# :nodoc: # Autogenerated from a Treetop grammar. Edits may be lost. require 'treetop' require 'weskit/wml' module WesnothMarkupLanguage include Treetop::Runtime def root @root ||= :document end module Document0 def wml ::Weskit::WML::Root.new.push *::Weskit::WML::Mixins::Grammar.reject_non_wml(elements) end end def _nt_document start_index = index if node_cache[:document].has_key?(index) cached = node_cache[:document][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end r0 = _nt_contents r0.extend(Document0) node_cache[:document][start_index] = r0 r0 end module Identifier0 end module Identifier1 def name text_value end end def _nt_identifier start_index = index if node_cache[:identifier].has_key?(index) cached = node_cache[:identifier][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if has_terminal?('\G[a-z]', true, index) r1 = true @index += 1 else r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do if has_terminal?('\G[a-z_]', true, index) r3 = true @index += 1 else r3 = nil end if r3 s2 << r3 else break end end r2 = instantiate_node(SyntaxNode,input, i2...index, s2) s0 << r2 end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Identifier0) r0.extend(Identifier1) else @index = i0 r0 = nil end node_cache[:identifier][start_index] = r0 r0 end module RawString0 end module RawString1 def data text_value end end def _nt_raw_string start_index = index if node_cache[:raw_string].has_key?(index) cached = node_cache[:raw_string][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do i1, s1 = index, [] i2 = index r3 = _nt_eol if r3 r2 = nil else @index = i2 r2 = instantiate_node(SyntaxNode,input, index...index) end s1 << r2 if r2 if index < input_length r4 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("any character") r4 = nil end s1 << r4 end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(RawString0) else @index = i1 r1 = nil end if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(RawString1) node_cache[:raw_string][start_index] = r0 r0 end module CodeContent0 def content elements[1] end end module CodeContent1 def contents text_value end end def _nt_code_content start_index = index if node_cache[:code_content].has_key?(index) cached = node_cache[:code_content][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do i1, s1 = index, [] i2 = index if has_terminal?('>>', false, index) r3 = instantiate_node(SyntaxNode,input, index...(index + 2)) @index += 2 else terminal_parse_failure('>>') r3 = nil end if r3 r2 = nil else @index = i2 r2 = instantiate_node(SyntaxNode,input, index...index) end s1 << r2 if r2 r4 = _nt_content s1 << r4 end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(CodeContent0) else @index = i1 r1 = nil end if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(CodeContent1) node_cache[:code_content][start_index] = r0 r0 end module CodeString0 def string elements[1] end end module CodeString1 def data string.contents end end def _nt_code_string start_index = index if node_cache[:code_string].has_key?(index) cached = node_cache[:code_string][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if has_terminal?('<<', false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 2)) @index += 2 else terminal_parse_failure('<<') r1 = nil end s0 << r1 if r1 r2 = _nt_code_content s0 << r2 if r2 if has_terminal?('>>', false, index) r3 = instantiate_node(SyntaxNode,input, index...(index + 2)) @index += 2 else terminal_parse_failure('>>') r3 = nil end s0 << r3 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(CodeString0) r0.extend(CodeString1) else @index = i0 r0 = nil end node_cache[:code_string][start_index] = r0 r0 end module MultilineContent0 def content elements[1] end end module MultilineContent1 def contents text_value end end def _nt_multiline_content start_index = index if node_cache[:multiline_content].has_key?(index) cached = node_cache[:multiline_content][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do i1, s1 = index, [] i2 = index r3 = _nt_quote if r3 r2 = nil else @index = i2 r2 = instantiate_node(SyntaxNode,input, index...index) end s1 << r2 if r2 r4 = _nt_content s1 << r4 end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(MultilineContent0) else @index = i1 r1 = nil end if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(MultilineContent1) node_cache[:multiline_content][start_index] = r0 r0 end module MultilineString0 def quote1 elements[0] end def string elements[1] end def quote2 elements[2] end end module MultilineString1 def data elements.collect(&:string).collect(&:contents).join '"' end end def _nt_multiline_string start_index = index if node_cache[:multiline_string].has_key?(index) cached = node_cache[:multiline_string][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do i1, s1 = index, [] r2 = _nt_quote s1 << r2 if r2 r3 = _nt_multiline_content s1 << r3 if r3 r4 = _nt_quote s1 << r4 end end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(MultilineString0) else @index = i1 r1 = nil end if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(MultilineString1) node_cache[:multiline_string][start_index] = r0 r0 end module TranslatableString0 def lws elements[1] end def string elements[2] end end module TranslatableString1 def data string.contents end end def _nt_translatable_string start_index = index if node_cache[:translatable_string].has_key?(index) cached = node_cache[:translatable_string][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if has_terminal?('_', false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('_') r1 = nil end s0 << r1 if r1 r2 = _nt_lws s0 << r2 if r2 r3 = _nt_multiline_string s0 << r3 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(TranslatableString0) r0.extend(TranslatableString1) else @index = i0 r0 = nil end node_cache[:translatable_string][start_index] = r0 r0 end module OpeningTag0 def lws elements[0] end def tag elements[2] end def fws elements[4] end end module OpeningTag1 def name tag.name end end def _nt_opening_tag start_index = index if node_cache[:opening_tag].has_key?(index) cached = node_cache[:opening_tag][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_lws s0 << r1 if r1 if has_terminal?('[', false, index) r2 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('[') r2 = nil end s0 << r2 if r2 r3 = _nt_identifier s0 << r3 if r3 if has_terminal?(']', false, index) r4 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure(']') r4 = nil end s0 << r4 if r4 r5 = _nt_fws s0 << r5 end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(OpeningTag0) r0.extend(OpeningTag1) else @index = i0 r0 = nil end node_cache[:opening_tag][start_index] = r0 r0 end module AmendingTag0 def lws elements[0] end def tag elements[2] end def fws elements[4] end end module AmendingTag1 def name tag.name end end def _nt_amending_tag start_index = index if node_cache[:amending_tag].has_key?(index) cached = node_cache[:amending_tag][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_lws s0 << r1 if r1 if has_terminal?('[+', false, index) r2 = instantiate_node(SyntaxNode,input, index...(index + 2)) @index += 2 else terminal_parse_failure('[+') r2 = nil end s0 << r2 if r2 r3 = _nt_identifier s0 << r3 if r3 if has_terminal?(']', false, index) r4 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure(']') r4 = nil end s0 << r4 if r4 r5 = _nt_fws s0 << r5 end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(AmendingTag0) r0.extend(AmendingTag1) else @index = i0 r0 = nil end node_cache[:amending_tag][start_index] = r0 r0 end module ClosingTag0 def lws elements[0] end def tag elements[2] end def fws elements[4] end end module ClosingTag1 def name tag.name end end def _nt_closing_tag start_index = index if node_cache[:closing_tag].has_key?(index) cached = node_cache[:closing_tag][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_lws s0 << r1 if r1 if has_terminal?('[/', false, index) r2 = instantiate_node(SyntaxNode,input, index...(index + 2)) @index += 2 else terminal_parse_failure('[/') r2 = nil end s0 << r2 if r2 r3 = _nt_identifier s0 << r3 if r3 if has_terminal?(']', false, index) r4 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure(']') r4 = nil end s0 << r4 if r4 r5 = _nt_fws s0 << r5 end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(ClosingTag0) r0.extend(ClosingTag1) else @index = i0 r0 = nil end node_cache[:closing_tag][start_index] = r0 r0 end module BlankLine0 end def _nt_blank_line start_index = index if node_cache[:blank_line].has_key?(index) cached = node_cache[:blank_line][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] s1, i1 = [], index loop do r2 = _nt_ws if r2 s1 << r2 else break end end r1 = instantiate_node(SyntaxNode,input, i1...index, s1) s0 << r1 if r1 if has_terminal?("\n", false, index) r3 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("\n") r3 = nil end s0 << r3 end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(BlankLine0) else @index = i0 r0 = nil end node_cache[:blank_line][start_index] = r0 r0 end def _nt_item start_index = index if node_cache[:item].has_key?(index) cached = node_cache[:item][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_code_attribute if r1 r0 = r1 else r2 = _nt_multiline_attribute if r2 r0 = r2 else r3 = _nt_translatable_attribute if r3 r0 = r3 else r4 = _nt_attribute if r4 r0 = r4 else r5 = _nt_amending_element if r5 r0 = r5 else r6 = _nt_element if r6 r0 = r6 else @index = i0 r0 = nil end end end end end end node_cache[:item][start_index] = r0 r0 end module Contents0 def items ::Weskit::WML::Mixins::Grammar.reject_non_wml elements end end def _nt_contents start_index = index if node_cache[:contents].has_key?(index) cached = node_cache[:contents][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do i1 = index r2 = _nt_blank_line if r2 r1 = r2 else r3 = _nt_item if r3 r1 = r3 else @index = i1 r1 = nil end end if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Contents0) node_cache[:contents][start_index] = r0 r0 end module Attribute0 def lws1 elements[0] end def id elements[1] end def lws2 elements[2] end def equals elements[3] end def value elements[4] end def eol elements[5] end end module Attribute1 def item ::Weskit::WML::Attribute.new id.name, value.data end end def _nt_attribute start_index = index if node_cache[:attribute].has_key?(index) cached = node_cache[:attribute][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_lws s0 << r1 if r1 r2 = _nt_identifier s0 << r2 if r2 r3 = _nt_lws s0 << r3 if r3 r4 = _nt_equals s0 << r4 if r4 r5 = _nt_raw_string s0 << r5 if r5 r6 = _nt_eol s0 << r6 end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Attribute0) r0.extend(Attribute1) else @index = i0 r0 = nil end node_cache[:attribute][start_index] = r0 r0 end module CodeAttribute0 def lws1 elements[0] end def id elements[1] end def lws2 elements[2] end def equals elements[3] end def lws3 elements[4] end def value elements[5] end def fws elements[6] end end module CodeAttribute1 def item ::Weskit::WML::Attribute.new id.name, value.data, :code => true end end def _nt_code_attribute start_index = index if node_cache[:code_attribute].has_key?(index) cached = node_cache[:code_attribute][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_lws s0 << r1 if r1 r2 = _nt_identifier s0 << r2 if r2 r3 = _nt_lws s0 << r3 if r3 r4 = _nt_equals s0 << r4 if r4 r5 = _nt_lws s0 << r5 if r5 r6 = _nt_code_string s0 << r6 if r6 r7 = _nt_fws s0 << r7 end end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(CodeAttribute0) r0.extend(CodeAttribute1) else @index = i0 r0 = nil end node_cache[:code_attribute][start_index] = r0 r0 end module MultilineAttribute0 def lws1 elements[0] end def id elements[1] end def lws2 elements[2] end def equals elements[3] end def lws3 elements[4] end def value elements[5] end def fws elements[6] end end module MultilineAttribute1 def item ::Weskit::WML::Attribute.new id.name, value.data end end def _nt_multiline_attribute start_index = index if node_cache[:multiline_attribute].has_key?(index) cached = node_cache[:multiline_attribute][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_lws s0 << r1 if r1 r2 = _nt_identifier s0 << r2 if r2 r3 = _nt_lws s0 << r3 if r3 r4 = _nt_equals s0 << r4 if r4 r5 = _nt_lws s0 << r5 if r5 r6 = _nt_multiline_string s0 << r6 if r6 r7 = _nt_fws s0 << r7 end end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(MultilineAttribute0) r0.extend(MultilineAttribute1) else @index = i0 r0 = nil end node_cache[:multiline_attribute][start_index] = r0 r0 end module TranslatableAttribute0 def lws1 elements[0] end def id elements[1] end def lws2 elements[2] end def equals elements[3] end def lws3 elements[4] end def lws4 elements[6] end def value elements[7] end def fws elements[8] end end module TranslatableAttribute1 def item ::Weskit::WML::Attribute.new id.name, value.data, :translatable => true end end def _nt_translatable_attribute start_index = index if node_cache[:translatable_attribute].has_key?(index) cached = node_cache[:translatable_attribute][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_lws s0 << r1 if r1 r2 = _nt_identifier s0 << r2 if r2 r3 = _nt_lws s0 << r3 if r3 r4 = _nt_equals s0 << r4 if r4 r5 = _nt_lws s0 << r5 if r5 if has_terminal?('_', false, index) r6 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('_') r6 = nil end s0 << r6 if r6 r7 = _nt_lws s0 << r7 if r7 r8 = _nt_multiline_string s0 << r8 if r8 r9 = _nt_fws s0 << r9 end end end end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(TranslatableAttribute0) r0.extend(TranslatableAttribute1) else @index = i0 r0 = nil end node_cache[:translatable_attribute][start_index] = r0 r0 end module Element0 def open elements[0] end def nested elements[1] end def close elements[2] end end module Element1 def item ::Weskit::WML::Mixins::Grammar.raise_on_mismatching open, close ::Weskit::WML::Element.new(open.name).push *nested.items end end def _nt_element start_index = index if node_cache[:element].has_key?(index) cached = node_cache[:element][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_opening_tag s0 << r1 if r1 r2 = _nt_contents s0 << r2 if r2 r3 = _nt_closing_tag s0 << r3 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Element0) r0.extend(Element1) else @index = i0 r0 = nil end node_cache[:element][start_index] = r0 r0 end module AmendingElement0 def open elements[0] end def nested elements[1] end def close elements[2] end end module AmendingElement1 def item ::Weskit::WML::Mixins::Grammar.raise_on_mismatching open, close ::Weskit::WML::Element.new(open.name, :amendment => true).push *nested.items end end def _nt_amending_element start_index = index if node_cache[:amending_element].has_key?(index) cached = node_cache[:amending_element][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_amending_tag s0 << r1 if r1 r2 = _nt_contents s0 << r2 if r2 r3 = _nt_closing_tag s0 << r3 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(AmendingElement0) r0.extend(AmendingElement1) else @index = i0 r0 = nil end node_cache[:amending_element][start_index] = r0 r0 end def _nt_content start_index = index if node_cache[:content].has_key?(index) cached = node_cache[:content][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index if has_terminal?("\n", false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("\n") r1 = nil end if r1 r0 = r1 else if index < input_length r2 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("any character") r2 = nil end if r2 r0 = r2 else @index = i0 r0 = nil end end node_cache[:content][start_index] = r0 r0 end def _nt_eol start_index = index if node_cache[:eol].has_key?(index) cached = node_cache[:eol][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index if has_terminal?("\n", false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("\n") r1 = nil end if r1 r0 = r1 else i2 = index if index < input_length r3 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("any character") r3 = nil end if r3 r2 = nil else @index = i2 r2 = instantiate_node(SyntaxNode,input, index...index) end if r2 r0 = r2 else @index = i0 r0 = nil end end node_cache[:eol][start_index] = r0 r0 end def _nt_equals start_index = index if node_cache[:equals].has_key?(index) cached = node_cache[:equals][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end if has_terminal?('=', false, index) r0 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('=') r0 = nil end node_cache[:equals][start_index] = r0 r0 end def _nt_quote start_index = index if node_cache[:quote].has_key?(index) cached = node_cache[:quote][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end if has_terminal?('"', false, index) r0 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('"') r0 = nil end node_cache[:quote][start_index] = r0 r0 end def _nt_ws start_index = index if node_cache[:ws].has_key?(index) cached = node_cache[:ws][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index if has_terminal?("\s", false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("\s") r1 = nil end if r1 r0 = r1 else if has_terminal?("\t", false, index) r2 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("\t") r2 = nil end if r2 r0 = r2 else @index = i0 r0 = nil end end node_cache[:ws][start_index] = r0 r0 end def _nt_lws start_index = index if node_cache[:lws].has_key?(index) cached = node_cache[:lws][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do r1 = _nt_ws if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) node_cache[:lws][start_index] = r0 r0 end module Fws0 def eol elements[1] end end def _nt_fws start_index = index if node_cache[:fws].has_key?(index) cached = node_cache[:fws][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] s1, i1 = [], index loop do r2 = _nt_ws if r2 s1 << r2 else break end end r1 = instantiate_node(SyntaxNode,input, i1...index, s1) s0 << r1 if r1 r3 = _nt_eol s0 << r3 end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Fws0) else @index = i0 r0 = nil end node_cache[:fws][start_index] = r0 r0 end end class WesnothMarkupLanguageParser < Treetop::Runtime::CompiledParser include WesnothMarkupLanguage end