# Treetop (http://treetop.rubyforge.org/) grammar for package definitions from # Autogenerated from a Treetop grammar. Edits may be lost. # the early days. # Some aspects of this grammar are significantly dumber than they could be # because: # # * We want to treat statements as identically as possible to their # command-line equivalents. # * Treetop parse errors are pretty inscrutable at times and we can make # error messages clearer by validating a lot of the terminals ourselves. require 'treetop' require 'fig/grammar/base' require 'fig/grammar/version' module Fig module Grammar module V0 include Treetop::Runtime def root @root ||= :package end include Fig::Grammar::Base include Fig::Grammar::Version module Package0 def optional_ws1 elements[0] end def grammar_version elements[1] end def statements elements[3] end def optional_ws2 elements[4] 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 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 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_ws if r5 s4 << r5 else break end end r4 = instantiate_node(SyntaxNode,input, i4...index, s4) s0 << r4 if r4 s6, i6 = [], index loop do r7 = _nt_package_statement if r7 s6 << r7 else break end end r6 = instantiate_node(SyntaxNode,input, i6...index, s6) s0 << r6 if r6 r8 = _nt_optional_ws s0 << r8 end 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_package_statement start_index = index if node_cache[:package_statement].has_key?(index) cached = node_cache[:package_statement][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_archive if r1 r0 = r1 else r2 = _nt_resource if r2 r0 = r2 else r3 = _nt_retrieve if r3 r0 = r3 else r4 = _nt_config if r4 r0 = r4 else @index = i0 r0 = nil end end end end node_cache[:package_statement][start_index] = r0 r0 end module Archive0 def statement_start elements[0] end def location elements[2] end end module Archive1 def to_package_statement(build_state) return build_state.new_asset_statement( Statement::Archive, statement_start, location.location ) end end def _nt_archive start_index = index if node_cache[:archive].has_key?(index) cached = node_cache[:archive][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if has_terminal?('archive', false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 7)) @index += 7 else terminal_parse_failure('archive') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_ws 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_asset_location s0 << r4 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Archive0) r0.extend(Archive1) else @index = i0 r0 = nil end node_cache[:archive][start_index] = r0 r0 end module Resource0 def statement_start elements[0] end def location elements[2] end end module Resource1 def to_package_statement(build_state) return build_state.new_asset_statement( Statement::Resource, statement_start, location.location ) end end def _nt_resource start_index = index if node_cache[:resource].has_key?(index) cached = node_cache[:resource][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if has_terminal?('resource', false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 8)) @index += 8 else terminal_parse_failure('resource') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_ws 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_asset_location s0 << r4 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Resource0) r0.extend(Resource1) else @index = i0 r0 = nil end node_cache[:resource][start_index] = r0 r0 end module Retrieve0 def statement_start elements[0] end def variable elements[2] end def path elements[4] end end module Retrieve1 def to_package_statement(build_state) return build_state.new_retrieve_statement( statement_start, variable, path ) end end def _nt_retrieve start_index = index if node_cache[:retrieve].has_key?(index) cached = node_cache[:retrieve][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if has_terminal?('retrieve', false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 8)) @index += 8 else terminal_parse_failure('retrieve') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_ws 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_environment_variable_name s0 << r4 if r4 if has_terminal?('->', false, index) r5 = instantiate_node(SyntaxNode,input, index...(index + 2)) @index += 2 else terminal_parse_failure('->') r5 = nil end s0 << r5 if r5 r6 = _nt_retrieve_path s0 << r6 if r6 s7, i7 = [], index loop do r8 = _nt_ws if r8 s7 << r8 else break end end if s7.empty? @index = i7 r7 = nil else r7 = instantiate_node(SyntaxNode,input, i7...index, s7) end s0 << r7 end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Retrieve0) r0.extend(Retrieve1) else @index = i0 r0 = nil end node_cache[:retrieve][start_index] = r0 r0 end module Config0 def statement_start elements[0] end def config_name elements[2] end def statements elements[4] end end module Config1 def to_package_statement(build_state) return build_state.new_configuration_statement( statement_start, config_name, statements ) end end def _nt_config start_index = index if node_cache[:config].has_key?(index) cached = node_cache[:config][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if has_terminal?('config', false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 6)) @index += 6 else terminal_parse_failure('config') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_ws 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_config_name s0 << r4 if r4 s5, i5 = [], index loop do r6 = _nt_ws if r6 s5 << r6 else break end end if s5.empty? @index = i5 r5 = nil else r5 = instantiate_node(SyntaxNode,input, i5...index, s5) end s0 << r5 if r5 s7, i7 = [], index loop do r8 = _nt_config_statement if r8 s7 << r8 else break end end r7 = instantiate_node(SyntaxNode,input, i7...index, s7) s0 << r7 if r7 if has_terminal?('end', false, index) r9 = instantiate_node(SyntaxNode,input, index...(index + 3)) @index += 3 else terminal_parse_failure('end') r9 = nil end s0 << r9 if r9 s10, i10 = [], index loop do r11 = _nt_ws if r11 s10 << r11 else break end end if s10.empty? @index = i10 r10 = nil else r10 = instantiate_node(SyntaxNode,input, i10...index, s10) end s0 << r10 end end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Config0) r0.extend(Config1) else @index = i0 r0 = nil end node_cache[:config][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 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 r0 = r1 else r2 = _nt_include if r2 r0 = r2 else r3 = _nt_command if r3 r0 = r3 else r4 = _nt_path if r4 r0 = r4 else r5 = _nt_set if r5 r0 = r5 else @index = i0 r0 = nil end end end end end node_cache[:config_statement][start_index] = r0 r0 end module Include0 def statement_start elements[0] end def descriptor_string elements[2] end end module Include1 def to_config_statement(build_state) return build_state.new_include_statement( statement_start, descriptor_string ) end end def _nt_include start_index = index if node_cache[:include].has_key?(index) cached = node_cache[:include][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if has_terminal?('include', false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 7)) @index += 7 else terminal_parse_failure('include') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_ws 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_descriptor_string s0 << r4 if r4 s5, i5 = [], index loop do r6 = _nt_ws if r6 s5 << r6 else break end end if s5.empty? @index = i5 r5 = nil else r5 = instantiate_node(SyntaxNode,input, i5...index, s5) end s0 << r5 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Include0) r0.extend(Include1) else @index = i0 r0 = nil end node_cache[:include][start_index] = r0 r0 end module Override0 def statement_start elements[0] end def descriptor_string elements[2] end end module Override1 def to_config_statement(build_state) return build_state.new_override_statement( statement_start, descriptor_string ) end end def _nt_override start_index = index if node_cache[:override].has_key?(index) cached = node_cache[:override][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if has_terminal?('override', false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 8)) @index += 8 else terminal_parse_failure('override') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_ws 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_descriptor_string s0 << r4 if r4 s5, i5 = [], index loop do r6 = _nt_ws if r6 s5 << r6 else break end end if s5.empty? @index = i5 r5 = nil else r5 = instantiate_node(SyntaxNode,input, i5...index, s5) end s0 << r5 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Override0) r0.extend(Override1) else @index = i0 r0 = nil end node_cache[:override][start_index] = r0 r0 end module Set0 def statement_start elements[0] end def environment_variable_name_value elements[2] end end module Set1 def to_config_statement(build_state) return build_state.new_environment_variable_statement( Statement::Set, statement_start, environment_variable_name_value ) end end def _nt_set start_index = index if node_cache[:set].has_key?(index) cached = node_cache[:set][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if has_terminal?('set', false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 3)) @index += 3 else terminal_parse_failure('set') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_ws 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_environment_variable_name_value s0 << r4 if r4 s5, i5 = [], index loop do r6 = _nt_ws if r6 s5 << r6 else break end end if s5.empty? @index = i5 r5 = nil else r5 = instantiate_node(SyntaxNode,input, i5...index, s5) end s0 << r5 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Set0) r0.extend(Set1) else @index = i0 r0 = nil end node_cache[:set][start_index] = r0 r0 end module Path0 def statement_start elements[0] end def environment_variable_name_value elements[2] end end module Path1 def to_config_statement(build_state) return build_state.new_environment_variable_statement( Statement::Path, statement_start, environment_variable_name_value ) end end def _nt_path start_index = index if node_cache[:path].has_key?(index) cached = node_cache[:path][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] i1 = index if has_terminal?('add', false, index) r2 = instantiate_node(SyntaxNode,input, index...(index + 3)) @index += 3 else terminal_parse_failure('add') r2 = nil end if r2 r1 = r2 else if has_terminal?('append', false, index) r3 = instantiate_node(SyntaxNode,input, index...(index + 6)) @index += 6 else terminal_parse_failure('append') r3 = nil end if r3 r1 = r3 else if has_terminal?('path', false, index) r4 = instantiate_node(SyntaxNode,input, index...(index + 4)) @index += 4 else terminal_parse_failure('path') r4 = nil end if r4 r1 = r4 else @index = i1 r1 = nil end end end s0 << r1 if r1 s5, i5 = [], index loop do r6 = _nt_ws if r6 s5 << r6 else break end end if s5.empty? @index = i5 r5 = nil else r5 = instantiate_node(SyntaxNode,input, i5...index, s5) end s0 << r5 if r5 r7 = _nt_environment_variable_name_value s0 << r7 if r7 s8, i8 = [], index loop do r9 = _nt_ws if r9 s8 << r9 else break end end if s8.empty? @index = i8 r8 = nil else r8 = instantiate_node(SyntaxNode,input, i8...index, s8) end s0 << r8 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Path0) r0.extend(Path1) else @index = i0 r0 = nil end node_cache[:path][start_index] = r0 r0 end module Command0 def statement_start elements[0] end def command_line elements[2] end end module Command1 def to_config_statement(build_state) return build_state.new_v0_command_statement( statement_start, command_line ) end end def _nt_command start_index = index if node_cache[:command].has_key?(index) cached = node_cache[:command][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if has_terminal?('command', false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 7)) @index += 7 else terminal_parse_failure('command') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_ws 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_command_line s0 << r4 if r4 s5, i5 = [], index loop do r6 = _nt_ws if r6 s5 << r6 else break end end if s5.empty? @index = i5 r5 = nil else r5 = instantiate_node(SyntaxNode,input, i5...index, s5) end s0 << r5 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Command0) r0.extend(Command1) else @index = i0 r0 = nil end node_cache[:command][start_index] = r0 r0 end module CommandLine0 end def _nt_command_line start_index = index if node_cache[:command_line].has_key?(index) cached = node_cache[:command_line][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] if has_terminal?('"', false, index) r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('"') r1 = nil end s0 << r1 if r1 s2, i2 = [], index loop do if has_terminal?('\G[^"]', true, index) r3 = true @index += 1 else r3 = nil end if r3 s2 << r3 else break end end r2 = instantiate_node(SyntaxNode,input, i2...index, s2) s0 << r2 if r2 if has_terminal?('"', false, index) r4 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('"') r4 = nil end s0 << r4 end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(CommandLine0) else @index = i0 r0 = nil end node_cache[:command_line][start_index] = r0 r0 end def _nt_descriptor_string start_index = index if node_cache[:descriptor_string].has_key?(index) cached = node_cache[:descriptor_string][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do if has_terminal?('\G[\\S]', true, index) r1 = true @index += 1 else 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) end node_cache[:descriptor_string][start_index] = r0 r0 end def _nt_config_name start_index = index if node_cache[:config_name].has_key?(index) cached = node_cache[:config_name][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do if has_terminal?('\G[a-zA-Z0-9_.-]', true, index) r1 = true @index += 1 else 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) end node_cache[:config_name][start_index] = r0 r0 end def _nt_environment_variable_name start_index = index if node_cache[:environment_variable_name].has_key?(index) cached = node_cache[:environment_variable_name][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do if has_terminal?('\G[a-zA-Z0-9_]', true, index) r1 = true @index += 1 else 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) end node_cache[:environment_variable_name][start_index] = r0 r0 end def _nt_environment_variable_name_value start_index = index if node_cache[:environment_variable_name_value].has_key?(index) cached = node_cache[:environment_variable_name_value][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do if has_terminal?('\G[\\S]', true, index) r1 = true @index += 1 else 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) end node_cache[:environment_variable_name_value][start_index] = r0 r0 end module AssetLocation0 def location elements[0] end def ws elements[1] end end module AssetLocation1 def location elements[1] end def ws elements[3] end end def _nt_asset_location start_index = index if node_cache[:asset_location].has_key?(index) cached = node_cache[:asset_location][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, [] s2, i2 = [], index loop do if has_terminal?('\G[^@\'"<>|\\s]', true, index) r3 = true @index += 1 else r3 = nil end 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 s1 << r2 if r2 r4 = _nt_ws s1 << r4 end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(AssetLocation0) else @index = i1 r1 = nil end if r1 r0 = r1 else i5, s5 = index, [] if has_terminal?('"', false, index) r6 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('"') r6 = nil end s5 << r6 if r6 s7, i7 = [], index loop do if has_terminal?('\G[^@\'"<>|*?\\[\\]{}\\s]', true, index) r8 = true @index += 1 else r8 = nil end if r8 s7 << r8 else break end end if s7.empty? @index = i7 r7 = nil else r7 = instantiate_node(SyntaxNode,input, i7...index, s7) end s5 << r7 if r7 if has_terminal?('"', false, index) r9 = instantiate_node(SyntaxNode,input, index...(index + 1)) @index += 1 else terminal_parse_failure('"') r9 = nil end s5 << r9 if r9 r10 = _nt_ws s5 << r10 end end end if s5.last r5 = instantiate_node(SyntaxNode,input, i5...index, s5) r5.extend(AssetLocation1) else @index = i5 r5 = nil end if r5 r0 = r5 else @index = i0 r0 = nil end end node_cache[:asset_location][start_index] = r0 r0 end def _nt_retrieve_path start_index = index if node_cache[:retrieve_path].has_key?(index) cached = node_cache[:retrieve_path][index] if cached cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do if has_terminal?('\G[a-zA-Z0-9_/.\\[\\]-]', true, index) r1 = true @index += 1 else 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) end node_cache[:retrieve_path][start_index] = r0 r0 end end class V0Parser < Treetop::Runtime::CompiledParser include V0 end end end