_nt_grammar (Treetop::Compiler::Metagrammar)

    # File lib/treetop/compiler/metagrammar.rb, line 398
          def _nt_grammar
            start_index = index
            if node_cache[:grammar].has_key?(index)
              cached = node_cache[:grammar][index]
              @index = cached.interval.end if cached
              return cached
            end

            i0, s0 = index, []
            if input.index('grammar', index) == index
              r1 = instantiate_node(SyntaxNode,input, index...(index + 7))
              @index += 7
            else
              terminal_parse_failure('grammar')
              r1 = nil
            end
            s0 << r1
            if r1
              r2 = _nt_space
              s0 << r2
              if r2
                r3 = _nt_grammar_name
                s0 << r3
                if r3
                  r4 = _nt_space
                  s0 << r4
                  if r4
                    i6, s6 = index, []
                    if input.index('do', index) == index
                      r7 = instantiate_node(SyntaxNode,input, index...(index + 2))
                      @index += 2
                    else
                      terminal_parse_failure('do')
                      r7 = nil
                    end
                    s6 << r7
                    if r7
                      r8 = _nt_space
                      s6 << r8
                    end
                    if s6.last
                      r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
                      r6.extend(Grammar0)
                    else
                      self.index = i6
                      r6 = nil
                    end
                    if r6
                      r5 = r6
                    else
                      r5 = instantiate_node(SyntaxNode,input, index...index)
                    end
                    s0 << r5
                    if r5
                      r9 = _nt_declaration_sequence
                      s0 << r9
                      if r9
                        r11 = _nt_space
                        if r11
                          r10 = r11
                        else
                          r10 = instantiate_node(SyntaxNode,input, index...index)
                        end
                        s0 << r10
                        if r10
                          if input.index('end', index) == index
                            r12 = instantiate_node(SyntaxNode,input, index...(index + 3))
                            @index += 3
                          else
                            terminal_parse_failure('end')
                            r12 = nil
                          end
                          s0 << r12
                        end
                      end
                    end
                  end
                end
              end
            end
            if s0.last
              r0 = instantiate_node(Grammar,input, i0...index, s0)
              r0.extend(Grammar1)
            else
              self.index = i0
              r0 = nil
            end

            node_cache[:grammar][start_index] = r0

            return r0
          end