# Autogenerated from a Treetop grammar. Edits may be lost. require "hemingway/math/math_nodes" module Hemingway module Math include Treetop::Runtime def root @root ||= :math end module Math0 def math_start elements[0] end def content elements[1] end def math_end elements[2] end end def _nt_math start_index = index if node_cache[:math].has_key?(index) cached = node_cache[:math][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_math_start s0 << r1 if r1 i2 = index r3 = _nt_symbol if r3 r2 = r3 else r4 = _nt_exponent if r4 r2 = r4 else @index = i2 r2 = nil end end s0 << r2 if r2 r5 = _nt_math_end s0 << r5 end end if s0.last r0 = instantiate_node(MathNode,input, i0...index, s0) r0.extend(Math0) else @index = i0 r0 = nil end node_cache[:math][start_index] = r0 r0 end def _nt_symbol start_index = index if node_cache[:symbol].has_key?(index) cached = node_cache[:symbol][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end r0 = _nt_math_symbol node_cache[:symbol][start_index] = r0 r0 end module Exponent0 def value elements[1] end end def _nt_exponent start_index = index if node_cache[:exponent].has_key?(index) cached = node_cache[:exponent][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 i2 = index if has_terminal?("\\circ", false, index) r3 = instantiate_node(SyntaxNode,input, index...(index + 5)) @index += 5 else terminal_parse_failure("\\circ") r3 = nil end if r3 r2 = r3 else r4 = _nt_text if r4 r2 = r4 else @index = i2 r2 = nil end end s0 << r2 if r2 if has_terminal?("}", false, index) r5 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r5 = nil end s0 << r5 end end if s0.last r0 = instantiate_node(ExponentNode,input, i0...index, s0) r0.extend(Exponent0) else @index = i0 r0 = nil end node_cache[:exponent][start_index] = r0 r0 end def _nt_math_start start_index = index if node_cache[:math_start].has_key?(index) cached = node_cache[:math_start][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[:math_start][start_index] = r0 r0 end def _nt_math_end start_index = index if node_cache[:math_end].has_key?(index) cached = node_cache[:math_end][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[:math_end][start_index] = r0 r0 end end class MathParser < Treetop::Runtime::CompiledParser include Math end end