rison-rb 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/build.yml +30 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +82 -0
- data/Rakefile +16 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rison.rb +66 -0
- data/lib/rison/array/dumper.rb +18 -0
- data/lib/rison/array/parser.rb +610 -0
- data/lib/rison/array/parser.y +131 -0
- data/lib/rison/dumper.rb +34 -0
- data/lib/rison/object/dumper.rb +18 -0
- data/lib/rison/object/parser.rb +606 -0
- data/lib/rison/object/parser.y +131 -0
- data/lib/rison/parser.rb +596 -0
- data/lib/rison/parser.y +130 -0
- data/lib/rison/version.rb +3 -0
- data/rison-rb.gemspec +33 -0
- metadata +126 -0
@@ -0,0 +1,131 @@
|
|
1
|
+
class Rison::Array::Parser
|
2
|
+
rule
|
3
|
+
|
4
|
+
target: QUOTE QUOTE { result = [] }
|
5
|
+
| elements
|
6
|
+
|
7
|
+
object: LPAREN RPAREN { result = {} }
|
8
|
+
| LPAREN members RPAREN { result = val[1] }
|
9
|
+
|
10
|
+
members: pair
|
11
|
+
| pair COMMA members { result = val[0].merge(val[2]) }
|
12
|
+
|
13
|
+
pair: key COLON value { result = { val[0] => val[2] } }
|
14
|
+
|
15
|
+
array: EXCLAM LPAREN RPAREN { result = [] }
|
16
|
+
| EXCLAM LPAREN elements RPAREN { result = val[2] }
|
17
|
+
|
18
|
+
elements: value { result = [val[0]] }
|
19
|
+
| value COMMA elements { result = val[2].unshift(val[0]) }
|
20
|
+
|
21
|
+
key: id | string
|
22
|
+
|
23
|
+
value: id | string | number | object | array | bool | null
|
24
|
+
|
25
|
+
bool: EXCLAM T { result = true }
|
26
|
+
| EXCLAM F { result = false }
|
27
|
+
|
28
|
+
null: EXCLAM N { result = nil }
|
29
|
+
|
30
|
+
id: idstart
|
31
|
+
| idstart idchars { result = val[0] + val[1] }
|
32
|
+
|
33
|
+
idchars: idchar
|
34
|
+
| idchar idchars { result = val[0] + val[1] }
|
35
|
+
|
36
|
+
idchar: IDCHAR | idstart | MINUS | DIGIT
|
37
|
+
|
38
|
+
idstart: IDSTART | E | T | F | N | DOT
|
39
|
+
|
40
|
+
string: QUOTE QUOTE { result = '' }
|
41
|
+
| QUOTE strchars QUOTE { result = val[1] }
|
42
|
+
|
43
|
+
strchars: strchar
|
44
|
+
| strchar strchars { result = val[0] + val[1] }
|
45
|
+
|
46
|
+
strchar: STRCHAR
|
47
|
+
| idchar
|
48
|
+
| EXCLAM EXCLAM { result = '!' }
|
49
|
+
| EXCLAM QUOTE { result = "'" }
|
50
|
+
| COLON
|
51
|
+
| LPAREN
|
52
|
+
| RPAREN
|
53
|
+
| COMMA
|
54
|
+
|
55
|
+
number: int { result = val[0].to_i }
|
56
|
+
| int frac { result = "#{val[0]}#{val[1]}".to_f }
|
57
|
+
| int exp { result = "#{val[0]}#{val[1]}".to_f }
|
58
|
+
| int frac exp { result = "#{val[0]}#{val[1]}#{val[2]}".to_f }
|
59
|
+
|
60
|
+
int : DIGIT { result = val[0].to_i }
|
61
|
+
| DIGIT digits { result = "#{val[0]}#{val[1]}".to_i }
|
62
|
+
| MINUS DIGIT { result = "-#{val[1]}".to_i }
|
63
|
+
| MINUS DIGIT digits { result = "-#{val[1]}#{val[2]}".to_i }
|
64
|
+
|
65
|
+
frac: DOT digits { result = "#{val[0]}#{val[1]}" }
|
66
|
+
|
67
|
+
exp: e digits { result = "#{val[0]}#{val[1]}" }
|
68
|
+
|
69
|
+
digits: DIGIT
|
70
|
+
| DIGIT digits { result = "#{val[0]}#{val[1]}" }
|
71
|
+
|
72
|
+
e: E { result = 'e' }
|
73
|
+
| E MINUS { result = "e-" }
|
74
|
+
|
75
|
+
---- inner
|
76
|
+
|
77
|
+
attr_reader :source, :input
|
78
|
+
|
79
|
+
def initialize(source)
|
80
|
+
@source = source
|
81
|
+
@input = StringScanner.new(source)
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.parse(source)
|
85
|
+
self.new(source).do_parse
|
86
|
+
rescue Racc::ParseError => exn
|
87
|
+
raise ParserError.new("#{exn.message} in #{source}")
|
88
|
+
end
|
89
|
+
|
90
|
+
def next_token
|
91
|
+
case
|
92
|
+
when input.eos?
|
93
|
+
[false, false]
|
94
|
+
when input.scan(/'/)
|
95
|
+
[:QUOTE, input.matched]
|
96
|
+
when input.scan(/\(/)
|
97
|
+
[:LPAREN, input.matched]
|
98
|
+
when input.scan(/\)/)
|
99
|
+
[:RPAREN, input.matched]
|
100
|
+
when input.scan(/:/)
|
101
|
+
[:COLON, input.matched]
|
102
|
+
when input.scan(/\./)
|
103
|
+
[:DOT, input.matched]
|
104
|
+
when input.scan(/\,/)
|
105
|
+
[:COMMA, input.matched]
|
106
|
+
when input.scan(/!/)
|
107
|
+
[:EXCLAM, input.matched]
|
108
|
+
when input.scan(/\-/)
|
109
|
+
[:MINUS, input.matched]
|
110
|
+
when input.scan(/e/)
|
111
|
+
[:E, input.matched]
|
112
|
+
when input.scan(/t/)
|
113
|
+
[:T, input.matched]
|
114
|
+
when input.scan(/f/)
|
115
|
+
[:F, input.matched]
|
116
|
+
when input.scan(/n/)
|
117
|
+
[:N, input.matched]
|
118
|
+
# Originally, 0 is not allowed at the beginning of the number, but rison.js accepts this.
|
119
|
+
when input.scan(/[0-9]/)
|
120
|
+
[:DIGIT, input.matched]
|
121
|
+
# IDSTART and IDCHAR should originally accept only the ASCII symbols `-_./~`, but rison.js accepts other symbols.
|
122
|
+
# @see https://rison.io/
|
123
|
+
# @see https://github.com/Nanonid/rison/blob/e64af6c096fd30950ec32cfd48526ca6ee21649d/js/rison.js#L77-L84
|
124
|
+
when input.scan(/[^\-0-9 '!:\(\),\*@\$]/)
|
125
|
+
[:IDSTART, input.matched]
|
126
|
+
when input.scan(/[^ '!:\(\),\*@\$]/)
|
127
|
+
[:IDCHAR, input.matched]
|
128
|
+
when input.scan(/[^\'\!]/)
|
129
|
+
[:STRCHAR, input.matched]
|
130
|
+
end
|
131
|
+
end
|
data/lib/rison/dumper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Rison
|
2
|
+
class Dumper
|
3
|
+
class << self
|
4
|
+
def dump(object)
|
5
|
+
case object
|
6
|
+
when TrueClass
|
7
|
+
"!t"
|
8
|
+
when FalseClass
|
9
|
+
"!f"
|
10
|
+
when NilClass
|
11
|
+
"!n"
|
12
|
+
when Numeric
|
13
|
+
object.to_s.gsub('+', '')
|
14
|
+
when Hash
|
15
|
+
"(#{object.map { |k, v| dump(k) + ':' + dump(v) }.join(',')})"
|
16
|
+
when ::Array
|
17
|
+
"!(#{object.map { |e| dump(e) }.join(',')})"
|
18
|
+
else
|
19
|
+
escape(object.to_s)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def escape(str)
|
26
|
+
id?(str) ? str : "'#{str.gsub('!', '!!').gsub("'", "!'")}'"
|
27
|
+
end
|
28
|
+
|
29
|
+
def id?(str)
|
30
|
+
str.match?(/^[^\-0-9 '!:\(\),\*@¥\$][^ '!:\(\),\*@¥\$]*$/)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Rison
|
2
|
+
module Object
|
3
|
+
class Dumper < ::Rison::Dumper
|
4
|
+
class << self
|
5
|
+
def dump_object(object)
|
6
|
+
case object
|
7
|
+
when {}
|
8
|
+
%('')
|
9
|
+
when Hash
|
10
|
+
object.map { |k, v| dump(k) + ':' + dump(v) }.join(',')
|
11
|
+
else
|
12
|
+
raise DumperError.new("O-Rison only accepts Hash as the top level, but #{object.inspect} received.")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,606 @@
|
|
1
|
+
#
|
2
|
+
# DO NOT MODIFY!!!!
|
3
|
+
# This file is automatically generated by Racc 1.4.15
|
4
|
+
# from Racc grammer file "".
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'racc/parser.rb'
|
8
|
+
module Rison
|
9
|
+
module Object
|
10
|
+
class Parser < Racc::Parser
|
11
|
+
|
12
|
+
module_eval(<<'...end parser.y/module_eval...', 'parser.y', 76)
|
13
|
+
|
14
|
+
attr_reader :source, :input
|
15
|
+
|
16
|
+
def initialize(source)
|
17
|
+
@source = source
|
18
|
+
@input = StringScanner.new(source)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.parse(source)
|
22
|
+
self.new(source).do_parse
|
23
|
+
rescue Racc::ParseError => exn
|
24
|
+
raise ParserError.new("#{exn.message} in #{source}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def next_token
|
28
|
+
case
|
29
|
+
when input.eos?
|
30
|
+
[false, false]
|
31
|
+
when input.scan(/'/)
|
32
|
+
[:QUOTE, input.matched]
|
33
|
+
when input.scan(/\(/)
|
34
|
+
[:LPAREN, input.matched]
|
35
|
+
when input.scan(/\)/)
|
36
|
+
[:RPAREN, input.matched]
|
37
|
+
when input.scan(/:/)
|
38
|
+
[:COLON, input.matched]
|
39
|
+
when input.scan(/\./)
|
40
|
+
[:DOT, input.matched]
|
41
|
+
when input.scan(/\,/)
|
42
|
+
[:COMMA, input.matched]
|
43
|
+
when input.scan(/!/)
|
44
|
+
[:EXCLAM, input.matched]
|
45
|
+
when input.scan(/\-/)
|
46
|
+
[:MINUS, input.matched]
|
47
|
+
when input.scan(/e/)
|
48
|
+
[:E, input.matched]
|
49
|
+
when input.scan(/t/)
|
50
|
+
[:T, input.matched]
|
51
|
+
when input.scan(/f/)
|
52
|
+
[:F, input.matched]
|
53
|
+
when input.scan(/n/)
|
54
|
+
[:N, input.matched]
|
55
|
+
# Originally, 0 is not allowed at the beginning of the number, but rison.js accepts this.
|
56
|
+
when input.scan(/[0-9]/)
|
57
|
+
[:DIGIT, input.matched]
|
58
|
+
# IDSTART and IDCHAR should originally accept only the ASCII symbols `-_./~`, but rison.js accepts other symbols.
|
59
|
+
# @see https://rison.io/
|
60
|
+
# @see https://github.com/Nanonid/rison/blob/e64af6c096fd30950ec32cfd48526ca6ee21649d/js/rison.js#L77-L84
|
61
|
+
when input.scan(/[^\-0-9 '!:\(\),\*@\$]/)
|
62
|
+
[:IDSTART, input.matched]
|
63
|
+
when input.scan(/[^ '!:\(\),\*@\$]/)
|
64
|
+
[:IDCHAR, input.matched]
|
65
|
+
when input.scan(/[^\'\!]/)
|
66
|
+
[:STRCHAR, input.matched]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
...end parser.y/module_eval...
|
70
|
+
##### State transition tables begin ###
|
71
|
+
|
72
|
+
racc_action_table = [
|
73
|
+
16, 27, 28, 29, 26, 25, 11, 12, 13, 17,
|
74
|
+
19, 20, 9, 10, 14, 23, 55, 27, 28, 29,
|
75
|
+
26, 25, 11, 12, 13, 17, 19, 20, 9, 10,
|
76
|
+
14, 23, 40, 41, 66, 64, 38, 43, 11, 12,
|
77
|
+
13, 37, 53, 52, 9, 10, 14, 27, 28, 29,
|
78
|
+
26, 25, 11, 12, 13, 17, 19, 20, 9, 10,
|
79
|
+
14, 23, 40, 68, 69, 70, 81, 66, 11, 12,
|
80
|
+
13, 68, 40, 41, 9, 10, 14, 43, 11, 12,
|
81
|
+
13, 68, 53, 52, 9, 10, 14, 40, 30, 56,
|
82
|
+
31, 58, 34, 11, 12, 13, 59, 60, 61, 9,
|
83
|
+
10, 14, 40, 41, 71, -38, 77, 43, 11, 12,
|
84
|
+
13, 2, 53, 52, 9, 10, 14, 11, 12, 13,
|
85
|
+
35, 68, 68, 9, 10, 14, 11, 12, 13, 17,
|
86
|
+
19, 20, 9, 10, 14, 11, 12, 13, 17, 19,
|
87
|
+
20, 9, 10, 14, 15, 80 ]
|
88
|
+
|
89
|
+
racc_action_check = [
|
90
|
+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
91
|
+
2, 2, 2, 2, 2, 2, 40, 40, 40, 40,
|
92
|
+
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
|
93
|
+
40, 40, 81, 81, 51, 51, 25, 81, 81, 81,
|
94
|
+
81, 25, 81, 81, 81, 81, 81, 22, 22, 22,
|
95
|
+
22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
96
|
+
22, 22, 30, 52, 53, 57, 73, 62, 30, 30,
|
97
|
+
30, 64, 31, 31, 30, 30, 30, 31, 31, 31,
|
98
|
+
31, 65, 31, 31, 31, 31, 31, 41, 4, 41,
|
99
|
+
5, 43, 15, 41, 41, 41, 43, 43, 43, 41,
|
100
|
+
41, 41, 58, 58, 58, 16, 66, 58, 58, 58,
|
101
|
+
58, 0, 58, 58, 58, 58, 58, 0, 0, 0,
|
102
|
+
21, 68, 69, 0, 0, 0, 8, 8, 8, 8,
|
103
|
+
8, 8, 8, 8, 8, 33, 33, 33, 33, 33,
|
104
|
+
33, 33, 33, 33, 1, 72 ]
|
105
|
+
|
106
|
+
racc_action_pointer = [
|
107
|
+
109, 144, -2, nil, 83, 84, nil, nil, 118, nil,
|
108
|
+
nil, nil, nil, nil, nil, 92, 99, nil, nil, nil,
|
109
|
+
nil, 118, 44, nil, nil, 34, nil, nil, nil, nil,
|
110
|
+
60, 70, nil, 127, nil, nil, nil, nil, nil, nil,
|
111
|
+
14, 85, nil, 88, nil, nil, nil, nil, nil, nil,
|
112
|
+
nil, 19, 50, 51, nil, nil, nil, 61, 100, nil,
|
113
|
+
nil, nil, 52, nil, 58, 68, 94, nil, 108, 109,
|
114
|
+
nil, nil, 141, 61, nil, nil, nil, nil, nil, nil,
|
115
|
+
nil, 30, nil ]
|
116
|
+
|
117
|
+
racc_action_default = [
|
118
|
+
-64, -64, -64, -2, -5, -64, -12, -13, -24, -32,
|
119
|
+
-33, -34, -35, -36, -37, -64, -1, -28, -29, -30,
|
120
|
+
-31, -64, -40, -42, -43, -64, -46, -47, -48, -49,
|
121
|
+
-64, -64, -25, -26, 83, -39, -41, -44, -45, -6,
|
122
|
+
-64, -64, -7, -64, -14, -15, -16, -17, -18, -19,
|
123
|
+
-20, -50, -54, -64, -27, -38, -3, -64, -64, -21,
|
124
|
+
-22, -23, -51, -52, -64, -64, -62, -55, -60, -56,
|
125
|
+
-4, -8, -64, -10, -53, -58, -59, -63, -61, -57,
|
126
|
+
-9, -64, -11 ]
|
127
|
+
|
128
|
+
racc_goto_table = [
|
129
|
+
44, 45, 3, 18, 32, 33, 63, 42, 72, 18,
|
130
|
+
36, 62, 1, nil, nil, nil, nil, 74, nil, nil,
|
131
|
+
nil, nil, nil, 18, nil, nil, nil, 44, 45, 54,
|
132
|
+
33, 82, 39, nil, 18, nil, 67, nil, nil, nil,
|
133
|
+
nil, 18, nil, 57, nil, nil, nil, nil, 75, 76,
|
134
|
+
44, 45, 78, 79 ]
|
135
|
+
|
136
|
+
racc_goto_check = [
|
137
|
+
9, 10, 2, 14, 15, 16, 21, 6, 8, 14,
|
138
|
+
17, 20, 1, nil, nil, nil, nil, 21, nil, nil,
|
139
|
+
nil, nil, nil, 14, nil, nil, nil, 9, 10, 15,
|
140
|
+
16, 8, 2, nil, 14, nil, 22, nil, nil, nil,
|
141
|
+
nil, 14, nil, 2, nil, nil, nil, nil, 22, 22,
|
142
|
+
9, 10, 22, 22 ]
|
143
|
+
|
144
|
+
racc_goto_pointer = [
|
145
|
+
nil, 12, 2, nil, nil, nil, -24, nil, -50, -31,
|
146
|
+
-30, nil, nil, nil, 1, -4, -3, -12, nil, nil,
|
147
|
+
-40, -45, -16, nil ]
|
148
|
+
|
149
|
+
racc_goto_default = [
|
150
|
+
nil, nil, nil, 47, 4, 5, 73, 48, nil, 6,
|
151
|
+
7, 46, 49, 50, 8, nil, 24, 21, 22, 51,
|
152
|
+
nil, nil, nil, 65 ]
|
153
|
+
|
154
|
+
racc_reduce_table = [
|
155
|
+
0, 0, :racc_error,
|
156
|
+
2, 19, :_reduce_1,
|
157
|
+
1, 19, :_reduce_none,
|
158
|
+
2, 21, :_reduce_3,
|
159
|
+
3, 21, :_reduce_4,
|
160
|
+
1, 20, :_reduce_none,
|
161
|
+
3, 20, :_reduce_6,
|
162
|
+
3, 22, :_reduce_7,
|
163
|
+
3, 25, :_reduce_8,
|
164
|
+
4, 25, :_reduce_9,
|
165
|
+
1, 26, :_reduce_10,
|
166
|
+
3, 26, :_reduce_11,
|
167
|
+
1, 23, :_reduce_none,
|
168
|
+
1, 23, :_reduce_none,
|
169
|
+
1, 24, :_reduce_none,
|
170
|
+
1, 24, :_reduce_none,
|
171
|
+
1, 24, :_reduce_none,
|
172
|
+
1, 24, :_reduce_none,
|
173
|
+
1, 24, :_reduce_none,
|
174
|
+
1, 24, :_reduce_none,
|
175
|
+
1, 24, :_reduce_none,
|
176
|
+
2, 30, :_reduce_21,
|
177
|
+
2, 30, :_reduce_22,
|
178
|
+
2, 31, :_reduce_23,
|
179
|
+
1, 27, :_reduce_none,
|
180
|
+
2, 27, :_reduce_25,
|
181
|
+
1, 33, :_reduce_none,
|
182
|
+
2, 33, :_reduce_27,
|
183
|
+
1, 34, :_reduce_none,
|
184
|
+
1, 34, :_reduce_none,
|
185
|
+
1, 34, :_reduce_none,
|
186
|
+
1, 34, :_reduce_none,
|
187
|
+
1, 32, :_reduce_none,
|
188
|
+
1, 32, :_reduce_none,
|
189
|
+
1, 32, :_reduce_none,
|
190
|
+
1, 32, :_reduce_none,
|
191
|
+
1, 32, :_reduce_none,
|
192
|
+
1, 32, :_reduce_none,
|
193
|
+
2, 28, :_reduce_38,
|
194
|
+
3, 28, :_reduce_39,
|
195
|
+
1, 35, :_reduce_none,
|
196
|
+
2, 35, :_reduce_41,
|
197
|
+
1, 36, :_reduce_none,
|
198
|
+
1, 36, :_reduce_none,
|
199
|
+
2, 36, :_reduce_44,
|
200
|
+
2, 36, :_reduce_45,
|
201
|
+
1, 36, :_reduce_none,
|
202
|
+
1, 36, :_reduce_none,
|
203
|
+
1, 36, :_reduce_none,
|
204
|
+
1, 36, :_reduce_none,
|
205
|
+
1, 29, :_reduce_50,
|
206
|
+
2, 29, :_reduce_51,
|
207
|
+
2, 29, :_reduce_52,
|
208
|
+
3, 29, :_reduce_53,
|
209
|
+
1, 37, :_reduce_54,
|
210
|
+
2, 37, :_reduce_55,
|
211
|
+
2, 37, :_reduce_56,
|
212
|
+
3, 37, :_reduce_57,
|
213
|
+
2, 38, :_reduce_58,
|
214
|
+
2, 39, :_reduce_59,
|
215
|
+
1, 40, :_reduce_none,
|
216
|
+
2, 40, :_reduce_61,
|
217
|
+
1, 41, :_reduce_62,
|
218
|
+
2, 41, :_reduce_63 ]
|
219
|
+
|
220
|
+
racc_reduce_n = 64
|
221
|
+
|
222
|
+
racc_shift_n = 83
|
223
|
+
|
224
|
+
racc_token_table = {
|
225
|
+
false => 0,
|
226
|
+
:error => 1,
|
227
|
+
:QUOTE => 2,
|
228
|
+
:LPAREN => 3,
|
229
|
+
:RPAREN => 4,
|
230
|
+
:COMMA => 5,
|
231
|
+
:COLON => 6,
|
232
|
+
:EXCLAM => 7,
|
233
|
+
:T => 8,
|
234
|
+
:F => 9,
|
235
|
+
:N => 10,
|
236
|
+
:IDCHAR => 11,
|
237
|
+
:MINUS => 12,
|
238
|
+
:DIGIT => 13,
|
239
|
+
:IDSTART => 14,
|
240
|
+
:E => 15,
|
241
|
+
:DOT => 16,
|
242
|
+
:STRCHAR => 17 }
|
243
|
+
|
244
|
+
racc_nt_base = 18
|
245
|
+
|
246
|
+
racc_use_result_var = true
|
247
|
+
|
248
|
+
Racc_arg = [
|
249
|
+
racc_action_table,
|
250
|
+
racc_action_check,
|
251
|
+
racc_action_default,
|
252
|
+
racc_action_pointer,
|
253
|
+
racc_goto_table,
|
254
|
+
racc_goto_check,
|
255
|
+
racc_goto_default,
|
256
|
+
racc_goto_pointer,
|
257
|
+
racc_nt_base,
|
258
|
+
racc_reduce_table,
|
259
|
+
racc_token_table,
|
260
|
+
racc_shift_n,
|
261
|
+
racc_reduce_n,
|
262
|
+
racc_use_result_var ]
|
263
|
+
|
264
|
+
Racc_token_to_s_table = [
|
265
|
+
"$end",
|
266
|
+
"error",
|
267
|
+
"QUOTE",
|
268
|
+
"LPAREN",
|
269
|
+
"RPAREN",
|
270
|
+
"COMMA",
|
271
|
+
"COLON",
|
272
|
+
"EXCLAM",
|
273
|
+
"T",
|
274
|
+
"F",
|
275
|
+
"N",
|
276
|
+
"IDCHAR",
|
277
|
+
"MINUS",
|
278
|
+
"DIGIT",
|
279
|
+
"IDSTART",
|
280
|
+
"E",
|
281
|
+
"DOT",
|
282
|
+
"STRCHAR",
|
283
|
+
"$start",
|
284
|
+
"target",
|
285
|
+
"members",
|
286
|
+
"object",
|
287
|
+
"pair",
|
288
|
+
"key",
|
289
|
+
"value",
|
290
|
+
"array",
|
291
|
+
"elements",
|
292
|
+
"id",
|
293
|
+
"string",
|
294
|
+
"number",
|
295
|
+
"bool",
|
296
|
+
"null",
|
297
|
+
"idstart",
|
298
|
+
"idchars",
|
299
|
+
"idchar",
|
300
|
+
"strchars",
|
301
|
+
"strchar",
|
302
|
+
"int",
|
303
|
+
"frac",
|
304
|
+
"exp",
|
305
|
+
"digits",
|
306
|
+
"e" ]
|
307
|
+
|
308
|
+
Racc_debug_parser = false
|
309
|
+
|
310
|
+
##### State transition tables end #####
|
311
|
+
|
312
|
+
# reduce 0 omitted
|
313
|
+
|
314
|
+
module_eval(<<'.,.,', 'parser.y', 3)
|
315
|
+
def _reduce_1(val, _values, result)
|
316
|
+
result = {}
|
317
|
+
result
|
318
|
+
end
|
319
|
+
.,.,
|
320
|
+
|
321
|
+
# reduce 2 omitted
|
322
|
+
|
323
|
+
module_eval(<<'.,.,', 'parser.y', 6)
|
324
|
+
def _reduce_3(val, _values, result)
|
325
|
+
result = {}
|
326
|
+
result
|
327
|
+
end
|
328
|
+
.,.,
|
329
|
+
|
330
|
+
module_eval(<<'.,.,', 'parser.y', 7)
|
331
|
+
def _reduce_4(val, _values, result)
|
332
|
+
result = val[1]
|
333
|
+
result
|
334
|
+
end
|
335
|
+
.,.,
|
336
|
+
|
337
|
+
# reduce 5 omitted
|
338
|
+
|
339
|
+
module_eval(<<'.,.,', 'parser.y', 10)
|
340
|
+
def _reduce_6(val, _values, result)
|
341
|
+
result = val[0].merge(val[2])
|
342
|
+
result
|
343
|
+
end
|
344
|
+
.,.,
|
345
|
+
|
346
|
+
module_eval(<<'.,.,', 'parser.y', 12)
|
347
|
+
def _reduce_7(val, _values, result)
|
348
|
+
result = { val[0] => val[2] }
|
349
|
+
result
|
350
|
+
end
|
351
|
+
.,.,
|
352
|
+
|
353
|
+
module_eval(<<'.,.,', 'parser.y', 14)
|
354
|
+
def _reduce_8(val, _values, result)
|
355
|
+
result = []
|
356
|
+
result
|
357
|
+
end
|
358
|
+
.,.,
|
359
|
+
|
360
|
+
module_eval(<<'.,.,', 'parser.y', 15)
|
361
|
+
def _reduce_9(val, _values, result)
|
362
|
+
result = val[2]
|
363
|
+
result
|
364
|
+
end
|
365
|
+
.,.,
|
366
|
+
|
367
|
+
module_eval(<<'.,.,', 'parser.y', 17)
|
368
|
+
def _reduce_10(val, _values, result)
|
369
|
+
result = [val[0]]
|
370
|
+
result
|
371
|
+
end
|
372
|
+
.,.,
|
373
|
+
|
374
|
+
module_eval(<<'.,.,', 'parser.y', 18)
|
375
|
+
def _reduce_11(val, _values, result)
|
376
|
+
result = val[2].unshift(val[0])
|
377
|
+
result
|
378
|
+
end
|
379
|
+
.,.,
|
380
|
+
|
381
|
+
# reduce 12 omitted
|
382
|
+
|
383
|
+
# reduce 13 omitted
|
384
|
+
|
385
|
+
# reduce 14 omitted
|
386
|
+
|
387
|
+
# reduce 15 omitted
|
388
|
+
|
389
|
+
# reduce 16 omitted
|
390
|
+
|
391
|
+
# reduce 17 omitted
|
392
|
+
|
393
|
+
# reduce 18 omitted
|
394
|
+
|
395
|
+
# reduce 19 omitted
|
396
|
+
|
397
|
+
# reduce 20 omitted
|
398
|
+
|
399
|
+
module_eval(<<'.,.,', 'parser.y', 24)
|
400
|
+
def _reduce_21(val, _values, result)
|
401
|
+
result = true
|
402
|
+
result
|
403
|
+
end
|
404
|
+
.,.,
|
405
|
+
|
406
|
+
module_eval(<<'.,.,', 'parser.y', 25)
|
407
|
+
def _reduce_22(val, _values, result)
|
408
|
+
result = false
|
409
|
+
result
|
410
|
+
end
|
411
|
+
.,.,
|
412
|
+
|
413
|
+
module_eval(<<'.,.,', 'parser.y', 27)
|
414
|
+
def _reduce_23(val, _values, result)
|
415
|
+
result = nil
|
416
|
+
result
|
417
|
+
end
|
418
|
+
.,.,
|
419
|
+
|
420
|
+
# reduce 24 omitted
|
421
|
+
|
422
|
+
module_eval(<<'.,.,', 'parser.y', 30)
|
423
|
+
def _reduce_25(val, _values, result)
|
424
|
+
result = val[0] + val[1]
|
425
|
+
result
|
426
|
+
end
|
427
|
+
.,.,
|
428
|
+
|
429
|
+
# reduce 26 omitted
|
430
|
+
|
431
|
+
module_eval(<<'.,.,', 'parser.y', 33)
|
432
|
+
def _reduce_27(val, _values, result)
|
433
|
+
result = val[0] + val[1]
|
434
|
+
result
|
435
|
+
end
|
436
|
+
.,.,
|
437
|
+
|
438
|
+
# reduce 28 omitted
|
439
|
+
|
440
|
+
# reduce 29 omitted
|
441
|
+
|
442
|
+
# reduce 30 omitted
|
443
|
+
|
444
|
+
# reduce 31 omitted
|
445
|
+
|
446
|
+
# reduce 32 omitted
|
447
|
+
|
448
|
+
# reduce 33 omitted
|
449
|
+
|
450
|
+
# reduce 34 omitted
|
451
|
+
|
452
|
+
# reduce 35 omitted
|
453
|
+
|
454
|
+
# reduce 36 omitted
|
455
|
+
|
456
|
+
# reduce 37 omitted
|
457
|
+
|
458
|
+
module_eval(<<'.,.,', 'parser.y', 39)
|
459
|
+
def _reduce_38(val, _values, result)
|
460
|
+
result = ''
|
461
|
+
result
|
462
|
+
end
|
463
|
+
.,.,
|
464
|
+
|
465
|
+
module_eval(<<'.,.,', 'parser.y', 40)
|
466
|
+
def _reduce_39(val, _values, result)
|
467
|
+
result = val[1]
|
468
|
+
result
|
469
|
+
end
|
470
|
+
.,.,
|
471
|
+
|
472
|
+
# reduce 40 omitted
|
473
|
+
|
474
|
+
module_eval(<<'.,.,', 'parser.y', 43)
|
475
|
+
def _reduce_41(val, _values, result)
|
476
|
+
result = val[0] + val[1]
|
477
|
+
result
|
478
|
+
end
|
479
|
+
.,.,
|
480
|
+
|
481
|
+
# reduce 42 omitted
|
482
|
+
|
483
|
+
# reduce 43 omitted
|
484
|
+
|
485
|
+
module_eval(<<'.,.,', 'parser.y', 47)
|
486
|
+
def _reduce_44(val, _values, result)
|
487
|
+
result = '!'
|
488
|
+
result
|
489
|
+
end
|
490
|
+
.,.,
|
491
|
+
|
492
|
+
module_eval(<<'.,.,', 'parser.y', 48)
|
493
|
+
def _reduce_45(val, _values, result)
|
494
|
+
result = "'"
|
495
|
+
result
|
496
|
+
end
|
497
|
+
.,.,
|
498
|
+
|
499
|
+
# reduce 46 omitted
|
500
|
+
|
501
|
+
# reduce 47 omitted
|
502
|
+
|
503
|
+
# reduce 48 omitted
|
504
|
+
|
505
|
+
# reduce 49 omitted
|
506
|
+
|
507
|
+
module_eval(<<'.,.,', 'parser.y', 54)
|
508
|
+
def _reduce_50(val, _values, result)
|
509
|
+
result = val[0].to_i
|
510
|
+
result
|
511
|
+
end
|
512
|
+
.,.,
|
513
|
+
|
514
|
+
module_eval(<<'.,.,', 'parser.y', 55)
|
515
|
+
def _reduce_51(val, _values, result)
|
516
|
+
result = "#{val[0]}#{val[1]}".to_f
|
517
|
+
result
|
518
|
+
end
|
519
|
+
.,.,
|
520
|
+
|
521
|
+
module_eval(<<'.,.,', 'parser.y', 56)
|
522
|
+
def _reduce_52(val, _values, result)
|
523
|
+
result = "#{val[0]}#{val[1]}".to_f
|
524
|
+
result
|
525
|
+
end
|
526
|
+
.,.,
|
527
|
+
|
528
|
+
module_eval(<<'.,.,', 'parser.y', 57)
|
529
|
+
def _reduce_53(val, _values, result)
|
530
|
+
result = "#{val[0]}#{val[1]}#{val[2]}".to_f
|
531
|
+
result
|
532
|
+
end
|
533
|
+
.,.,
|
534
|
+
|
535
|
+
module_eval(<<'.,.,', 'parser.y', 59)
|
536
|
+
def _reduce_54(val, _values, result)
|
537
|
+
result = val[0].to_i
|
538
|
+
result
|
539
|
+
end
|
540
|
+
.,.,
|
541
|
+
|
542
|
+
module_eval(<<'.,.,', 'parser.y', 60)
|
543
|
+
def _reduce_55(val, _values, result)
|
544
|
+
result = "#{val[0]}#{val[1]}".to_i
|
545
|
+
result
|
546
|
+
end
|
547
|
+
.,.,
|
548
|
+
|
549
|
+
module_eval(<<'.,.,', 'parser.y', 61)
|
550
|
+
def _reduce_56(val, _values, result)
|
551
|
+
result = "-#{val[1]}".to_i
|
552
|
+
result
|
553
|
+
end
|
554
|
+
.,.,
|
555
|
+
|
556
|
+
module_eval(<<'.,.,', 'parser.y', 62)
|
557
|
+
def _reduce_57(val, _values, result)
|
558
|
+
result = "-#{val[1]}#{val[2]}".to_i
|
559
|
+
result
|
560
|
+
end
|
561
|
+
.,.,
|
562
|
+
|
563
|
+
module_eval(<<'.,.,', 'parser.y', 64)
|
564
|
+
def _reduce_58(val, _values, result)
|
565
|
+
result = "#{val[0]}#{val[1]}"
|
566
|
+
result
|
567
|
+
end
|
568
|
+
.,.,
|
569
|
+
|
570
|
+
module_eval(<<'.,.,', 'parser.y', 66)
|
571
|
+
def _reduce_59(val, _values, result)
|
572
|
+
result = "#{val[0]}#{val[1]}"
|
573
|
+
result
|
574
|
+
end
|
575
|
+
.,.,
|
576
|
+
|
577
|
+
# reduce 60 omitted
|
578
|
+
|
579
|
+
module_eval(<<'.,.,', 'parser.y', 69)
|
580
|
+
def _reduce_61(val, _values, result)
|
581
|
+
result = "#{val[0]}#{val[1]}"
|
582
|
+
result
|
583
|
+
end
|
584
|
+
.,.,
|
585
|
+
|
586
|
+
module_eval(<<'.,.,', 'parser.y', 71)
|
587
|
+
def _reduce_62(val, _values, result)
|
588
|
+
result = 'e'
|
589
|
+
result
|
590
|
+
end
|
591
|
+
.,.,
|
592
|
+
|
593
|
+
module_eval(<<'.,.,', 'parser.y', 72)
|
594
|
+
def _reduce_63(val, _values, result)
|
595
|
+
result = "e-"
|
596
|
+
result
|
597
|
+
end
|
598
|
+
.,.,
|
599
|
+
|
600
|
+
def _reduce_none(val, _values, result)
|
601
|
+
val[0]
|
602
|
+
end
|
603
|
+
|
604
|
+
end # class Parser
|
605
|
+
end # module Object
|
606
|
+
end # module Rison
|