# Autogenerated from a Treetop grammar. Edits may be lost. require 'hemingway/build' require 'hemingway/latex_nodes' require "hemingway/block/block" require "hemingway/footnote/footnote" require "hemingway/math/math" require "hemingway/special/special" require "hemingway/symbol/symbol" require "hemingway/tag/tag" require "hemingway/text/text" module Hemingway module Latex include Treetop::Runtime def root @root ||= :document end include Block include Footnote include Math include Special include Symbol include Tag include Text 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_entry node_cache[:document][start_index] = r0 r0 end def _nt_entry start_index = index if node_cache[:entry].has_key?(index) cached = node_cache[:entry][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_paragraph if r2 r1 = r2 else r3 = _nt_last_paragraph if r3 r1 = r3 else @index = i1 r1 = nil end end if r1 s0 << r1 else break end end r0 = instantiate_node(EntryNode,input, i0...index, s0) node_cache[:entry][start_index] = r0 r0 end module Paragraph0 def sequence elements[0] end def eop elements[1] end end def _nt_paragraph start_index = index if node_cache[:paragraph].has_key?(index) cached = node_cache[:paragraph][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 i2 = index r3 = _nt_content if r3 r2 = r3 else r4 = _nt_footnote if r4 r2 = r4 else @index = i2 r2 = nil end end if r2 s1 << r2 else break end end r1 = instantiate_node(SyntaxNode,input, i1...index, s1) s0 << r1 if r1 r5 = _nt_eop s0 << r5 end if s0.last r0 = instantiate_node(ParagraphNode,input, i0...index, s0) r0.extend(Paragraph0) else @index = i0 r0 = nil end node_cache[:paragraph][start_index] = r0 r0 end module LastParagraph0 def sequence elements[0] end end def _nt_last_paragraph start_index = index if node_cache[:last_paragraph].has_key?(index) cached = node_cache[:last_paragraph][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 i2 = index r3 = _nt_content if r3 r2 = r3 else r4 = _nt_footnote if r4 r2 = r4 else @index = i2 r2 = nil end end if r2 s1 << r2 else break end end if s1.empty? @index = i1 r1 = nil else r1 = instantiate_node(SyntaxNode,input, i1...index, s1) end s0 << r1 if r1 r6 = _nt_eop if r6 r5 = r6 else r5 = instantiate_node(SyntaxNode,input, index...index) end s0 << r5 end if s0.last r0 = instantiate_node(ParagraphNode,input, i0...index, s0) r0.extend(LastParagraph0) else @index = i0 r0 = nil end node_cache[:last_paragraph][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 r1 = _nt_special if r1 r0 = r1 else r2 = _nt_tag if r2 r0 = r2 else r3 = _nt_block if r3 r0 = r3 else r4 = _nt_math if r4 r0 = r4 else r5 = _nt_text if r5 r0 = r5 else @index = i0 r0 = nil end end end end end node_cache[:content][start_index] = r0 r0 end def _nt_whitespace start_index = index if node_cache[:whitespace].has_key?(index) cached = node_cache[:whitespace][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 if has_terminal?(" ", false, index) r2 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure(" ") r2 = nil end if r2 r1 = r2 else r3 = _nt_newline 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) node_cache[:whitespace][start_index] = r0 r0 end def _nt_spaces start_index = index if node_cache[:spaces].has_key?(index) cached = node_cache[:spaces][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 if has_terminal?(" ", false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure(" ") r1 = nil end if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) node_cache[:spaces][start_index] = r0 r0 end def _nt_eop start_index = index if node_cache[:eop].has_key?(index) cached = node_cache[:eop][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_newline if r1 s0 << r1 else break end end if s0.size < 2 @index = i0 r0 = nil else r0 = instantiate_node(SyntaxNode,input, i0...index, s0) end node_cache[:eop][start_index] = r0 r0 end def _nt_newline start_index = index if node_cache[:newline].has_key?(index) cached = node_cache[:newline][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end if has_terminal?("\n", false, index) r0 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("\n") r0 = nil end node_cache[:newline][start_index] = r0 r0 end end class LatexParser < Treetop::Runtime::CompiledParser include Latex end end