# # DO NOT MODIFY!!!! # This file is automatically generated by Racc 1.4.11 # from Racc grammer file "". # require 'racc/parser.rb' module JsonColor class Parser < Racc::Parser module_eval(<<'...end parser.rb/module_eval...', 'parser.rb', 65) R_SPACE = /\A[ \t\n\r]+/ R_RESERVED = /\A[\{\}\[\],:]/ R_NUMBER = /\A-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?/ R_STRING = /\A"(?:\\["\\\/bfnrt]|\\u[\dA-Za-z]{4}|[^\\"])*"/ R_FALSE = /\Afalse/ R_NULL = /\Anull/ R_TRUE = /\Atrue/ def self.parse(src, color_map) self.new(src, color_map).parse end def initialize(src, color_map) @ss = StringScanner.new(src) @color_map = color_map end def scan tok = nil until @ss.eos? if (tok = @ss.scan R_SPACE) yield [:SPACE, tok] elsif (tok = @ss.scan R_RESERVED) yield [tok, tok] elsif (tok = @ss.scan R_NUMBER) yield [:NUMBER, tok] elsif (tok = @ss.scan R_STRING) yield [:STRING, tok] elsif (tok = @ss.scan R_FALSE) yield [:FALSE, tok] elsif (tok = @ss.scan R_NULL) yield [:NULL, tok] elsif (tok = @ss.scan R_TRUE) yield [:TRUE, tok] else raise Racc::ParseError, ('parse error on value "%s"' % @ss.rest.inspect) end end yield [false, '$'] end def parse yyparse self, :scan end def colorize(str, *types) types.each do |t| color = @color_map[t] if color return Term::ANSIColor.send(color, str) end end return str end ...end parser.rb/module_eval... ##### State transition tables begin ### racc_action_table = [ 6, 18, 19, 20, 23, 24, 7, 6, 6, 6, 8, 25, 6, 6, 6, 35, 9, 33, 34, 7, 3, 31, 32, 8, 6, 18, 19, 20, 23, 24, 7, nil, nil, nil, 8, 6, 18, 19, 20, 23, 24, 7, 6, 6, nil, 8, nil, 17, 17, 14 ] racc_action_check = [ 13, 13, 13, 13, 13, 13, 13, 30, 29, 10, 13, 13, 11, 2, 28, 30, 3, 29, 30, 2, 1, 28, 28, 2, 37, 37, 37, 37, 37, 37, 37, nil, nil, nil, 37, 38, 38, 38, 38, 38, 38, 38, 12, 36, nil, 38, nil, 12, 36, 12 ] racc_action_pointer = [ nil, 20, 11, 16, nil, nil, nil, nil, nil, nil, 7, 10, 40, -2, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 12, 6, 5, nil, nil, nil, nil, nil, 41, 22, 33, nil, nil, nil ] racc_action_default = [ -3, -21, -21, -21, -3, -3, -4, -3, -3, 42, -1, -2, -21, -21, -12, -3, -14, -3, -5, -6, -7, -8, -9, -10, -11, -17, -3, -19, -21, -21, -21, -13, -3, -3, -18, -3, -21, -21, -21, -15, -16, -20 ] racc_goto_table = [ 2, 16, 1, 27, 10, 11, 5, 12, 13, 15, 4, 26, nil, nil, nil, 28, nil, 29, nil, nil, nil, nil, nil, nil, nil, 39, 30, 40, 41, nil, nil, nil, 36, 37, nil, 38 ] racc_goto_check = [ 2, 7, 1, 5, 2, 2, 4, 2, 2, 6, 3, 8, nil, nil, nil, 2, nil, 2, nil, nil, nil, nil, nil, nil, nil, 7, 2, 5, 5, nil, nil, nil, 2, 2, nil, 2 ] racc_goto_pointer = [ nil, 2, 0, 8, 4, -10, -3, -11, -2 ] racc_goto_default = [ nil, nil, nil, 21, 22, nil, nil, nil, nil ] racc_reduce_table = [ 0, 0, :racc_error, 3, 15, :_reduce_1, 3, 15, :_reduce_2, 0, 16, :_reduce_3, 2, 16, :_reduce_4, 1, 19, :_reduce_5, 1, 19, :_reduce_6, 1, 19, :_reduce_7, 1, 19, :_reduce_8, 1, 19, :_reduce_9, 1, 19, :_reduce_10, 1, 19, :_reduce_11, 3, 17, :_reduce_12, 5, 17, :_reduce_13, 1, 20, :_reduce_14, 5, 20, :_reduce_15, 5, 21, :_reduce_16, 3, 18, :_reduce_17, 5, 18, :_reduce_18, 1, 22, :_reduce_19, 5, 22, :_reduce_20 ] racc_reduce_n = 21 racc_shift_n = 42 racc_token_table = { false => 0, :error => 1, :SPACE => 2, :FALSE => 3, :NULL => 4, :TRUE => 5, :NUMBER => 6, :STRING => 7, "{" => 8, "}" => 9, "," => 10, ":" => 11, "[" => 12, "]" => 13 } racc_nt_base = 14 racc_use_result_var = false 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", "SPACE", "FALSE", "NULL", "TRUE", "NUMBER", "STRING", "\"{\"", "\"}\"", "\",\"", "\":\"", "\"[\"", "\"]\"", "$start", "json_text", "ws", "object", "array", "value", "members", "member", "values" ] Racc_debug_parser = false ##### State transition tables end ##### # reduce 0 omitted module_eval(<<'.,.,', 'parser.rb', 4) def _reduce_1(val, _values) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 6) def _reduce_2(val, _values) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 9) def _reduce_3(val, _values) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 11) def _reduce_4(val, _values) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 14) def _reduce_5(val, _values) colorize(val[0], :false, :bool) end .,., module_eval(<<'.,.,', 'parser.rb', 16) def _reduce_6(val, _values) colorize(val[0], :null) end .,., module_eval(<<'.,.,', 'parser.rb', 18) def _reduce_7(val, _values) colorize(val[0], :true, :bool) end .,., module_eval(<<'.,.,', 'parser.rb', 20) def _reduce_8(val, _values) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 22) def _reduce_9(val, _values) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 24) def _reduce_10(val, _values) colorize(val[0], :number) end .,., module_eval(<<'.,.,', 'parser.rb', 26) def _reduce_11(val, _values) colorize(val[0], :string) end .,., module_eval(<<'.,.,', 'parser.rb', 29) def _reduce_12(val, _values) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 31) def _reduce_13(val, _values) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 34) def _reduce_14(val, _values) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 36) def _reduce_15(val, _values) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 40) def _reduce_16(val, _values) val[0] = colorize(val[0], :key, :string) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 45) def _reduce_17(val, _values) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 47) def _reduce_18(val, _values) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 50) def _reduce_19(val, _values) val.flatten.join end .,., module_eval(<<'.,.,', 'parser.rb', 52) def _reduce_20(val, _values) val.flatten.join end .,., def _reduce_none(val, _values) val[0] end end # class Parser end # JsonColor