# # 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 Status class Parser < Racc::Parser module_eval(<<'...end parser.y/module_eval...', 'parser.y', 35) def create_token(string) result = [] inside = false scanner = StringScanner.new(string) until scanner.empty? case when scanner.scan(/\s+/) # ignore whitespace when scanner.scan(/#[^\n]*/) # ignore comments when (!inside and match = scanner.scan(/\w+/)) result << [:TYPE, match] when match = scanner.scan(/\{/) inside = true result << [:OPEN, nil] when match = scanner.scan(/\}/) inside = false result << [:CLOSE, nil] when match = scanner.scan(/\w+\s*\=/) result << [:KEY, match.chop.gsub(/\s+$/, '')] when (inside and match = scanner.scan(/\d+$/)) result << [:VALUE, match.to_i] when (inside and 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, 8, 1, 13, 8, 4, 10, 11, 1 ] racc_action_check = [ 2, 4, 2, 9, 9, 1, 5, 8, 0 ] racc_action_pointer = [ 6, 2, 0, nil, -4, 6, nil, nil, 1, -1, nil, nil, nil, nil ] racc_action_default = [ -8, -8, -8, -1, -8, -8, -2, -4, -6, -8, 14, -7, -5, -3 ] racc_goto_table = [ 7, 3, 9, 6, 2, 12 ] racc_goto_check = [ 4, 2, 3, 2, 1, 4 ] racc_goto_pointer = [ nil, 4, 1, -2, -4 ] racc_goto_default = [ nil, nil, nil, nil, nil ] racc_reduce_table = [ 0, 0, :racc_error, 1, 8, :_reduce_none, 2, 8, :_reduce_none, 4, 9, :_reduce_3, 1, 10, :_reduce_none, 2, 10, :_reduce_5, 1, 11, :_reduce_6, 2, 11, :_reduce_7 ] racc_reduce_n = 8 racc_shift_n = 14 racc_token_table = { false => 0, :error => 1, :TYPE => 2, :OPEN => 3, :CLOSE => 4, :KEY => 5, :VALUE => 6 } racc_nt_base = 7 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", "TYPE", "OPEN", "CLOSE", "KEY", "VALUE", "$start", "types", "type", "assignments", "assignment" ] Racc_debug_parser = false ##### State transition tables end ##### # reduce 0 omitted # reduce 1 omitted # reduce 2 omitted module_eval(<<'.,.,', 'parser.y', 11) def _reduce_3(val, _values, result) @result[val[0]] ||= [] @result[val[0]] << val[2] result end .,., # reduce 4 omitted module_eval(<<'.,.,', 'parser.y', 18) def _reduce_5(val, _values, result) val[1].each do |key, value| val[0][key] = value end result = val[0] result end .,., module_eval(<<'.,.,', 'parser.y', 25) def _reduce_6(val, _values, result) result = {val[0] => nil} result end .,., module_eval(<<'.,.,', 'parser.y', 26) def _reduce_7(val, _values, result) result = {val[0] => val[1]} result end .,., def _reduce_none(val, _values, result) val[0] end end # class Parser end # module Status end # module NagiosParser