# Autogenerated from a Treetop grammar. Edits may be lost. require "hemingway/block/block_nodes" require "hemingway/block/list/list" require "hemingway/block/verbatim/verbatim" require "hemingway/block/quote/quote" module Hemingway module Block include Treetop::Runtime def root @root ||= :block end include List include Verbatim include Quote module Block0 def block_start elements[0] end def type elements[1] end def whitespace1 elements[3] end def content elements[4] end def whitespace2 elements[5] end def block_end elements[6] end def list_type elements[7] end end module Block1 def block_start elements[0] end def type elements[1] end def whitespace1 elements[3] end def content elements[4] end def whitespace2 elements[5] end def block_end elements[6] end def verbatim_type elements[7] end end module Block2 def block_start elements[0] end def type elements[1] end def whitespace1 elements[3] end def content elements[4] end def whitespace2 elements[5] end def block_end elements[6] end def quote_type elements[7] end end def _nt_block start_index = index if node_cache[:block].has_key?(index) cached = node_cache[:block][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index i1, s1 = index, [] r2 = _nt_block_start s1 << r2 if r2 r3 = _nt_list_type s1 << 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 s1 << r4 if r4 r5 = _nt_whitespace s1 << r5 if r5 r6 = _nt_list s1 << r6 if r6 r7 = _nt_whitespace s1 << r7 if r7 r8 = _nt_block_end s1 << r8 if r8 r9 = _nt_list_type s1 << r9 if r9 if has_terminal?("}", false, index) r10 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r10 = nil end s1 << r10 if r10 i11 = index r12 = lambda { |seq| seq[1].text_value == seq[7].text_value }.call(s1) if r12 @index = i11 r11 = instantiate_node(SyntaxNode,input, index...index) else r11 = nil end s1 << r11 end end end end end end end end end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(Block0) else @index = i1 r1 = nil end if r1 r0 = r1 r0.extend(BlockNode) else i13, s13 = index, [] r14 = _nt_block_start s13 << r14 if r14 r15 = _nt_verbatim_type s13 << r15 if r15 if has_terminal?("}", false, index) r16 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r16 = nil end s13 << r16 if r16 r17 = _nt_whitespace s13 << r17 if r17 r18 = _nt_verbatim s13 << r18 if r18 r19 = _nt_whitespace s13 << r19 if r19 r20 = _nt_block_end s13 << r20 if r20 r21 = _nt_verbatim_type s13 << r21 if r21 if has_terminal?("}", false, index) r22 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r22 = nil end s13 << r22 end end end end end end end end if s13.last r13 = instantiate_node(SyntaxNode,input, i13...index, s13) r13.extend(Block1) else @index = i13 r13 = nil end if r13 r0 = r13 r0.extend(BlockNode) else i23, s23 = index, [] r24 = _nt_block_start s23 << r24 if r24 r25 = _nt_quote_type s23 << r25 if r25 if has_terminal?("}", false, index) r26 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r26 = nil end s23 << r26 if r26 r27 = _nt_whitespace s23 << r27 if r27 r28 = _nt_quote_entry s23 << r28 if r28 r29 = _nt_whitespace s23 << r29 if r29 r30 = _nt_block_end s23 << r30 if r30 r31 = _nt_quote_type s23 << r31 if r31 if has_terminal?("}", false, index) r32 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r32 = nil end s23 << r32 end end end end end end end end if s23.last r23 = instantiate_node(SyntaxNode,input, i23...index, s23) r23.extend(Block2) else @index = i23 r23 = nil end if r23 r0 = r23 r0.extend(BlockNode) else @index = i0 r0 = nil end end end node_cache[:block][start_index] = r0 r0 end def _nt_block_start start_index = index if node_cache[:block_start].has_key?(index) cached = node_cache[:block_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?("\\begin{", false, index) r0 = instantiate_node(SyntaxNode,input, index...(index + 7)) @index += 7 else terminal_parse_failure("\\begin{") r0 = nil end node_cache[:block_start][start_index] = r0 r0 end def _nt_block_end start_index = index if node_cache[:block_end].has_key?(index) cached = node_cache[:block_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?("\\end{", false, index) r0 = instantiate_node(SyntaxNode,input, index...(index + 5)) @index += 5 else terminal_parse_failure("\\end{") r0 = nil end node_cache[:block_end][start_index] = r0 r0 end end class BlockParser < Treetop::Runtime::CompiledParser include Block end end