# coding: utf-8 # Autogenerated from a Treetop grammar. Edits may be lost. # Treetop (http://treetop.rubyforge.org/) grammar for package definitions in v1 # format. require 'treetop' require 'fig/grammar/base' require 'fig/grammar/v1_base' require 'fig/grammar/version' module Fig module Grammar module V1 include Treetop::Runtime def root @root ||= :package end include Fig::Grammar::Base include Fig::Grammar::Version include Fig::Grammar::V1Base module Package0 def optional_ws_or_comment1 elements[0] end def grammar_version elements[1] end def statements elements[2] end def optional_ws_or_comment2 elements[3] end end module Package1 def to_package(unparsed_package, build_state) return build_state.new_package_statement( unparsed_package, grammar_version, statements ) end end def _nt_package start_index = index if node_cache[:package].has_key?(index) cached = node_cache[:package][index] if cached node_cache[:package][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_optional_ws_or_comment s0 << r1 if r1 r3 = _nt_grammar_version if r3 r2 = r3 else r2 = instantiate_node(SyntaxNode,input, index...index) end s0 << r2 if r2 s4, i4 = [], index loop do r5 = _nt_package_statement_with_ws if r5 s4 << r5 else break end end r4 = instantiate_node(SyntaxNode,input, i4...index, s4) s0 << r4 if r4 r6 = _nt_optional_ws_or_comment s0 << r6 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Package0) r0.extend(Package1) else @index = i0 r0 = nil end node_cache[:package][start_index] = r0 r0 end def _nt_config_statement start_index = index if node_cache[:config_statement].has_key?(index) cached = node_cache[:config_statement][index] if cached node_cache[:config_statement][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_override if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else r2 = _nt_include if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 else r3 = _nt_command if r3 r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true r0 = r3 else r4 = _nt_path if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r0 = r4 else r5 = _nt_set if r5 r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true r0 = r5 else @index = i0 r0 = nil end end end end end node_cache[:config_statement][start_index] = r0 r0 end end class V1Parser < Treetop::Runtime::CompiledParser include V1 end end end