mongo-ejson 0.2.2 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -2
- data/.travis.yml +5 -4
- data/Gemfile.lock +34 -31
- data/README.md +26 -36
- data/Rakefile +1 -1
- data/ejson.gemspec +1 -1
- data/lib/ejson/parser_action/abstract_json.rb +3 -0
- data/lib/ejson/parser_action/ruby.rb +18 -2
- data/lib/ejson/version.rb +1 -1
- data/src/ejson.peg +23 -4
- data/src/ejson.rb +449 -48
- data/vendor/assets/javascripts/ejson.js +450 -49
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18fbd9a2f37dcf781e2828d049eee0d87efa889c867cb4324b7b3f7ca358d800
|
4
|
+
data.tar.gz: 89a376582e61086039829140b3b5b48fba1f3694ce8055f31fe02f68159c83cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60f950727d2c04662de8bd02ab174d810c725d60b0578003b9634af3f05f6cae6cade532c1fc4f4f1fb63d63046f30f216490fb927cda8d293c5eb3a975f8b87
|
7
|
+
data.tar.gz: 02a1f4ef6949d5518681a2e958d3a7cbd4e445778e10c6f9ef4005ad3308d1550a5119b41fdcd2f414199b0222e0c005c95264db22f91831012154320986c823
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
|
3
3
|
AllCops:
|
4
|
+
NewCops: enable
|
4
5
|
Exclude:
|
5
6
|
- 'src/**/*'
|
6
7
|
- 'vendor/bundle/**/*'
|
@@ -27,8 +28,11 @@ Metrics/BlockLength:
|
|
27
28
|
- describe
|
28
29
|
|
29
30
|
Style/FrozenStringLiteralComment:
|
30
|
-
EnforcedStyle:
|
31
|
+
EnforcedStyle: never
|
31
32
|
|
32
|
-
|
33
|
+
Style/ExponentialNotation:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Layout/HashAlignment:
|
33
37
|
EnforcedHashRocketStyle: table
|
34
38
|
EnforcedColonStyle: table
|
data/.travis.yml
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
-
---
|
2
|
-
sudo: false
|
3
1
|
language: ruby
|
4
2
|
cache: bundler
|
3
|
+
|
4
|
+
os: linux
|
5
|
+
dist: xenial
|
6
|
+
|
5
7
|
rvm:
|
8
|
+
- 2.7
|
6
9
|
- 2.6
|
7
10
|
- 2.5
|
8
11
|
- jruby-9.2
|
9
|
-
|
10
12
|
before_install:
|
11
13
|
- gem install bundler -v 2.0.1
|
12
|
-
|
13
14
|
script:
|
14
15
|
- bundle exec rspec
|
15
16
|
- bundle exec rubocop
|
data/Gemfile.lock
CHANGED
@@ -1,45 +1,48 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mongo-ejson (0.2.
|
4
|
+
mongo-ejson (0.2.7)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.4.
|
10
|
-
bson (4.
|
11
|
-
bson (4.
|
12
|
-
diff-lcs (1.
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
ast (~> 2.4.0)
|
17
|
-
powerpack (0.1.2)
|
9
|
+
ast (2.4.1)
|
10
|
+
bson (4.9.2)
|
11
|
+
bson (4.9.2-java)
|
12
|
+
diff-lcs (1.4.2)
|
13
|
+
parallel (1.19.2)
|
14
|
+
parser (2.7.1.4)
|
15
|
+
ast (~> 2.4.1)
|
18
16
|
rainbow (3.0.0)
|
19
|
-
rake (
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
rspec-
|
24
|
-
|
25
|
-
rspec-
|
26
|
-
rspec-
|
17
|
+
rake (13.0.1)
|
18
|
+
regexp_parser (1.7.1)
|
19
|
+
rexml (3.2.4)
|
20
|
+
rspec (3.9.0)
|
21
|
+
rspec-core (~> 3.9.0)
|
22
|
+
rspec-expectations (~> 3.9.0)
|
23
|
+
rspec-mocks (~> 3.9.0)
|
24
|
+
rspec-core (3.9.2)
|
25
|
+
rspec-support (~> 3.9.3)
|
26
|
+
rspec-expectations (3.9.2)
|
27
27
|
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
-
rspec-support (~> 3.
|
29
|
-
rspec-mocks (3.
|
28
|
+
rspec-support (~> 3.9.0)
|
29
|
+
rspec-mocks (3.9.1)
|
30
30
|
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
-
rspec-support (~> 3.
|
32
|
-
rspec-support (3.
|
33
|
-
rubocop (0.
|
34
|
-
jaro_winkler (~> 1.5.1)
|
31
|
+
rspec-support (~> 3.9.0)
|
32
|
+
rspec-support (3.9.3)
|
33
|
+
rubocop (0.86.0)
|
35
34
|
parallel (~> 1.10)
|
36
|
-
parser (>= 2.
|
37
|
-
powerpack (~> 0.1)
|
35
|
+
parser (>= 2.7.0.1)
|
38
36
|
rainbow (>= 2.2.2, < 4.0)
|
37
|
+
regexp_parser (>= 1.7)
|
38
|
+
rexml
|
39
|
+
rubocop-ast (>= 0.0.3, < 1.0)
|
39
40
|
ruby-progressbar (~> 1.7)
|
40
|
-
unicode-display_width (
|
41
|
-
|
42
|
-
|
41
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
42
|
+
rubocop-ast (0.0.3)
|
43
|
+
parser (>= 2.7.0.1)
|
44
|
+
ruby-progressbar (1.10.1)
|
45
|
+
unicode-display_width (1.7.0)
|
43
46
|
|
44
47
|
PLATFORMS
|
45
48
|
java
|
@@ -49,9 +52,9 @@ DEPENDENCIES
|
|
49
52
|
bson
|
50
53
|
bundler (~> 2.0)
|
51
54
|
mongo-ejson!
|
52
|
-
rake (~>
|
55
|
+
rake (~> 13.0)
|
53
56
|
rspec (~> 3.0)
|
54
57
|
rubocop (~> 0.63)
|
55
58
|
|
56
59
|
BUNDLED WITH
|
57
|
-
2.
|
60
|
+
2.1.4
|
data/README.md
CHANGED
@@ -42,50 +42,40 @@ Just add it to your `application.js`
|
|
42
42
|
## Requirements
|
43
43
|
|
44
44
|
Runtime:
|
45
|
-
|
46
|
-
|
45
|
+
|
46
|
+
- Ruby 2.5+
|
47
|
+
- JRuby 9.2+
|
47
48
|
|
48
49
|
Development:
|
49
|
-
|
50
|
+
|
51
|
+
- [canopy](https://github.com/jcoglan/canopy) from master branch
|
50
52
|
|
51
53
|
## Supported literals
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
55
|
+
- `undefined`
|
56
|
+
- `MinKey`
|
57
|
+
- `MaxKey`
|
58
|
+
- `ObjectId(<object_id_hex_string>)`
|
59
|
+
- `BinData(<type_string>, <bindata_base64_string>)`
|
60
|
+
- `BinData(<type_integer>, <base64_bindata>)`
|
61
|
+
- `Timestamp(<time_interger>, <increment_integer>)`
|
62
|
+
- `NumberLong(<value_string>)`
|
63
|
+
- `NumberLong(<value_integer>)`
|
64
|
+
- `NumberDecimal(<value_string>)`
|
65
|
+
- `NumberDecimal(<value_number>)`
|
66
|
+
- `ISODate(<time_iso8601_string>)`
|
67
|
+
- `ISODate(<time_interger>)`
|
68
|
+
- `new Date(<time_iso8601_string>)`
|
69
|
+
- `new Date(<time_interger>)`
|
70
|
+
- `/<regexp>/<options>`
|
71
|
+
- `DBRef(<name_string>, <object_id_hex_string>)`
|
70
72
|
|
71
73
|
## Supported JSON extensions:
|
72
74
|
|
73
|
-
|
74
|
-
|
75
|
+
- Single quoted strings
|
76
|
+
- Single line comments `//`
|
77
|
+
- Non-quoted key names: `{_id: 123}`
|
75
78
|
|
76
79
|
## Planned JSON extensions:
|
77
80
|
|
78
|
-
|
79
|
-
* Multi-line comments: `/* */`
|
80
|
-
|
81
|
-
## Issues
|
82
|
-
|
83
|
-
* String: following not escaped chars should fail, but pass
|
84
|
-
|
85
|
-
* Backspace (must be replaced with `\b`). no fixture
|
86
|
-
* Form feed (must be replaced with `\f`), no fixture
|
87
|
-
* Newline (must be replaced with `\n`)
|
88
|
-
* Carriage return (must be replaced with `\r`), no fixture
|
89
|
-
* Tab (must be replaced with `\t`)
|
90
|
-
|
91
|
-
|
81
|
+
- Multi-line comments: `/* */`
|
data/Rakefile
CHANGED
data/ejson.gemspec
CHANGED
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.require_paths = ['lib']
|
40
40
|
|
41
41
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
42
|
-
spec.add_development_dependency 'rake', '~>
|
42
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
43
43
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
44
44
|
spec.add_development_dependency 'rubocop', '~> 0.63'
|
45
45
|
|
@@ -4,7 +4,7 @@ require 'date'
|
|
4
4
|
module ParserAction
|
5
5
|
class Ruby < ParserAction::Abstract
|
6
6
|
UNICODE_ESCAPER = proc { |s|
|
7
|
-
format('\u%
|
7
|
+
format('\u%04<char>X', char: s.codepoints[0])
|
8
8
|
}
|
9
9
|
|
10
10
|
def make_root(_input, _starts_at, _ends_at, elements)
|
@@ -37,6 +37,10 @@ module ParserAction
|
|
37
37
|
quoted_string.encode('ASCII', fallback: UNICODE_ESCAPER).undump
|
38
38
|
end
|
39
39
|
|
40
|
+
def make_identifier(input, starts_at, ends_at, _elements)
|
41
|
+
input[starts_at...ends_at]
|
42
|
+
end
|
43
|
+
|
40
44
|
def make_numeric_string(_input, _starts_at, _ends_at, elements)
|
41
45
|
elements.first
|
42
46
|
end
|
@@ -83,7 +87,7 @@ module ParserAction
|
|
83
87
|
|
84
88
|
case value
|
85
89
|
when String
|
86
|
-
|
90
|
+
_date_from_string(value)
|
87
91
|
when Numeric
|
88
92
|
Time.at(value)
|
89
93
|
else
|
@@ -111,5 +115,17 @@ module ParserAction
|
|
111
115
|
string.to_i
|
112
116
|
end
|
113
117
|
end
|
118
|
+
|
119
|
+
DateError = if defined? Date::Error
|
120
|
+
Date::Error
|
121
|
+
else
|
122
|
+
ArgumentError
|
123
|
+
end
|
124
|
+
|
125
|
+
def _date_from_string(string)
|
126
|
+
DateTime.parse(string)
|
127
|
+
rescue DateError
|
128
|
+
raise ExtendedJSON::ParseError, "Invalid date '#{string}'', expected ISO date"
|
129
|
+
end
|
114
130
|
end
|
115
131
|
end
|
data/lib/ejson/version.rb
CHANGED
data/src/ejson.peg
CHANGED
@@ -4,7 +4,7 @@ grammar ExtendedJSON
|
|
4
4
|
|
5
5
|
object <- (non_empty_object / empty_object)
|
6
6
|
|
7
|
-
pair <- @__ string @assignment value
|
7
|
+
pair <- @__ (string / identifier) @assignment value
|
8
8
|
%make_pair
|
9
9
|
|
10
10
|
non_empty_object <- @object_open
|
@@ -48,18 +48,35 @@ grammar ExtendedJSON
|
|
48
48
|
|
49
49
|
string <- double_quote_string / single_quote_string
|
50
50
|
|
51
|
+
identifier <- (identifier_start identifier_part*)
|
52
|
+
%make_identifier
|
53
|
+
|
54
|
+
identifier_start <- unicode_letter / "$" / "_" / "\\" unicode_escape
|
55
|
+
identifier_part <- unicode_letter / unicode_digit / unicode_conn_punct
|
56
|
+
|
57
|
+
# Not fully compatible with a https://www.ecma-international.org/ecma-262/5.1/#sec-7.6
|
58
|
+
# but enough to cover most failing cases
|
59
|
+
unicode_combining <- unicode_non_spacing / unicode_comb_spacing
|
60
|
+
|
61
|
+
unicode_escape <- "u" hex_digit hex_digit hex_digit hex_digit
|
62
|
+
|
63
|
+
unicode_letter <- [a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]
|
64
|
+
unicode_digit <- [0-9]
|
65
|
+
unicode_conn_punct <- [_\u203F\u2040\u2054\uFE33\uFE34\uFE4D-\uFE4F\uFF3F]
|
66
|
+
|
67
|
+
# https://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
|
51
68
|
double_quote_string <- @double_quote
|
52
|
-
("\\"
|
69
|
+
("\\" [^\b\t\n\v\f\r] / [^"\b\t\n\v\f\r])*
|
53
70
|
@double_quote
|
54
71
|
%make_string
|
55
72
|
|
56
73
|
single_quote_string <- @single_quote
|
57
|
-
("\\"
|
74
|
+
("\\" [^\b\t\n\v\f\r] / [^'\b\t\n\v\f\r])*
|
58
75
|
@single_quote
|
59
76
|
%make_string
|
60
77
|
|
61
78
|
hex_string <- hex_single_quote / hex_double_quote
|
62
|
-
hex_value <-
|
79
|
+
hex_value <- hex_digit+
|
63
80
|
|
64
81
|
hex_single_quote <- @single_quote
|
65
82
|
hex_value
|
@@ -209,6 +226,8 @@ grammar ExtendedJSON
|
|
209
226
|
space <- [\s]
|
210
227
|
new_line <- [\n]
|
211
228
|
|
229
|
+
hex_digit <- [a-fA-F0-9]
|
230
|
+
|
212
231
|
comment <- "//" [^\n]*
|
213
232
|
__ <- (space / new_line / comment)*
|
214
233
|
|
data/src/ejson.rb
CHANGED
@@ -18,11 +18,10 @@ module ExtendedJSON
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class TreeNode1 < TreeNode
|
21
|
-
attr_reader :
|
21
|
+
attr_reader :value
|
22
22
|
|
23
23
|
def initialize(text, offset, elements)
|
24
24
|
super
|
25
|
-
@string = elements[0]
|
26
25
|
@value = elements[1]
|
27
26
|
end
|
28
27
|
end
|
@@ -64,6 +63,33 @@ module ExtendedJSON
|
|
64
63
|
end
|
65
64
|
|
66
65
|
class TreeNode6 < TreeNode
|
66
|
+
attr_reader :identifier_start
|
67
|
+
|
68
|
+
def initialize(text, offset, elements)
|
69
|
+
super
|
70
|
+
@identifier_start = elements[0]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class TreeNode7 < TreeNode
|
75
|
+
attr_reader :unicode_escape
|
76
|
+
|
77
|
+
def initialize(text, offset, elements)
|
78
|
+
super
|
79
|
+
@unicode_escape = elements[1]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class TreeNode8 < TreeNode
|
84
|
+
attr_reader :hex_digit
|
85
|
+
|
86
|
+
def initialize(text, offset, elements)
|
87
|
+
super
|
88
|
+
@hex_digit = elements[4]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class TreeNode9 < TreeNode
|
67
93
|
attr_reader :hex_value
|
68
94
|
|
69
95
|
def initialize(text, offset, elements)
|
@@ -72,7 +98,7 @@ module ExtendedJSON
|
|
72
98
|
end
|
73
99
|
end
|
74
100
|
|
75
|
-
class
|
101
|
+
class TreeNode10 < TreeNode
|
76
102
|
attr_reader :hex_value
|
77
103
|
|
78
104
|
def initialize(text, offset, elements)
|
@@ -81,7 +107,7 @@ module ExtendedJSON
|
|
81
107
|
end
|
82
108
|
end
|
83
109
|
|
84
|
-
class
|
110
|
+
class TreeNode11 < TreeNode
|
85
111
|
attr_reader :integer_number
|
86
112
|
|
87
113
|
def initialize(text, offset, elements)
|
@@ -90,7 +116,7 @@ module ExtendedJSON
|
|
90
116
|
end
|
91
117
|
end
|
92
118
|
|
93
|
-
class
|
119
|
+
class TreeNode12 < TreeNode
|
94
120
|
attr_reader :integer_number
|
95
121
|
|
96
122
|
def initialize(text, offset, elements)
|
@@ -99,7 +125,7 @@ module ExtendedJSON
|
|
99
125
|
end
|
100
126
|
end
|
101
127
|
|
102
|
-
class
|
128
|
+
class TreeNode13 < TreeNode
|
103
129
|
attr_reader :number
|
104
130
|
|
105
131
|
def initialize(text, offset, elements)
|
@@ -108,7 +134,7 @@ module ExtendedJSON
|
|
108
134
|
end
|
109
135
|
end
|
110
136
|
|
111
|
-
class
|
137
|
+
class TreeNode14 < TreeNode
|
112
138
|
attr_reader :number
|
113
139
|
|
114
140
|
def initialize(text, offset, elements)
|
@@ -117,7 +143,7 @@ module ExtendedJSON
|
|
117
143
|
end
|
118
144
|
end
|
119
145
|
|
120
|
-
class
|
146
|
+
class TreeNode15 < TreeNode
|
121
147
|
attr_reader :base64_value
|
122
148
|
|
123
149
|
def initialize(text, offset, elements)
|
@@ -126,7 +152,7 @@ module ExtendedJSON
|
|
126
152
|
end
|
127
153
|
end
|
128
154
|
|
129
|
-
class
|
155
|
+
class TreeNode16 < TreeNode
|
130
156
|
attr_reader :base64_value
|
131
157
|
|
132
158
|
def initialize(text, offset, elements)
|
@@ -135,7 +161,7 @@ module ExtendedJSON
|
|
135
161
|
end
|
136
162
|
end
|
137
163
|
|
138
|
-
class
|
164
|
+
class TreeNode17 < TreeNode
|
139
165
|
attr_reader :integer
|
140
166
|
|
141
167
|
def initialize(text, offset, elements)
|
@@ -144,7 +170,7 @@ module ExtendedJSON
|
|
144
170
|
end
|
145
171
|
end
|
146
172
|
|
147
|
-
class
|
173
|
+
class TreeNode18 < TreeNode
|
148
174
|
attr_reader :integer
|
149
175
|
|
150
176
|
def initialize(text, offset, elements)
|
@@ -153,7 +179,7 @@ module ExtendedJSON
|
|
153
179
|
end
|
154
180
|
end
|
155
181
|
|
156
|
-
class
|
182
|
+
class TreeNode19 < TreeNode
|
157
183
|
attr_reader :integer
|
158
184
|
|
159
185
|
def initialize(text, offset, elements)
|
@@ -162,7 +188,7 @@ module ExtendedJSON
|
|
162
188
|
end
|
163
189
|
end
|
164
190
|
|
165
|
-
class
|
191
|
+
class TreeNode20 < TreeNode
|
166
192
|
attr_reader :hex_string
|
167
193
|
|
168
194
|
def initialize(text, offset, elements)
|
@@ -171,7 +197,7 @@ module ExtendedJSON
|
|
171
197
|
end
|
172
198
|
end
|
173
199
|
|
174
|
-
class
|
200
|
+
class TreeNode21 < TreeNode
|
175
201
|
attr_reader :bin_data_type, :base64_string
|
176
202
|
|
177
203
|
def initialize(text, offset, elements)
|
@@ -181,7 +207,7 @@ module ExtendedJSON
|
|
181
207
|
end
|
182
208
|
end
|
183
209
|
|
184
|
-
class
|
210
|
+
class TreeNode22 < TreeNode
|
185
211
|
attr_reader :integer_number
|
186
212
|
|
187
213
|
def initialize(text, offset, elements)
|
@@ -190,7 +216,7 @@ module ExtendedJSON
|
|
190
216
|
end
|
191
217
|
end
|
192
218
|
|
193
|
-
class
|
219
|
+
class TreeNode23 < TreeNode
|
194
220
|
attr_reader :number_long_value
|
195
221
|
|
196
222
|
def initialize(text, offset, elements)
|
@@ -199,7 +225,7 @@ module ExtendedJSON
|
|
199
225
|
end
|
200
226
|
end
|
201
227
|
|
202
|
-
class
|
228
|
+
class TreeNode24 < TreeNode
|
203
229
|
attr_reader :number_decimal_value
|
204
230
|
|
205
231
|
def initialize(text, offset, elements)
|
@@ -208,7 +234,7 @@ module ExtendedJSON
|
|
208
234
|
end
|
209
235
|
end
|
210
236
|
|
211
|
-
class
|
237
|
+
class TreeNode25 < TreeNode
|
212
238
|
attr_reader :date_value
|
213
239
|
|
214
240
|
def initialize(text, offset, elements)
|
@@ -217,7 +243,7 @@ module ExtendedJSON
|
|
217
243
|
end
|
218
244
|
end
|
219
245
|
|
220
|
-
class
|
246
|
+
class TreeNode26 < TreeNode
|
221
247
|
attr_reader :string
|
222
248
|
|
223
249
|
def initialize(text, offset, elements)
|
@@ -226,7 +252,7 @@ module ExtendedJSON
|
|
226
252
|
end
|
227
253
|
end
|
228
254
|
|
229
|
-
class
|
255
|
+
class TreeNode27 < TreeNode
|
230
256
|
attr_reader :comma
|
231
257
|
|
232
258
|
def initialize(text, offset, elements)
|
@@ -320,7 +346,15 @@ module ExtendedJSON
|
|
320
346
|
address1 = _read___
|
321
347
|
unless address1 == FAILURE
|
322
348
|
address2 = FAILURE
|
349
|
+
index2 = @offset
|
323
350
|
address2 = _read_string
|
351
|
+
if address2 == FAILURE
|
352
|
+
@offset = index2
|
353
|
+
address2 = _read_identifier
|
354
|
+
if address2 == FAILURE
|
355
|
+
@offset = index2
|
356
|
+
end
|
357
|
+
end
|
324
358
|
unless address2 == FAILURE
|
325
359
|
elements0 << address2
|
326
360
|
address3 = FAILURE
|
@@ -856,6 +890,353 @@ module ExtendedJSON
|
|
856
890
|
return address0
|
857
891
|
end
|
858
892
|
|
893
|
+
def _read_identifier
|
894
|
+
address0, index0 = FAILURE, @offset
|
895
|
+
cached = @cache[:identifier][index0]
|
896
|
+
if cached
|
897
|
+
@offset = cached[1]
|
898
|
+
return cached[0]
|
899
|
+
end
|
900
|
+
index1, elements0 = @offset, []
|
901
|
+
address1 = FAILURE
|
902
|
+
address1 = _read_identifier_start
|
903
|
+
unless address1 == FAILURE
|
904
|
+
elements0 << address1
|
905
|
+
address2 = FAILURE
|
906
|
+
remaining0, index2, elements1, address3 = 0, @offset, [], true
|
907
|
+
until address3 == FAILURE
|
908
|
+
address3 = _read_identifier_part
|
909
|
+
unless address3 == FAILURE
|
910
|
+
elements1 << address3
|
911
|
+
remaining0 -= 1
|
912
|
+
end
|
913
|
+
end
|
914
|
+
if remaining0 <= 0
|
915
|
+
address2 = TreeNode.new(@input[index2...@offset], index2, elements1)
|
916
|
+
@offset = @offset
|
917
|
+
else
|
918
|
+
address2 = FAILURE
|
919
|
+
end
|
920
|
+
unless address2 == FAILURE
|
921
|
+
elements0 << address2
|
922
|
+
else
|
923
|
+
elements0 = nil
|
924
|
+
@offset = index1
|
925
|
+
end
|
926
|
+
else
|
927
|
+
elements0 = nil
|
928
|
+
@offset = index1
|
929
|
+
end
|
930
|
+
if elements0.nil?
|
931
|
+
address0 = FAILURE
|
932
|
+
else
|
933
|
+
address0 = @actions.make_identifier(@input, index1, @offset, elements0)
|
934
|
+
@offset = @offset
|
935
|
+
end
|
936
|
+
@cache[:identifier][index0] = [address0, @offset]
|
937
|
+
return address0
|
938
|
+
end
|
939
|
+
|
940
|
+
def _read_identifier_start
|
941
|
+
address0, index0 = FAILURE, @offset
|
942
|
+
cached = @cache[:identifier_start][index0]
|
943
|
+
if cached
|
944
|
+
@offset = cached[1]
|
945
|
+
return cached[0]
|
946
|
+
end
|
947
|
+
index1 = @offset
|
948
|
+
address0 = _read_unicode_letter
|
949
|
+
if address0 == FAILURE
|
950
|
+
@offset = index1
|
951
|
+
chunk0 = nil
|
952
|
+
if @offset < @input_size
|
953
|
+
chunk0 = @input[@offset...@offset + 1]
|
954
|
+
end
|
955
|
+
if chunk0 == "$"
|
956
|
+
address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
|
957
|
+
@offset = @offset + 1
|
958
|
+
else
|
959
|
+
address0 = FAILURE
|
960
|
+
if @offset > @failure
|
961
|
+
@failure = @offset
|
962
|
+
@expected = []
|
963
|
+
end
|
964
|
+
if @offset == @failure
|
965
|
+
@expected << "\"$\""
|
966
|
+
end
|
967
|
+
end
|
968
|
+
if address0 == FAILURE
|
969
|
+
@offset = index1
|
970
|
+
chunk1 = nil
|
971
|
+
if @offset < @input_size
|
972
|
+
chunk1 = @input[@offset...@offset + 1]
|
973
|
+
end
|
974
|
+
if chunk1 == "_"
|
975
|
+
address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
|
976
|
+
@offset = @offset + 1
|
977
|
+
else
|
978
|
+
address0 = FAILURE
|
979
|
+
if @offset > @failure
|
980
|
+
@failure = @offset
|
981
|
+
@expected = []
|
982
|
+
end
|
983
|
+
if @offset == @failure
|
984
|
+
@expected << "\"_\""
|
985
|
+
end
|
986
|
+
end
|
987
|
+
if address0 == FAILURE
|
988
|
+
@offset = index1
|
989
|
+
index2, elements0 = @offset, []
|
990
|
+
address1 = FAILURE
|
991
|
+
chunk2 = nil
|
992
|
+
if @offset < @input_size
|
993
|
+
chunk2 = @input[@offset...@offset + 1]
|
994
|
+
end
|
995
|
+
if chunk2 == "\\"
|
996
|
+
address1 = TreeNode.new(@input[@offset...@offset + 1], @offset)
|
997
|
+
@offset = @offset + 1
|
998
|
+
else
|
999
|
+
address1 = FAILURE
|
1000
|
+
if @offset > @failure
|
1001
|
+
@failure = @offset
|
1002
|
+
@expected = []
|
1003
|
+
end
|
1004
|
+
if @offset == @failure
|
1005
|
+
@expected << "\"\\\\\""
|
1006
|
+
end
|
1007
|
+
end
|
1008
|
+
unless address1 == FAILURE
|
1009
|
+
elements0 << address1
|
1010
|
+
address2 = FAILURE
|
1011
|
+
address2 = _read_unicode_escape
|
1012
|
+
unless address2 == FAILURE
|
1013
|
+
elements0 << address2
|
1014
|
+
else
|
1015
|
+
elements0 = nil
|
1016
|
+
@offset = index2
|
1017
|
+
end
|
1018
|
+
else
|
1019
|
+
elements0 = nil
|
1020
|
+
@offset = index2
|
1021
|
+
end
|
1022
|
+
if elements0.nil?
|
1023
|
+
address0 = FAILURE
|
1024
|
+
else
|
1025
|
+
address0 = TreeNode7.new(@input[index2...@offset], index2, elements0)
|
1026
|
+
@offset = @offset
|
1027
|
+
end
|
1028
|
+
if address0 == FAILURE
|
1029
|
+
@offset = index1
|
1030
|
+
end
|
1031
|
+
end
|
1032
|
+
end
|
1033
|
+
end
|
1034
|
+
@cache[:identifier_start][index0] = [address0, @offset]
|
1035
|
+
return address0
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
def _read_identifier_part
|
1039
|
+
address0, index0 = FAILURE, @offset
|
1040
|
+
cached = @cache[:identifier_part][index0]
|
1041
|
+
if cached
|
1042
|
+
@offset = cached[1]
|
1043
|
+
return cached[0]
|
1044
|
+
end
|
1045
|
+
index1 = @offset
|
1046
|
+
address0 = _read_unicode_letter
|
1047
|
+
if address0 == FAILURE
|
1048
|
+
@offset = index1
|
1049
|
+
address0 = _read_unicode_digit
|
1050
|
+
if address0 == FAILURE
|
1051
|
+
@offset = index1
|
1052
|
+
address0 = _read_unicode_conn_punct
|
1053
|
+
if address0 == FAILURE
|
1054
|
+
@offset = index1
|
1055
|
+
end
|
1056
|
+
end
|
1057
|
+
end
|
1058
|
+
@cache[:identifier_part][index0] = [address0, @offset]
|
1059
|
+
return address0
|
1060
|
+
end
|
1061
|
+
|
1062
|
+
def _read_unicode_combining
|
1063
|
+
address0, index0 = FAILURE, @offset
|
1064
|
+
cached = @cache[:unicode_combining][index0]
|
1065
|
+
if cached
|
1066
|
+
@offset = cached[1]
|
1067
|
+
return cached[0]
|
1068
|
+
end
|
1069
|
+
index1 = @offset
|
1070
|
+
address0 = _read_unicode_non_spacing
|
1071
|
+
if address0 == FAILURE
|
1072
|
+
@offset = index1
|
1073
|
+
address0 = _read_unicode_comb_spacing
|
1074
|
+
if address0 == FAILURE
|
1075
|
+
@offset = index1
|
1076
|
+
end
|
1077
|
+
end
|
1078
|
+
@cache[:unicode_combining][index0] = [address0, @offset]
|
1079
|
+
return address0
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
def _read_unicode_escape
|
1083
|
+
address0, index0 = FAILURE, @offset
|
1084
|
+
cached = @cache[:unicode_escape][index0]
|
1085
|
+
if cached
|
1086
|
+
@offset = cached[1]
|
1087
|
+
return cached[0]
|
1088
|
+
end
|
1089
|
+
index1, elements0 = @offset, []
|
1090
|
+
address1 = FAILURE
|
1091
|
+
chunk0 = nil
|
1092
|
+
if @offset < @input_size
|
1093
|
+
chunk0 = @input[@offset...@offset + 1]
|
1094
|
+
end
|
1095
|
+
if chunk0 == "u"
|
1096
|
+
address1 = TreeNode.new(@input[@offset...@offset + 1], @offset)
|
1097
|
+
@offset = @offset + 1
|
1098
|
+
else
|
1099
|
+
address1 = FAILURE
|
1100
|
+
if @offset > @failure
|
1101
|
+
@failure = @offset
|
1102
|
+
@expected = []
|
1103
|
+
end
|
1104
|
+
if @offset == @failure
|
1105
|
+
@expected << "\"u\""
|
1106
|
+
end
|
1107
|
+
end
|
1108
|
+
unless address1 == FAILURE
|
1109
|
+
elements0 << address1
|
1110
|
+
address2 = FAILURE
|
1111
|
+
address2 = _read_hex_digit
|
1112
|
+
unless address2 == FAILURE
|
1113
|
+
elements0 << address2
|
1114
|
+
address3 = FAILURE
|
1115
|
+
address3 = _read_hex_digit
|
1116
|
+
unless address3 == FAILURE
|
1117
|
+
elements0 << address3
|
1118
|
+
address4 = FAILURE
|
1119
|
+
address4 = _read_hex_digit
|
1120
|
+
unless address4 == FAILURE
|
1121
|
+
elements0 << address4
|
1122
|
+
address5 = FAILURE
|
1123
|
+
address5 = _read_hex_digit
|
1124
|
+
unless address5 == FAILURE
|
1125
|
+
elements0 << address5
|
1126
|
+
else
|
1127
|
+
elements0 = nil
|
1128
|
+
@offset = index1
|
1129
|
+
end
|
1130
|
+
else
|
1131
|
+
elements0 = nil
|
1132
|
+
@offset = index1
|
1133
|
+
end
|
1134
|
+
else
|
1135
|
+
elements0 = nil
|
1136
|
+
@offset = index1
|
1137
|
+
end
|
1138
|
+
else
|
1139
|
+
elements0 = nil
|
1140
|
+
@offset = index1
|
1141
|
+
end
|
1142
|
+
else
|
1143
|
+
elements0 = nil
|
1144
|
+
@offset = index1
|
1145
|
+
end
|
1146
|
+
if elements0.nil?
|
1147
|
+
address0 = FAILURE
|
1148
|
+
else
|
1149
|
+
address0 = TreeNode8.new(@input[index1...@offset], index1, elements0)
|
1150
|
+
@offset = @offset
|
1151
|
+
end
|
1152
|
+
@cache[:unicode_escape][index0] = [address0, @offset]
|
1153
|
+
return address0
|
1154
|
+
end
|
1155
|
+
|
1156
|
+
def _read_unicode_letter
|
1157
|
+
address0, index0 = FAILURE, @offset
|
1158
|
+
cached = @cache[:unicode_letter][index0]
|
1159
|
+
if cached
|
1160
|
+
@offset = cached[1]
|
1161
|
+
return cached[0]
|
1162
|
+
end
|
1163
|
+
chunk0 = nil
|
1164
|
+
if @offset < @input_size
|
1165
|
+
chunk0 = @input[@offset...@offset + 1]
|
1166
|
+
end
|
1167
|
+
if chunk0 =~ /\A[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]/
|
1168
|
+
address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
|
1169
|
+
@offset = @offset + 1
|
1170
|
+
else
|
1171
|
+
address0 = FAILURE
|
1172
|
+
if @offset > @failure
|
1173
|
+
@failure = @offset
|
1174
|
+
@expected = []
|
1175
|
+
end
|
1176
|
+
if @offset == @failure
|
1177
|
+
@expected << "[a-zA-Z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]"
|
1178
|
+
end
|
1179
|
+
end
|
1180
|
+
@cache[:unicode_letter][index0] = [address0, @offset]
|
1181
|
+
return address0
|
1182
|
+
end
|
1183
|
+
|
1184
|
+
def _read_unicode_digit
|
1185
|
+
address0, index0 = FAILURE, @offset
|
1186
|
+
cached = @cache[:unicode_digit][index0]
|
1187
|
+
if cached
|
1188
|
+
@offset = cached[1]
|
1189
|
+
return cached[0]
|
1190
|
+
end
|
1191
|
+
chunk0 = nil
|
1192
|
+
if @offset < @input_size
|
1193
|
+
chunk0 = @input[@offset...@offset + 1]
|
1194
|
+
end
|
1195
|
+
if chunk0 =~ /\A[0-9]/
|
1196
|
+
address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
|
1197
|
+
@offset = @offset + 1
|
1198
|
+
else
|
1199
|
+
address0 = FAILURE
|
1200
|
+
if @offset > @failure
|
1201
|
+
@failure = @offset
|
1202
|
+
@expected = []
|
1203
|
+
end
|
1204
|
+
if @offset == @failure
|
1205
|
+
@expected << "[0-9]"
|
1206
|
+
end
|
1207
|
+
end
|
1208
|
+
@cache[:unicode_digit][index0] = [address0, @offset]
|
1209
|
+
return address0
|
1210
|
+
end
|
1211
|
+
|
1212
|
+
def _read_unicode_conn_punct
|
1213
|
+
address0, index0 = FAILURE, @offset
|
1214
|
+
cached = @cache[:unicode_conn_punct][index0]
|
1215
|
+
if cached
|
1216
|
+
@offset = cached[1]
|
1217
|
+
return cached[0]
|
1218
|
+
end
|
1219
|
+
chunk0 = nil
|
1220
|
+
if @offset < @input_size
|
1221
|
+
chunk0 = @input[@offset...@offset + 1]
|
1222
|
+
end
|
1223
|
+
if chunk0 =~ /\A[_\u203F\u2040\u2054\uFE33\uFE34\uFE4D-\uFE4F\uFF3F]/
|
1224
|
+
address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
|
1225
|
+
@offset = @offset + 1
|
1226
|
+
else
|
1227
|
+
address0 = FAILURE
|
1228
|
+
if @offset > @failure
|
1229
|
+
@failure = @offset
|
1230
|
+
@expected = []
|
1231
|
+
end
|
1232
|
+
if @offset == @failure
|
1233
|
+
@expected << "[_\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]"
|
1234
|
+
end
|
1235
|
+
end
|
1236
|
+
@cache[:unicode_conn_punct][index0] = [address0, @offset]
|
1237
|
+
return address0
|
1238
|
+
end
|
1239
|
+
|
859
1240
|
def _read_double_quote_string
|
860
1241
|
address0, index0 = FAILURE, @offset
|
861
1242
|
cached = @cache[:double_quote_string][index0]
|
@@ -893,7 +1274,11 @@ module ExtendedJSON
|
|
893
1274
|
unless address4 == FAILURE
|
894
1275
|
elements2 << address4
|
895
1276
|
address5 = FAILURE
|
1277
|
+
chunk1 = nil
|
896
1278
|
if @offset < @input_size
|
1279
|
+
chunk1 = @input[@offset...@offset + 1]
|
1280
|
+
end
|
1281
|
+
if chunk1 =~ /\A[^\b\t\n\v\f\r]/
|
897
1282
|
address5 = TreeNode.new(@input[@offset...@offset + 1], @offset)
|
898
1283
|
@offset = @offset + 1
|
899
1284
|
else
|
@@ -903,7 +1288,7 @@ module ExtendedJSON
|
|
903
1288
|
@expected = []
|
904
1289
|
end
|
905
1290
|
if @offset == @failure
|
906
|
-
@expected << "
|
1291
|
+
@expected << "[^\\b\\t\\n\\v\\f\\r]"
|
907
1292
|
end
|
908
1293
|
end
|
909
1294
|
unless address5 == FAILURE
|
@@ -924,11 +1309,11 @@ module ExtendedJSON
|
|
924
1309
|
end
|
925
1310
|
if address3 == FAILURE
|
926
1311
|
@offset = index3
|
927
|
-
|
1312
|
+
chunk2 = nil
|
928
1313
|
if @offset < @input_size
|
929
|
-
|
1314
|
+
chunk2 = @input[@offset...@offset + 1]
|
930
1315
|
end
|
931
|
-
if
|
1316
|
+
if chunk2 =~ /\A[^"\b\t\n\v\f\r]/
|
932
1317
|
address3 = TreeNode.new(@input[@offset...@offset + 1], @offset)
|
933
1318
|
@offset = @offset + 1
|
934
1319
|
else
|
@@ -938,7 +1323,7 @@ module ExtendedJSON
|
|
938
1323
|
@expected = []
|
939
1324
|
end
|
940
1325
|
if @offset == @failure
|
941
|
-
@expected << "[^\"]"
|
1326
|
+
@expected << "[^\"\\b\\t\\n\\v\\f\\r]"
|
942
1327
|
end
|
943
1328
|
end
|
944
1329
|
if address3 == FAILURE
|
@@ -1020,7 +1405,11 @@ module ExtendedJSON
|
|
1020
1405
|
unless address4 == FAILURE
|
1021
1406
|
elements2 << address4
|
1022
1407
|
address5 = FAILURE
|
1408
|
+
chunk1 = nil
|
1023
1409
|
if @offset < @input_size
|
1410
|
+
chunk1 = @input[@offset...@offset + 1]
|
1411
|
+
end
|
1412
|
+
if chunk1 =~ /\A[^\b\t\n\v\f\r]/
|
1024
1413
|
address5 = TreeNode.new(@input[@offset...@offset + 1], @offset)
|
1025
1414
|
@offset = @offset + 1
|
1026
1415
|
else
|
@@ -1030,7 +1419,7 @@ module ExtendedJSON
|
|
1030
1419
|
@expected = []
|
1031
1420
|
end
|
1032
1421
|
if @offset == @failure
|
1033
|
-
@expected << "
|
1422
|
+
@expected << "[^\\b\\t\\n\\v\\f\\r]"
|
1034
1423
|
end
|
1035
1424
|
end
|
1036
1425
|
unless address5 == FAILURE
|
@@ -1051,11 +1440,11 @@ module ExtendedJSON
|
|
1051
1440
|
end
|
1052
1441
|
if address3 == FAILURE
|
1053
1442
|
@offset = index3
|
1054
|
-
|
1443
|
+
chunk2 = nil
|
1055
1444
|
if @offset < @input_size
|
1056
|
-
|
1445
|
+
chunk2 = @input[@offset...@offset + 1]
|
1057
1446
|
end
|
1058
|
-
if
|
1447
|
+
if chunk2 =~ /\A[^'\b\t\n\v\f\r]/
|
1059
1448
|
address3 = TreeNode.new(@input[@offset...@offset + 1], @offset)
|
1060
1449
|
@offset = @offset + 1
|
1061
1450
|
else
|
@@ -1065,7 +1454,7 @@ module ExtendedJSON
|
|
1065
1454
|
@expected = []
|
1066
1455
|
end
|
1067
1456
|
if @offset == @failure
|
1068
|
-
@expected << "[^']"
|
1457
|
+
@expected << "[^'\\b\\t\\n\\v\\f\\r]"
|
1069
1458
|
end
|
1070
1459
|
end
|
1071
1460
|
if address3 == FAILURE
|
@@ -1139,23 +1528,7 @@ module ExtendedJSON
|
|
1139
1528
|
end
|
1140
1529
|
remaining0, index1, elements0, address1 = 1, @offset, [], true
|
1141
1530
|
until address1 == FAILURE
|
1142
|
-
|
1143
|
-
if @offset < @input_size
|
1144
|
-
chunk0 = @input[@offset...@offset + 1]
|
1145
|
-
end
|
1146
|
-
if chunk0 =~ /\A[a-fA-F0-9]/
|
1147
|
-
address1 = TreeNode.new(@input[@offset...@offset + 1], @offset)
|
1148
|
-
@offset = @offset + 1
|
1149
|
-
else
|
1150
|
-
address1 = FAILURE
|
1151
|
-
if @offset > @failure
|
1152
|
-
@failure = @offset
|
1153
|
-
@expected = []
|
1154
|
-
end
|
1155
|
-
if @offset == @failure
|
1156
|
-
@expected << "[a-fA-F0-9]"
|
1157
|
-
end
|
1158
|
-
end
|
1531
|
+
address1 = _read_hex_digit
|
1159
1532
|
unless address1 == FAILURE
|
1160
1533
|
elements0 << address1
|
1161
1534
|
remaining0 -= 1
|
@@ -3513,6 +3886,34 @@ module ExtendedJSON
|
|
3513
3886
|
return address0
|
3514
3887
|
end
|
3515
3888
|
|
3889
|
+
def _read_hex_digit
|
3890
|
+
address0, index0 = FAILURE, @offset
|
3891
|
+
cached = @cache[:hex_digit][index0]
|
3892
|
+
if cached
|
3893
|
+
@offset = cached[1]
|
3894
|
+
return cached[0]
|
3895
|
+
end
|
3896
|
+
chunk0 = nil
|
3897
|
+
if @offset < @input_size
|
3898
|
+
chunk0 = @input[@offset...@offset + 1]
|
3899
|
+
end
|
3900
|
+
if chunk0 =~ /\A[a-fA-F0-9]/
|
3901
|
+
address0 = TreeNode.new(@input[@offset...@offset + 1], @offset)
|
3902
|
+
@offset = @offset + 1
|
3903
|
+
else
|
3904
|
+
address0 = FAILURE
|
3905
|
+
if @offset > @failure
|
3906
|
+
@failure = @offset
|
3907
|
+
@expected = []
|
3908
|
+
end
|
3909
|
+
if @offset == @failure
|
3910
|
+
@expected << "[a-fA-F0-9]"
|
3911
|
+
end
|
3912
|
+
end
|
3913
|
+
@cache[:hex_digit][index0] = [address0, @offset]
|
3914
|
+
return address0
|
3915
|
+
end
|
3916
|
+
|
3516
3917
|
def _read_comment
|
3517
3918
|
address0, index0 = FAILURE, @offset
|
3518
3919
|
cached = @cache[:comment][index0]
|
@@ -3662,7 +4063,7 @@ module ExtendedJSON
|
|
3662
4063
|
if elements0.nil?
|
3663
4064
|
address0 = FAILURE
|
3664
4065
|
else
|
3665
|
-
address0 =
|
4066
|
+
address0 = TreeNode27.new(@input[index1...@offset], index1, elements0)
|
3666
4067
|
@offset = @offset
|
3667
4068
|
end
|
3668
4069
|
@cache[:delimiter][index0] = [address0, @offset]
|