# 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" require "hemingway/block/center/center" module Hemingway module Block include Treetop::Runtime def root @root ||= :block end include List include Verbatim include Quote include Center module Block0 def block_start elements[0] end def type elements[1] end def content elements[4] 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 content elements[4] 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 content elements[4] end def block_end elements[6] end def quote_type elements[7] end end module Block3 def block_start elements[0] end def type elements[1] end def content elements[4] end def block_end elements[6] end def center_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 r6 = _nt_whitespace if r6 r5 = r6 else r5 = instantiate_node(SyntaxNode,input, index...index) end s1 << r5 if r5 r7 = _nt_list s1 << r7 if r7 r9 = _nt_whitespace if r9 r8 = r9 else r8 = instantiate_node(SyntaxNode,input, index...index) end s1 << r8 if r8 r10 = _nt_block_end s1 << r10 if r10 r11 = _nt_list_type s1 << r11 if r11 if has_terminal?("}", false, index) r12 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r12 = nil end s1 << r12 if r12 i13 = index r14 = lambda { |seq| seq[1].text_value == seq[7].text_value }.call(s1) if r14 @index = i13 r13 = instantiate_node(SyntaxNode,input, index...index) else r13 = nil end s1 << r13 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 i15, s15 = index, [] r16 = _nt_block_start s15 << r16 if r16 r17 = _nt_verbatim_type s15 << r17 if r17 if has_terminal?("}", false, index) r18 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r18 = nil end s15 << r18 if r18 r20 = _nt_whitespace if r20 r19 = r20 else r19 = instantiate_node(SyntaxNode,input, index...index) end s15 << r19 if r19 r21 = _nt_verbatim s15 << r21 if r21 r23 = _nt_whitespace if r23 r22 = r23 else r22 = instantiate_node(SyntaxNode,input, index...index) end s15 << r22 if r22 r24 = _nt_block_end s15 << r24 if r24 r25 = _nt_verbatim_type s15 << 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 s15 << r26 end end end end end end end end if s15.last r15 = instantiate_node(SyntaxNode,input, i15...index, s15) r15.extend(Block1) else @index = i15 r15 = nil end if r15 r0 = r15 r0.extend(BlockNode) else i27, s27 = index, [] r28 = _nt_block_start s27 << r28 if r28 r29 = _nt_quote_type s27 << r29 if r29 if has_terminal?("}", false, index) r30 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r30 = nil end s27 << r30 if r30 r32 = _nt_whitespace if r32 r31 = r32 else r31 = instantiate_node(SyntaxNode,input, index...index) end s27 << r31 if r31 r33 = _nt_quote_entry s27 << r33 if r33 r35 = _nt_whitespace if r35 r34 = r35 else r34 = instantiate_node(SyntaxNode,input, index...index) end s27 << r34 if r34 r36 = _nt_block_end s27 << r36 if r36 r37 = _nt_quote_type s27 << r37 if r37 if has_terminal?("}", false, index) r38 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r38 = nil end s27 << r38 end end end end end end end end if s27.last r27 = instantiate_node(SyntaxNode,input, i27...index, s27) r27.extend(Block2) else @index = i27 r27 = nil end if r27 r0 = r27 r0.extend(BlockNode) else i39, s39 = index, [] r40 = _nt_block_start s39 << r40 if r40 r41 = _nt_center_type s39 << r41 if r41 if has_terminal?("}", false, index) r42 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r42 = nil end s39 << r42 if r42 r44 = _nt_whitespace if r44 r43 = r44 else r43 = instantiate_node(SyntaxNode,input, index...index) end s39 << r43 if r43 r45 = _nt_center s39 << r45 if r45 r47 = _nt_whitespace if r47 r46 = r47 else r46 = instantiate_node(SyntaxNode,input, index...index) end s39 << r46 if r46 r48 = _nt_block_end s39 << r48 if r48 r49 = _nt_center_type s39 << r49 if r49 if has_terminal?("}", false, index) r50 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure("}") r50 = nil end s39 << r50 end end end end end end end end if s39.last r39 = instantiate_node(SyntaxNode,input, i39...index, s39) r39.extend(Block3) else @index = i39 r39 = nil end if r39 r0 = r39 r0.extend(BlockNode) else @index = i0 r0 = nil end 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