# Autogenerated from a Treetop grammar. Edits may be lost. module OrigenVerilog # The preprocessor implements the below compiler directives, fully substituting # and including/excluding the text as appropriate before handing over the pre-processed # text to be parsed as Verilog. # # Any compiler directives not listed below will be parsed during the main Verilog parsing # stage and will be included in the Verilog AST. # # * define # * undef # * ifdef # * ifndef # * include # * error module Preprocessor module Grammar include Treetop::Runtime def root @root ||= :source end include Verilog::Grammar module Source0 def to_ast n :source, *elements_to_ast end end def _nt_source start_index = index if node_cache[:source].has_key?(index) cached = node_cache[:source][index] if cached node_cache[:source][index] = 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_source_items if r1 s0 << r1 else break end end if s0.empty? @index = i0 r0 = nil else r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Source0) r0.extend(Source0) end node_cache[:source][start_index] = r0 r0 end def _nt_source_items start_index = index if node_cache[:source_items].has_key?(index) cached = node_cache[:source_items][index] if cached node_cache[:source_items][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_comment if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else r2 = _nt_compiler_directive if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 else r3 = _nt_macro_reference if r3 r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true r0 = r3 else r4 = _nt_text_block if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r0 = r4 else @index = i0 r0 = nil end end end end node_cache[:source_items][start_index] = r0 r0 end module TextBlock0 end module TextBlock1 def to_ast n :text_block, text_value end end def _nt_text_block start_index = index if node_cache[:text_block].has_key?(index) cached = node_cache[:text_block][index] if cached node_cache[:text_block][index] = 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 i3 = index r4 = _nt_comment if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r3 = r4 else r5 = _nt_compiler_directive if r5 r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true r3 = r5 else r6 = _nt_compiler_directive_terminator if r6 r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true r3 = r6 else r7 = _nt_macro_reference if r7 r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true r3 = r7 else @index = i3 r3 = nil end end end end if r3 @index = i2 r2 = nil terminal_parse_failure("(any alternative)", true) else @terminal_failures.pop @index = i2 r2 = instantiate_node(SyntaxNode,input, index...index) end s1 << r2 if r2 if index < input_length r8 = true @index += 1 else terminal_parse_failure("any character") r8 = nil end s1 << r8 end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(TextBlock0) else @index = i1 r1 = nil end if r1 s0 << r1 else break end end if s0.empty? @index = i0 r0 = nil else r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(TextBlock1) r0.extend(TextBlock1) end node_cache[:text_block][start_index] = r0 r0 end def _nt_compiler_directive start_index = index if node_cache[:compiler_directive].has_key?(index) cached = node_cache[:compiler_directive][index] if cached node_cache[:compiler_directive][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_text_macro_definition if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else r2 = _nt_undefine_compiler_directive if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 else r3 = _nt_ifdef_directive if r3 r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true r0 = r3 else r4 = _nt_ifndef_directive if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r0 = r4 else r5 = _nt_include_compiler_directive if r5 r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true r0 = r5 else r6 = _nt_error_compiler_directive if r6 r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true r0 = r6 else @index = i0 r0 = nil end end end end end end node_cache[:compiler_directive][start_index] = r0 r0 end def _nt_compiler_directive_terminator start_index = index if node_cache[:compiler_directive_terminator].has_key?(index) cached = node_cache[:compiler_directive_terminator][index] if cached node_cache[:compiler_directive_terminator][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index if (match_len = has_terminal?("`else", false, index)) r1 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`else"') r1 = nil end if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else if (match_len = has_terminal?("`elsif", false, index)) r2 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`elsif"') r2 = nil end if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 else if (match_len = has_terminal?("`endif", false, index)) r3 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`endif"') r3 = nil end if r3 r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true r0 = r3 else @index = i0 r0 = nil end end end node_cache[:compiler_directive_terminator][start_index] = r0 r0 end module MacroReference0 def text_macro_identifier elements[1] end end module MacroReference1 def args elements[2] end end module MacroReference2 def name elements[1] end def s2 elements[3] end end module MacroReference3 def to_ast if s2.respond_to?(:args) n :macro_reference, name.text_value, s2.args.to_ast else n :macro_reference, name.text_value end end end def _nt_macro_reference start_index = index if node_cache[:macro_reference].has_key?(index) cached = node_cache[:macro_reference][index] if cached node_cache[:macro_reference][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if (match_len = has_terminal?("`", false, index)) r1 = true @index += match_len else terminal_parse_failure('"`"') r1 = nil end s0 << r1 if r1 i2, s2 = index, [] i3 = index r4 = _nt_illegal_macro_reference if r4 @index = i3 r3 = nil else @index = i3 r3 = instantiate_node(SyntaxNode,input, index...index) end s2 << r3 if r3 r5 = _nt_text_macro_identifier s2 << r5 end if s2.last r2 = instantiate_node(SyntaxNode,input, i2...index, s2) r2.extend(MacroReference0) else @index = i2 r2 = nil end s0 << r2 if r2 s6, i6 = [], index loop do r7 = _nt_space if r7 s6 << r7 else break end end r6 = instantiate_node(SyntaxNode,input, i6...index, s6) s0 << r6 if r6 i9, s9 = index, [] if (match_len = has_terminal?("(", false, index)) r10 = true @index += match_len else terminal_parse_failure('"("') r10 = nil end s9 << r10 if r10 s11, i11 = [], index loop do r12 = _nt_space if r12 s11 << r12 else break end end r11 = instantiate_node(SyntaxNode,input, i11...index, s11) s9 << r11 if r11 r13 = _nt_list_of_actual_arguments s9 << r13 if r13 s14, i14 = [], index loop do r15 = _nt_space if r15 s14 << r15 else break end end r14 = instantiate_node(SyntaxNode,input, i14...index, s14) s9 << r14 if r14 if (match_len = has_terminal?(")", false, index)) r16 = true @index += match_len else terminal_parse_failure('")"') r16 = nil end s9 << r16 end end end end if s9.last r9 = instantiate_node(SyntaxNode,input, i9...index, s9) r9.extend(MacroReference1) else @index = i9 r9 = nil end if r9 r8 = r9 else r8 = instantiate_node(SyntaxNode,input, index...index) end s0 << r8 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(MacroReference2) r0.extend(MacroReference3) else @index = i0 r0 = nil end node_cache[:macro_reference][start_index] = r0 r0 end module ListOfActualArguments0 def actual_argument elements[3] end end module ListOfActualArguments1 def actual_argument elements[0] end end module ListOfActualArguments2 def to_ast n :arguments, *elements_to_ast end end def _nt_list_of_actual_arguments start_index = index if node_cache[:list_of_actual_arguments].has_key?(index) cached = node_cache[:list_of_actual_arguments][index] if cached node_cache[:list_of_actual_arguments][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_actual_argument s0 << r1 if r1 s2, i2 = [], index loop do i3, s3 = index, [] s4, i4 = [], index loop do r5 = _nt_space if r5 s4 << r5 else break end end r4 = instantiate_node(SyntaxNode,input, i4...index, s4) s3 << r4 if r4 if (match_len = has_terminal?(',', false, index)) r6 = true @index += match_len else terminal_parse_failure('\',\'') r6 = nil end s3 << r6 if r6 s7, i7 = [], index loop do r8 = _nt_space if r8 s7 << r8 else break end end r7 = instantiate_node(SyntaxNode,input, i7...index, s7) s3 << r7 if r7 r9 = _nt_actual_argument s3 << r9 end end end if s3.last r3 = instantiate_node(SyntaxNode,input, i3...index, s3) r3.extend(ListOfActualArguments0) else @index = i3 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(ListOfActualArguments1) r0.extend(ListOfActualArguments2) else @index = i0 r0 = nil end node_cache[:list_of_actual_arguments][start_index] = r0 r0 end module ActualArgument0 def to_ast text_value end end def _nt_actual_argument start_index = index if node_cache[:actual_argument].has_key?(index) cached = node_cache[:actual_argument][index] if cached node_cache[:actual_argument][index] = 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_actual_argument_section if r1 s0 << r1 else break end end if s0.empty? @index = i0 r0 = nil else r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(ActualArgument0) r0.extend(ActualArgument0) end node_cache[:actual_argument][start_index] = r0 r0 end def _nt_actual_argument_section start_index = index if node_cache[:actual_argument_section].has_key?(index) cached = node_cache[:actual_argument_section][index] if cached node_cache[:actual_argument_section][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index if has_terminal?(@regexps[gr = '\A[^,(){}\\[\\]]'] ||= Regexp.new(gr), :regexp, index) r1 = true @index += 1 else terminal_parse_failure('[^,(){}\\[\\]]') r1 = nil end if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else r2 = _nt_balanced_bracket_string if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 else r3 = _nt_balanced_square_bracket_string if r3 r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true r0 = r3 else r4 = _nt_balanced_curly_bracket_string if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r0 = r4 else @index = i0 r0 = nil end end end end node_cache[:actual_argument_section][start_index] = r0 r0 end module BalancedBracketString0 end def _nt_balanced_bracket_string start_index = index if node_cache[:balanced_bracket_string].has_key?(index) cached = node_cache[:balanced_bracket_string][index] if cached node_cache[:balanced_bracket_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if (match_len = has_terminal?("(", false, index)) r1 = true @index += match_len else terminal_parse_failure('"("') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do i3 = index if has_terminal?(@regexps[gr = '\A[^\\(\\)]'] ||= Regexp.new(gr), :regexp, index) r4 = true @index += 1 else terminal_parse_failure('[^\\(\\)]') r4 = nil end if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r3 = r4 else r5 = _nt_balanced_bracket_string if r5 r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true r3 = r5 else @index = i3 r3 = nil end end if r3 s2 << r3 else break end end r2 = instantiate_node(SyntaxNode,input, i2...index, s2) s0 << r2 if r2 if (match_len = has_terminal?(")", false, index)) r6 = true @index += match_len else terminal_parse_failure('")"') r6 = nil end s0 << r6 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(BalancedBracketString0) else @index = i0 r0 = nil end node_cache[:balanced_bracket_string][start_index] = r0 r0 end module BalancedSquareBracketString0 end def _nt_balanced_square_bracket_string start_index = index if node_cache[:balanced_square_bracket_string].has_key?(index) cached = node_cache[:balanced_square_bracket_string][index] if cached node_cache[:balanced_square_bracket_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if (match_len = has_terminal?("[", false, index)) r1 = true @index += match_len else terminal_parse_failure('"["') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do i3 = index if has_terminal?(@regexps[gr = '\A[^\\[\\]]'] ||= Regexp.new(gr), :regexp, index) r4 = true @index += 1 else terminal_parse_failure('[^\\[\\]]') r4 = nil end if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r3 = r4 else r5 = _nt_balanced_square_bracket_string if r5 r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true r3 = r5 else @index = i3 r3 = nil end end if r3 s2 << r3 else break end end r2 = instantiate_node(SyntaxNode,input, i2...index, s2) s0 << r2 if r2 if (match_len = has_terminal?("]", false, index)) r6 = true @index += match_len else terminal_parse_failure('"]"') r6 = nil end s0 << r6 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(BalancedSquareBracketString0) else @index = i0 r0 = nil end node_cache[:balanced_square_bracket_string][start_index] = r0 r0 end module BalancedCurlyBracketString0 end def _nt_balanced_curly_bracket_string start_index = index if node_cache[:balanced_curly_bracket_string].has_key?(index) cached = node_cache[:balanced_curly_bracket_string][index] if cached node_cache[:balanced_curly_bracket_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if (match_len = has_terminal?("{", false, index)) r1 = true @index += match_len else terminal_parse_failure('"{"') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do i3 = index if has_terminal?(@regexps[gr = '\A[^\\{\\}]'] ||= Regexp.new(gr), :regexp, index) r4 = true @index += 1 else terminal_parse_failure('[^\\{\\}]') r4 = nil end if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r3 = r4 else r5 = _nt_balanced_curly_bracket_string if r5 r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true r3 = r5 else @index = i3 r3 = nil end end if r3 s2 << r3 else break end end r2 = instantiate_node(SyntaxNode,input, i2...index, s2) s0 << r2 if r2 if (match_len = has_terminal?("}", false, index)) r6 = true @index += match_len else terminal_parse_failure('"}"') r6 = nil end s0 << r6 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(BalancedCurlyBracketString0) else @index = i0 r0 = nil end node_cache[:balanced_curly_bracket_string][start_index] = r0 r0 end def _nt_illegal_macro_reference start_index = index if node_cache[:illegal_macro_reference].has_key?(index) cached = node_cache[:illegal_macro_reference][index] if cached node_cache[:illegal_macro_reference][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index if (match_len = has_terminal?("begin_keywords", false, index)) r1 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"begin_keywords"') r1 = nil end if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else if (match_len = has_terminal?("celldefine", false, index)) r2 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"celldefine"') r2 = nil end if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 else if (match_len = has_terminal?("default_nettype", false, index)) r3 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"default_nettype"') r3 = nil end if r3 r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true r0 = r3 else if (match_len = has_terminal?("define", false, index)) r4 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"define"') r4 = nil end if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r0 = r4 else if (match_len = has_terminal?("else", false, index)) r5 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"else"') r5 = nil end if r5 r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true r0 = r5 else if (match_len = has_terminal?("elsif", false, index)) r6 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"elsif"') r6 = nil end if r6 r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true r0 = r6 else if (match_len = has_terminal?("end_keywords", false, index)) r7 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"end_keywords"') r7 = nil end if r7 r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true r0 = r7 else if (match_len = has_terminal?("endcelldefine", false, index)) r8 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"endcelldefine"') r8 = nil end if r8 r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true r0 = r8 else if (match_len = has_terminal?("endif", false, index)) r9 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"endif"') r9 = nil end if r9 r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true r0 = r9 else if (match_len = has_terminal?("ifdef", false, index)) r10 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"ifdef"') r10 = nil end if r10 r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true r0 = r10 else if (match_len = has_terminal?("ifndef", false, index)) r11 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"ifndef"') r11 = nil end if r11 r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true r0 = r11 else if (match_len = has_terminal?("include", false, index)) r12 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"include"') r12 = nil end if r12 r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true r0 = r12 else if (match_len = has_terminal?("line", false, index)) r13 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"line"') r13 = nil end if r13 r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true r0 = r13 else if (match_len = has_terminal?("nounconnected_drive", false, index)) r14 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"nounconnected_drive"') r14 = nil end if r14 r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true r0 = r14 else if (match_len = has_terminal?("pragma", false, index)) r15 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"pragma"') r15 = nil end if r15 r15 = SyntaxNode.new(input, (index-1)...index) if r15 == true r0 = r15 else if (match_len = has_terminal?("resetall", false, index)) r16 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"resetall"') r16 = nil end if r16 r16 = SyntaxNode.new(input, (index-1)...index) if r16 == true r0 = r16 else if (match_len = has_terminal?("timescale", false, index)) r17 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"timescale"') r17 = nil end if r17 r17 = SyntaxNode.new(input, (index-1)...index) if r17 == true r0 = r17 else if (match_len = has_terminal?("unconnected_drive", false, index)) r18 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"unconnected_drive"') r18 = nil end if r18 r18 = SyntaxNode.new(input, (index-1)...index) if r18 == true r0 = r18 else if (match_len = has_terminal?("undef", false, index)) r19 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"undef"') r19 = nil end if r19 r19 = SyntaxNode.new(input, (index-1)...index) if r19 == true r0 = r19 else if (match_len = has_terminal?("error", false, index)) r20 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"error"') r20 = nil end if r20 r20 = SyntaxNode.new(input, (index-1)...index) if r20 == true r0 = r20 else @index = i0 r0 = nil end end end end end end end end end end end end end end end end end end end end node_cache[:illegal_macro_reference][start_index] = r0 r0 end module ErrorCompilerDirective0 def filename elements[4] end end module ErrorCompilerDirective1 def to_ast n :error, *elements_to_ast end end def _nt_error_compiler_directive start_index = index if node_cache[:error_compiler_directive].has_key?(index) cached = node_cache[:error_compiler_directive][index] if cached node_cache[:error_compiler_directive][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if (match_len = has_terminal?("`error", false, index)) r1 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`error"') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_space if r3 s2 << r3 else break end end if s2.empty? @index = i2 r2 = nil else r2 = instantiate_node(SyntaxNode,input, i2...index, s2) end s0 << r2 if r2 if (match_len = has_terminal?('"', false, index)) r4 = true @index += match_len else terminal_parse_failure('\'"\'') r4 = nil end s0 << r4 if r4 s5, i5 = [], index loop do r6 = _nt_space if r6 s5 << r6 else break end end r5 = instantiate_node(SyntaxNode,input, i5...index, s5) s0 << r5 if r5 r7 = _nt_filename s0 << r7 if r7 s8, i8 = [], index loop do r9 = _nt_space if r9 s8 << r9 else break end end r8 = instantiate_node(SyntaxNode,input, i8...index, s8) s0 << r8 if r8 if (match_len = has_terminal?('"', false, index)) r10 = true @index += match_len else terminal_parse_failure('\'"\'') r10 = nil end s0 << r10 end end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(ErrorCompilerDirective0) r0.extend(ErrorCompilerDirective1) else @index = i0 r0 = nil end node_cache[:error_compiler_directive][start_index] = r0 r0 end module IncludeCompilerDirective0 def filename elements[4] end end module IncludeCompilerDirective1 def to_ast n :include, *elements_to_ast end end def _nt_include_compiler_directive start_index = index if node_cache[:include_compiler_directive].has_key?(index) cached = node_cache[:include_compiler_directive][index] if cached node_cache[:include_compiler_directive][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if (match_len = has_terminal?("`include", false, index)) r1 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`include"') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_space if r3 s2 << r3 else break end end if s2.empty? @index = i2 r2 = nil else r2 = instantiate_node(SyntaxNode,input, i2...index, s2) end s0 << r2 if r2 if (match_len = has_terminal?('"', false, index)) r4 = true @index += match_len else terminal_parse_failure('\'"\'') r4 = nil end s0 << r4 if r4 s5, i5 = [], index loop do r6 = _nt_space if r6 s5 << r6 else break end end r5 = instantiate_node(SyntaxNode,input, i5...index, s5) s0 << r5 if r5 r7 = _nt_filename s0 << r7 if r7 s8, i8 = [], index loop do r9 = _nt_space if r9 s8 << r9 else break end end r8 = instantiate_node(SyntaxNode,input, i8...index, s8) s0 << r8 if r8 if (match_len = has_terminal?('"', false, index)) r10 = true @index += match_len else terminal_parse_failure('\'"\'') r10 = nil end s0 << r10 end end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(IncludeCompilerDirective0) r0.extend(IncludeCompilerDirective1) else @index = i0 r0 = nil end node_cache[:include_compiler_directive][start_index] = r0 r0 end module Filename0 end module Filename1 def to_ast text_value.strip end end def _nt_filename start_index = index if node_cache[:filename].has_key?(index) cached = node_cache[:filename][index] if cached node_cache[:filename][index] = 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 i3 = index r4 = _nt_N if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r3 = r4 else r5 = _nt_comment if r5 r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true r3 = r5 else if (match_len = has_terminal?('"', false, index)) r6 = true @index += match_len else terminal_parse_failure('\'"\'') r6 = nil end if r6 r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true r3 = r6 else @index = i3 r3 = nil end end end if r3 @index = i2 r2 = nil terminal_parse_failure("(any alternative)", true) else @terminal_failures.pop @index = i2 r2 = instantiate_node(SyntaxNode,input, index...index) end s1 << r2 if r2 if index < input_length r7 = true @index += 1 else terminal_parse_failure("any character") r7 = nil end s1 << r7 end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(Filename0) else @index = i1 r1 = nil end if r1 s0 << r1 else break end end if s0.empty? @index = i0 r0 = nil else r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Filename1) r0.extend(Filename1) end node_cache[:filename][start_index] = r0 r0 end module TextMacroDefinition0 def text_macro_name elements[2] end end module TextMacroDefinition1 def to_ast n :define, *elements_to_ast end end def _nt_text_macro_definition start_index = index if node_cache[:text_macro_definition].has_key?(index) cached = node_cache[:text_macro_definition][index] if cached node_cache[:text_macro_definition][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if (match_len = has_terminal?("`define", false, index)) r1 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`define"') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_space if r3 s2 << r3 else break end end if s2.empty? @index = i2 r2 = nil else r2 = instantiate_node(SyntaxNode,input, i2...index, s2) end s0 << r2 if r2 r4 = _nt_text_macro_name s0 << r4 if r4 s5, i5 = [], index loop do r6 = _nt_space if r6 s5 << r6 else break end end r5 = instantiate_node(SyntaxNode,input, i5...index, s5) s0 << r5 if r5 r8 = _nt_macro_text if r8 r7 = r8 else r7 = instantiate_node(SyntaxNode,input, index...index) end s0 << r7 end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(TextMacroDefinition0) r0.extend(TextMacroDefinition1) else @index = i0 r0 = nil end node_cache[:text_macro_definition][start_index] = r0 r0 end module MacroText0 def N elements[2] end end module MacroText1 end module MacroText2 def to_ast n :text, text_value.strip.gsub(/\\\s*\n/, "\n") unless text_value.empty? end end def _nt_macro_text start_index = index if node_cache[:macro_text].has_key?(index) cached = node_cache[:macro_text][index] if cached node_cache[:macro_text][index] = 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 i2, s2 = index, [] if (match_len = has_terminal?("\\", false, index)) r3 = true @index += match_len else terminal_parse_failure('"\\\\"') r3 = nil end s2 << r3 if r3 s4, i4 = [], index loop do r5 = _nt_space if r5 s4 << r5 else break end end r4 = instantiate_node(SyntaxNode,input, i4...index, s4) s2 << r4 if r4 r6 = _nt_N s2 << r6 end end if s2.last r2 = instantiate_node(SyntaxNode,input, i2...index, s2) r2.extend(MacroText0) else @index = i2 r2 = nil end if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r1 = r2 else i7, s7 = index, [] i8 = index i9 = index r10 = _nt_N if r10 r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true r9 = r10 else r11 = _nt_one_line_comment if r11 r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true r9 = r11 else @index = i9 r9 = nil end end if r9 @index = i8 r8 = nil terminal_parse_failure("(any alternative)", true) else @terminal_failures.pop @index = i8 r8 = instantiate_node(SyntaxNode,input, index...index) end s7 << r8 if r8 if index < input_length r12 = true @index += 1 else terminal_parse_failure("any character") r12 = nil end s7 << r12 end if s7.last r7 = instantiate_node(SyntaxNode,input, i7...index, s7) r7.extend(MacroText1) else @index = i7 r7 = nil end if r7 r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true r1 = r7 else @index = i1 r1 = nil end end if r1 s0 << r1 else break end end if s0.empty? @index = i0 r0 = nil else r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(MacroText2) r0.extend(MacroText2) end node_cache[:macro_text][start_index] = r0 r0 end module TextMacroName0 def list_of_formal_arguments elements[2] end end module TextMacroName1 def text_macro_identifier elements[0] end end module TextMacroName2 def to_ast n :name, *elements_to_ast end end def _nt_text_macro_name start_index = index if node_cache[:text_macro_name].has_key?(index) cached = node_cache[:text_macro_name][index] if cached node_cache[:text_macro_name][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_text_macro_identifier s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_space if r3 s2 << r3 else break end end r2 = instantiate_node(SyntaxNode,input, i2...index, s2) s0 << r2 if r2 i5, s5 = index, [] if (match_len = has_terminal?("(", false, index)) r6 = true @index += match_len else terminal_parse_failure('"("') r6 = nil end s5 << r6 if r6 s7, i7 = [], index loop do r8 = _nt_space if r8 s7 << r8 else break end end r7 = instantiate_node(SyntaxNode,input, i7...index, s7) s5 << r7 if r7 r9 = _nt_list_of_formal_arguments s5 << r9 if r9 s10, i10 = [], index loop do r11 = _nt_space if r11 s10 << r11 else break end end r10 = instantiate_node(SyntaxNode,input, i10...index, s10) s5 << r10 if r10 if (match_len = has_terminal?(")", false, index)) r12 = true @index += match_len else terminal_parse_failure('")"') r12 = nil end s5 << r12 end end end end if s5.last r5 = instantiate_node(SyntaxNode,input, i5...index, s5) r5.extend(TextMacroName0) else @index = i5 r5 = nil end if r5 r4 = r5 else r4 = instantiate_node(SyntaxNode,input, index...index) end s0 << r4 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(TextMacroName1) r0.extend(TextMacroName2) else @index = i0 r0 = nil end node_cache[:text_macro_name][start_index] = r0 r0 end module ListOfFormalArguments0 def formal_argument_identifier elements[3] end end module ListOfFormalArguments1 def formal_argument_identifier elements[0] end end module ListOfFormalArguments2 def to_ast n :arguments, *elements_to_ast end end def _nt_list_of_formal_arguments start_index = index if node_cache[:list_of_formal_arguments].has_key?(index) cached = node_cache[:list_of_formal_arguments][index] if cached node_cache[:list_of_formal_arguments][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_formal_argument_identifier s0 << r1 if r1 s2, i2 = [], index loop do i3, s3 = index, [] s4, i4 = [], index loop do r5 = _nt_space if r5 s4 << r5 else break end end r4 = instantiate_node(SyntaxNode,input, i4...index, s4) s3 << r4 if r4 if (match_len = has_terminal?(',', false, index)) r6 = true @index += match_len else terminal_parse_failure('\',\'') r6 = nil end s3 << r6 if r6 s7, i7 = [], index loop do r8 = _nt_space if r8 s7 << r8 else break end end r7 = instantiate_node(SyntaxNode,input, i7...index, s7) s3 << r7 if r7 r9 = _nt_formal_argument_identifier s3 << r9 end end end if s3.last r3 = instantiate_node(SyntaxNode,input, i3...index, s3) r3.extend(ListOfFormalArguments0) else @index = i3 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(ListOfFormalArguments1) r0.extend(ListOfFormalArguments2) else @index = i0 r0 = nil end node_cache[:list_of_formal_arguments][start_index] = r0 r0 end def _nt_formal_argument_identifier start_index = index if node_cache[:formal_argument_identifier].has_key?(index) cached = node_cache[:formal_argument_identifier][index] if cached node_cache[:formal_argument_identifier][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end r0 = _nt_simple_identifier node_cache[:formal_argument_identifier][start_index] = r0 r0 end module UndefineCompilerDirective0 def text_macro_identifier elements[2] end end module UndefineCompilerDirective1 def to_ast n :undef, *elements_to_ast end end def _nt_undefine_compiler_directive start_index = index if node_cache[:undefine_compiler_directive].has_key?(index) cached = node_cache[:undefine_compiler_directive][index] if cached node_cache[:undefine_compiler_directive][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if (match_len = has_terminal?("`undef", false, index)) r1 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`undef"') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_space if r3 s2 << r3 else break end end if s2.empty? @index = i2 r2 = nil else r2 = instantiate_node(SyntaxNode,input, i2...index, s2) end s0 << r2 if r2 r4 = _nt_text_macro_identifier s0 << r4 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(UndefineCompilerDirective0) r0.extend(UndefineCompilerDirective1) else @index = i0 r0 = nil end node_cache[:undefine_compiler_directive][start_index] = r0 r0 end module IfdefDirective0 def label elements[2] end def contents elements[4] end end module IfdefDirective1 def contents elements[2] end end module IfdefDirective2 def label elements[2] end def contents elements[4] end def s elements[5] end def elsif_nodes elements[6] end def else_node elements[8] end end module IfdefDirective3 def to_ast node = n :ifdef, label.text_value, *elements_to_ast(contents.elements) elsif_nodes.elements.each do |elsif_node| if elsif_node.respond_to?(:contents) e = n :elsif, elsif_node.label.text_value, *elements_to_ast(elsif_node.contents.elements) node = node.updated(nil, node.children + [e]) end end if else_node.respond_to?(:contents) node = node.updated(nil, node.children + [n(:else, *elements_to_ast(else_node.contents.elements))]) end node end end def _nt_ifdef_directive start_index = index if node_cache[:ifdef_directive].has_key?(index) cached = node_cache[:ifdef_directive][index] if cached node_cache[:ifdef_directive][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if (match_len = has_terminal?("`ifdef", false, index)) r1 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`ifdef"') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_space if r3 s2 << r3 else break end end if s2.empty? @index = i2 r2 = nil else r2 = instantiate_node(SyntaxNode,input, i2...index, s2) end s0 << r2 if r2 r4 = _nt_text_macro_identifier s0 << r4 if r4 s5, i5 = [], index loop do r6 = _nt_space if r6 s5 << r6 else break end end r5 = instantiate_node(SyntaxNode,input, i5...index, s5) s0 << r5 if r5 s7, i7 = [], index loop do r8 = _nt_source_items if r8 s7 << r8 else break end end r7 = instantiate_node(SyntaxNode,input, i7...index, s7) s0 << r7 if r7 r9 = _nt_s s0 << r9 if r9 s10, i10 = [], index loop do i11, s11 = index, [] if (match_len = has_terminal?("`elsif", false, index)) r12 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`elsif"') r12 = nil end s11 << r12 if r12 s13, i13 = [], index loop do r14 = _nt_space if r14 s13 << r14 else break end end if s13.empty? @index = i13 r13 = nil else r13 = instantiate_node(SyntaxNode,input, i13...index, s13) end s11 << r13 if r13 r15 = _nt_text_macro_identifier s11 << r15 if r15 s16, i16 = [], index loop do r17 = _nt_space if r17 s16 << r17 else break end end r16 = instantiate_node(SyntaxNode,input, i16...index, s16) s11 << r16 if r16 s18, i18 = [], index loop do r19 = _nt_source_items if r19 s18 << r19 else break end end r18 = instantiate_node(SyntaxNode,input, i18...index, s18) s11 << r18 end end end end if s11.last r11 = instantiate_node(SyntaxNode,input, i11...index, s11) r11.extend(IfdefDirective0) else @index = i11 r11 = nil end if r11 s10 << r11 else break end end r10 = instantiate_node(SyntaxNode,input, i10...index, s10) s0 << r10 if r10 s20, i20 = [], index loop do r21 = _nt_space if r21 s20 << r21 else break end end r20 = instantiate_node(SyntaxNode,input, i20...index, s20) s0 << r20 if r20 i23, s23 = index, [] if (match_len = has_terminal?("`else", false, index)) r24 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`else"') r24 = nil end s23 << r24 if r24 s25, i25 = [], index loop do r26 = _nt_space if r26 s25 << r26 else break end end r25 = instantiate_node(SyntaxNode,input, i25...index, s25) s23 << r25 if r25 s27, i27 = [], index loop do r28 = _nt_source_items if r28 s27 << r28 else break end end r27 = instantiate_node(SyntaxNode,input, i27...index, s27) s23 << r27 end end if s23.last r23 = instantiate_node(SyntaxNode,input, i23...index, s23) r23.extend(IfdefDirective1) else @index = i23 r23 = nil end if r23 r22 = r23 else r22 = instantiate_node(SyntaxNode,input, index...index) end s0 << r22 if r22 s29, i29 = [], index loop do r30 = _nt_space if r30 s29 << r30 else break end end r29 = instantiate_node(SyntaxNode,input, i29...index, s29) s0 << r29 if r29 if (match_len = has_terminal?("`endif", false, index)) r31 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`endif"') r31 = nil end s0 << r31 end end end end end end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(IfdefDirective2) r0.extend(IfdefDirective3) else @index = i0 r0 = nil end node_cache[:ifdef_directive][start_index] = r0 r0 end module IfndefDirective0 def label elements[2] end def contents elements[4] end end module IfndefDirective1 def contents elements[2] end end module IfndefDirective2 def label elements[2] end def contents elements[4] end def s elements[5] end def elsif_nodes elements[6] end def else_node elements[8] end end module IfndefDirective3 def to_ast node = n :ifndef, label.text_value, *elements_to_ast(contents.elements) elsif_nodes.elements.each do |elsif_node| if elsif_node.respond_to?(:contents) e = n :elsif, elsif_node.label.text_value, *elements_to_ast(elsif_node.contents.elements) node = node.updated(nil, node.children + [e]) end end if else_node.respond_to?(:contents) node = node.updated(nil, node.children + [n(:else, *elements_to_ast(else_node.contents.elements))]) end node end end def _nt_ifndef_directive start_index = index if node_cache[:ifndef_directive].has_key?(index) cached = node_cache[:ifndef_directive][index] if cached node_cache[:ifndef_directive][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if (match_len = has_terminal?("`ifndef", false, index)) r1 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`ifndef"') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_space if r3 s2 << r3 else break end end if s2.empty? @index = i2 r2 = nil else r2 = instantiate_node(SyntaxNode,input, i2...index, s2) end s0 << r2 if r2 r4 = _nt_text_macro_identifier s0 << r4 if r4 s5, i5 = [], index loop do r6 = _nt_space if r6 s5 << r6 else break end end r5 = instantiate_node(SyntaxNode,input, i5...index, s5) s0 << r5 if r5 s7, i7 = [], index loop do r8 = _nt_source_items if r8 s7 << r8 else break end end r7 = instantiate_node(SyntaxNode,input, i7...index, s7) s0 << r7 if r7 r9 = _nt_s s0 << r9 if r9 s10, i10 = [], index loop do i11, s11 = index, [] if (match_len = has_terminal?("`elsif", false, index)) r12 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`elsif"') r12 = nil end s11 << r12 if r12 s13, i13 = [], index loop do r14 = _nt_space if r14 s13 << r14 else break end end if s13.empty? @index = i13 r13 = nil else r13 = instantiate_node(SyntaxNode,input, i13...index, s13) end s11 << r13 if r13 r15 = _nt_text_macro_identifier s11 << r15 if r15 s16, i16 = [], index loop do r17 = _nt_space if r17 s16 << r17 else break end end r16 = instantiate_node(SyntaxNode,input, i16...index, s16) s11 << r16 if r16 s18, i18 = [], index loop do r19 = _nt_source_items if r19 s18 << r19 else break end end r18 = instantiate_node(SyntaxNode,input, i18...index, s18) s11 << r18 end end end end if s11.last r11 = instantiate_node(SyntaxNode,input, i11...index, s11) r11.extend(IfndefDirective0) else @index = i11 r11 = nil end if r11 s10 << r11 else break end end r10 = instantiate_node(SyntaxNode,input, i10...index, s10) s0 << r10 if r10 s20, i20 = [], index loop do r21 = _nt_space if r21 s20 << r21 else break end end r20 = instantiate_node(SyntaxNode,input, i20...index, s20) s0 << r20 if r20 i23, s23 = index, [] if (match_len = has_terminal?("`else", false, index)) r24 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`else"') r24 = nil end s23 << r24 if r24 s25, i25 = [], index loop do r26 = _nt_space if r26 s25 << r26 else break end end r25 = instantiate_node(SyntaxNode,input, i25...index, s25) s23 << r25 if r25 s27, i27 = [], index loop do r28 = _nt_source_items if r28 s27 << r28 else break end end r27 = instantiate_node(SyntaxNode,input, i27...index, s27) s23 << r27 end end if s23.last r23 = instantiate_node(SyntaxNode,input, i23...index, s23) r23.extend(IfndefDirective1) else @index = i23 r23 = nil end if r23 r22 = r23 else r22 = instantiate_node(SyntaxNode,input, index...index) end s0 << r22 if r22 s29, i29 = [], index loop do r30 = _nt_space if r30 s29 << r30 else break end end r29 = instantiate_node(SyntaxNode,input, i29...index, s29) s0 << r29 if r29 if (match_len = has_terminal?("`endif", false, index)) r31 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"`endif"') r31 = nil end s0 << r31 end end end end end end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(IfndefDirective2) r0.extend(IfndefDirective3) else @index = i0 r0 = nil end node_cache[:ifndef_directive][start_index] = r0 r0 end module BlockComment0 end module BlockComment1 def end_of_comment elements[2] end end module BlockComment2 def to_ast n :comment, text_value end end def _nt_block_comment start_index = index if node_cache[:block_comment].has_key?(index) cached = node_cache[:block_comment][index] if cached node_cache[:block_comment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if (match_len = has_terminal?("/*", false, index)) r1 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"/*"') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do i3, s3 = index, [] i4 = index r5 = _nt_end_of_comment if r5 @index = i4 r4 = nil else @index = i4 r4 = instantiate_node(SyntaxNode,input, index...index) end s3 << r4 if r4 if index < input_length r6 = true @index += 1 else terminal_parse_failure("any character") r6 = nil end s3 << r6 end if s3.last r3 = instantiate_node(SyntaxNode,input, i3...index, s3) r3.extend(BlockComment0) else @index = i3 r3 = nil end if r3 s2 << r3 else break end end r2 = instantiate_node(SyntaxNode,input, i2...index, s2) s0 << r2 if r2 r7 = _nt_end_of_comment s0 << r7 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(BlockComment1) r0.extend(BlockComment2) else @index = i0 r0 = nil end node_cache[:block_comment][start_index] = r0 r0 end module OneLineComment0 end module OneLineComment1 end module OneLineComment2 def to_ast n :comment, text_value end end def _nt_one_line_comment start_index = index if node_cache[:one_line_comment].has_key?(index) cached = node_cache[:one_line_comment][index] if cached node_cache[:one_line_comment][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if (match_len = has_terminal?("//", false, index)) r1 = instantiate_node(SyntaxNode,input, index...(index + match_len)) @index += match_len else terminal_parse_failure('"//"') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do i3, s3 = index, [] i4 = index r5 = _nt_N if r5 @index = i4 r4 = nil else @index = i4 r4 = instantiate_node(SyntaxNode,input, index...index) end s3 << r4 if r4 if index < input_length r6 = true @index += 1 else terminal_parse_failure("any character") r6 = nil end s3 << r6 end if s3.last r3 = instantiate_node(SyntaxNode,input, i3...index, s3) r3.extend(OneLineComment0) else @index = i3 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(OneLineComment1) r0.extend(OneLineComment2) else @index = i0 r0 = nil end node_cache[:one_line_comment][start_index] = r0 r0 end end class GrammarParser < Treetop::Runtime::CompiledParser include Grammar end end end