lib/nagios_parser/status/parser.rb in nagios_parser-1.0.0 vs lib/nagios_parser/status/parser.rb in nagios_parser-1.1.0

- old
+ new

@@ -10,11 +10,11 @@ module NagiosParser module Status class Parser < Racc::Parser -module_eval(<<'...end parser.y/module_eval...', 'parser.y', 39) +module_eval(<<'...end parser.y/module_eval...', 'parser.y', 35) def create_token(string) result = [] inside = false scanner = StringScanner.new(string) @@ -24,11 +24,11 @@ when scanner.scan(/\s+/) # ignore whitespace when scanner.scan(/#[^\n]*/) # ignore comments when (!inside and match = scanner.scan(/\w+/)) - result << [match, match] + result << [:TYPE, match] when match = scanner.scan(/\{/) inside = true result << [:OPEN, nil] when match = scanner.scan(/\}/) inside = false @@ -65,78 +65,59 @@ end ...end parser.y/module_eval... ##### State transition tables begin ### racc_action_table = [ - 11, 19, 15, 13, 15, 18, 6, 7, 8, 9, - 10, 1, 2, 6, 7, 8, 9, 10, 1, 2, - 14 ] + 5, 8, 1, 13, 8, 4, 10, 11, 1 ] racc_action_check = [ - 3, 16, 16, 5, 13, 15, 3, 3, 3, 3, - 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, - 11 ] + 2, 4, 2, 9, 9, 1, 5, 8, 0 ] racc_action_pointer = [ - 7, nil, nil, 0, nil, 1, nil, nil, nil, nil, - nil, 20, nil, 0, nil, 0, -2, nil, nil, nil, - nil ] + 6, 2, 0, nil, -4, 6, nil, nil, 1, -1, + nil, nil, nil, nil ] racc_action_default = [ - -15, -9, -10, -15, -1, -15, -4, -5, -6, -7, - -8, -15, -2, -15, 21, -13, -15, -11, -14, -3, - -12 ] + -8, -8, -8, -1, -8, -8, -2, -4, -6, -8, + 14, -7, -5, -3 ] racc_goto_table = [ - 17, 4, 16, 20, 12, 3 ] + 7, 3, 9, 6, 2, 12 ] racc_goto_check = [ - 5, 2, 4, 5, 2, 1 ] + 4, 2, 3, 2, 1, 4 ] racc_goto_pointer = [ - nil, 5, 1, nil, -11, -13 ] + nil, 4, 1, -2, -4 ] racc_goto_default = [ - nil, nil, nil, 5, nil, nil ] + nil, nil, nil, nil, nil ] racc_reduce_table = [ 0, 0, :racc_error, - 1, 14, :_reduce_none, - 2, 14, :_reduce_none, - 4, 15, :_reduce_3, - 1, 16, :_reduce_none, - 1, 16, :_reduce_none, - 1, 16, :_reduce_none, - 1, 16, :_reduce_none, - 1, 16, :_reduce_none, - 1, 16, :_reduce_none, - 1, 16, :_reduce_none, - 1, 17, :_reduce_none, - 2, 17, :_reduce_12, - 1, 18, :_reduce_13, - 2, 18, :_reduce_14 ] + 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 = 15 +racc_reduce_n = 8 -racc_shift_n = 21 +racc_shift_n = 14 racc_token_table = { false => 0, :error => 1, - :OPEN => 2, - :CLOSE => 3, - :KEY => 4, - :VALUE => 5, - "hostcomment" => 6, - "servicestatus" => 7, - "info" => 8, - "programstatus" => 9, - "hoststatus" => 10, - "contactstatus" => 11, - "servicecomment" => 12 } + :TYPE => 2, + :OPEN => 3, + :CLOSE => 4, + :KEY => 5, + :VALUE => 6 } -racc_nt_base = 13 +racc_nt_base = 7 racc_use_result_var = true Racc_arg = [ racc_action_table, @@ -155,25 +136,18 @@ racc_use_result_var ] Racc_token_to_s_table = [ "$end", "error", + "TYPE", "OPEN", "CLOSE", "KEY", "VALUE", - "\"hostcomment\"", - "\"servicestatus\"", - "\"info\"", - "\"programstatus\"", - "\"hoststatus\"", - "\"contactstatus\"", - "\"servicecomment\"", "$start", "types", "type", - "type_names", "assignments", "assignment" ] Racc_debug_parser = false @@ -194,43 +168,29 @@ end .,., # reduce 4 omitted -# reduce 5 omitted - -# reduce 6 omitted - -# reduce 7 omitted - -# reduce 8 omitted - -# reduce 9 omitted - -# reduce 10 omitted - -# reduce 11 omitted - -module_eval(<<'.,.,', 'parser.y', 22) - def _reduce_12(val, _values, result) +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', 29) - def _reduce_13(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 25) + def _reduce_6(val, _values, result) result = {val[0] => nil} result end .,., -module_eval(<<'.,.,', 'parser.y', 30) - def _reduce_14(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 26) + def _reduce_7(val, _values, result) result = {val[0] => val[1]} result end .,.,