# # DO NOT MODIFY!!!! # This file is automatically generated by Racc 1.4.6 # from Racc grammer file "". # require 'racc/parser.rb' require 'strscan' module NagiosParser module Resource class Parser < Racc::Parser module_eval(<<'...end parser.y/module_eval...', 'parser.y', 19) def create_token(string) result = [] scanner = StringScanner.new(string) until scanner.empty? case when scanner.scan(/\s+/) # ignore whitespace when scanner.scan(/#[^\n]*/) # ignore comments when match = scanner.scan(/\$\w+\$\s*\=/) result << [:KEY, match.chop.gsub(/\s+$/, '')] when match = scanner.scan(/[^\n]+/) result << [:VALUE, match.gsub(/\s+$/, '')] else raise "Can't tokenize <#{scanner.peek(10)}>" end end result << [false, false] end attr_accessor :token def self.parse(string) new.parse(string) end def parse(string) @result = {} @token = create_token(string) do_parse @result end def next_token @token.shift end ...end parser.y/module_eval... ##### State transition tables begin ### racc_action_table = [ 5, 1, 1, 4, 7 ] racc_action_check = [ 2, 0, 2, 1, 5 ] racc_action_pointer = [ -1, 0, 0, nil, nil, 4, nil, nil ] racc_action_default = [ -4, -4, -4, -1, -3, -4, -2, 8 ] racc_goto_table = [ 3, 2, 6 ] racc_goto_check = [ 2, 1, 2 ] racc_goto_pointer = [ nil, 1, 0 ] racc_goto_default = [ nil, nil, nil ] racc_reduce_table = [ 0, 0, :racc_error, 1, 5, :_reduce_none, 2, 5, :_reduce_none, 2, 6, :_reduce_3 ] racc_reduce_n = 4 racc_shift_n = 8 racc_token_table = { false => 0, :error => 1, :KEY => 2, :VALUE => 3 } racc_nt_base = 4 racc_use_result_var = true Racc_arg = [ racc_action_table, racc_action_check, racc_action_default, racc_action_pointer, racc_goto_table, racc_goto_check, racc_goto_default, racc_goto_pointer, racc_nt_base, racc_reduce_table, racc_token_table, racc_shift_n, racc_reduce_n, racc_use_result_var ] Racc_token_to_s_table = [ "$end", "error", "KEY", "VALUE", "$start", "assignments", "assignment" ] Racc_debug_parser = false ##### State transition tables end ##### # reduce 0 omitted # reduce 1 omitted # reduce 2 omitted module_eval(<<'.,.,', 'parser.y', 10) def _reduce_3(val, _values, result) @result[val[0]] = val[1] result end .,., def _reduce_none(val, _values, result) val[0] end end # class Parser end # module Resource end # module NagiosParser