json 1.8.6 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +11 -5
- data/{CHANGES → CHANGES.md} +179 -95
- data/Gemfile +10 -3
- data/LICENSE +56 -0
- data/{README-json-jruby.markdown → README-json-jruby.md} +0 -0
- data/README.md +171 -107
- data/Rakefile +33 -22
- data/VERSION +1 -1
- data/ext/json/ext/fbuffer/fbuffer.h +0 -3
- data/ext/json/ext/generator/generator.c +105 -98
- data/ext/json/ext/generator/generator.h +0 -6
- data/ext/json/ext/parser/extconf.rb +3 -0
- data/ext/json/ext/parser/parser.c +376 -480
- data/ext/json/ext/parser/parser.h +4 -5
- data/ext/json/ext/parser/parser.rl +108 -175
- data/ext/json/extconf.rb +0 -1
- data/java/src/json/ext/Generator.java +35 -15
- data/java/src/json/ext/GeneratorState.java +2 -54
- data/java/src/json/ext/OptionsReader.java +1 -1
- data/java/src/json/ext/Parser.java +131 -413
- data/java/src/json/ext/Parser.rl +47 -122
- data/java/src/json/ext/RuntimeInfo.java +0 -4
- data/json-java.gemspec +1 -2
- data/json.gemspec +0 -0
- data/json_pure.gemspec +8 -7
- data/lib/json.rb +1 -0
- data/lib/json/add/bigdecimal.rb +3 -2
- data/lib/json/add/complex.rb +4 -3
- data/lib/json/add/core.rb +1 -0
- data/lib/json/add/date.rb +1 -1
- data/lib/json/add/date_time.rb +1 -1
- data/lib/json/add/exception.rb +1 -1
- data/lib/json/add/ostruct.rb +3 -3
- data/lib/json/add/range.rb +1 -1
- data/lib/json/add/rational.rb +3 -2
- data/lib/json/add/regexp.rb +3 -3
- data/lib/json/add/set.rb +29 -0
- data/lib/json/add/struct.rb +1 -1
- data/lib/json/add/symbol.rb +1 -1
- data/lib/json/add/time.rb +1 -1
- data/lib/json/common.rb +26 -54
- data/lib/json/ext.rb +0 -6
- data/lib/json/generic_object.rb +5 -4
- data/lib/json/pure.rb +2 -8
- data/lib/json/pure/generator.rb +53 -124
- data/lib/json/pure/parser.rb +41 -81
- data/lib/json/version.rb +2 -1
- data/references/rfc7159.txt +899 -0
- data/tests/fixtures/obsolete_fail1.json +1 -0
- data/tests/{test_json_addition.rb → json_addition_test.rb} +32 -25
- data/tests/json_common_interface_test.rb +126 -0
- data/tests/json_encoding_test.rb +107 -0
- data/tests/json_ext_parser_test.rb +15 -0
- data/tests/{test_json_fixtures.rb → json_fixtures_test.rb} +5 -8
- data/tests/{test_json_generate.rb → json_generator_test.rb} +112 -39
- data/tests/{test_json_generic_object.rb → json_generic_object_test.rb} +15 -8
- data/tests/json_parser_test.rb +472 -0
- data/tests/json_string_matching_test.rb +38 -0
- data/tests/{setup_variant.rb → test_helper.rb} +6 -0
- data/tools/fuzz.rb +1 -9
- metadata +22 -37
- data/TODO +0 -1
- data/data/example.json +0 -1
- data/data/index.html +0 -38
- data/data/prototype.js +0 -4184
- data/tests/fixtures/fail1.json +0 -1
- data/tests/test_json.rb +0 -519
- data/tests/test_json_encoding.rb +0 -65
- data/tests/test_json_string_matching.rb +0 -39
- data/tests/test_json_unicode.rb +0 -72
data/ext/json/extconf.rb
CHANGED
@@ -7,6 +7,7 @@ package json.ext;
|
|
7
7
|
|
8
8
|
import org.jruby.Ruby;
|
9
9
|
import org.jruby.RubyArray;
|
10
|
+
import org.jruby.RubyBasicObject;
|
10
11
|
import org.jruby.RubyBignum;
|
11
12
|
import org.jruby.RubyBoolean;
|
12
13
|
import org.jruby.RubyClass;
|
@@ -15,6 +16,7 @@ import org.jruby.RubyFloat;
|
|
15
16
|
import org.jruby.RubyHash;
|
16
17
|
import org.jruby.RubyNumeric;
|
17
18
|
import org.jruby.RubyString;
|
19
|
+
import org.jruby.runtime.ClassIndex;
|
18
20
|
import org.jruby.runtime.ThreadContext;
|
19
21
|
import org.jruby.runtime.builtin.IRubyObject;
|
20
22
|
import org.jruby.util.ByteList;
|
@@ -57,6 +59,19 @@ public final class Generator {
|
|
57
59
|
return handler.generateNew(session, object);
|
58
60
|
}
|
59
61
|
|
62
|
+
// NOTE: drop this once Ruby 1.9.3 support is gone!
|
63
|
+
private static final int FIXNUM = 1;
|
64
|
+
private static final int BIGNUM = 2;
|
65
|
+
private static final int ARRAY = 3;
|
66
|
+
private static final int STRING = 4;
|
67
|
+
private static final int NIL = 5;
|
68
|
+
private static final int TRUE = 6;
|
69
|
+
private static final int FALSE = 7;
|
70
|
+
private static final int HASH = 10;
|
71
|
+
private static final int FLOAT = 11;
|
72
|
+
// hard-coded due JRuby 1.7 compatibility
|
73
|
+
// https://github.com/jruby/jruby/blob/1.7.27/core/src/main/java/org/jruby/runtime/ClassIndex.java
|
74
|
+
|
60
75
|
/**
|
61
76
|
* Returns the best serialization handler for the given object.
|
62
77
|
*/
|
@@ -65,16 +80,24 @@ public final class Generator {
|
|
65
80
|
@SuppressWarnings("unchecked")
|
66
81
|
private static <T extends IRubyObject>
|
67
82
|
Handler<? super T> getHandlerFor(Ruby runtime, T object) {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
83
|
+
switch (((RubyBasicObject) object).getNativeTypeIndex()) {
|
84
|
+
// can not use getNativeClassIndex due 1.7 compatibility
|
85
|
+
case NIL : return (Handler) NIL_HANDLER;
|
86
|
+
case TRUE : return (Handler) TRUE_HANDLER;
|
87
|
+
case FALSE : return (Handler) FALSE_HANDLER;
|
88
|
+
case FLOAT : return (Handler) FLOAT_HANDLER;
|
89
|
+
case FIXNUM : return (Handler) FIXNUM_HANDLER;
|
90
|
+
case BIGNUM : return (Handler) BIGNUM_HANDLER;
|
91
|
+
case STRING :
|
92
|
+
if (((RubyBasicObject) object).getMetaClass() != runtime.getString()) break;
|
93
|
+
return (Handler) STRING_HANDLER;
|
94
|
+
case ARRAY :
|
95
|
+
if (((RubyBasicObject) object).getMetaClass() != runtime.getArray()) break;
|
96
|
+
return (Handler) ARRAY_HANDLER;
|
97
|
+
case HASH :
|
98
|
+
if (((RubyBasicObject) object).getMetaClass() != runtime.getHash()) break;
|
99
|
+
return (Handler) HASH_HANDLER;
|
100
|
+
}
|
78
101
|
return GENERIC_HANDLER;
|
79
102
|
}
|
80
103
|
|
@@ -172,9 +195,7 @@ public final class Generator {
|
|
172
195
|
result = RubyString.newString(session.getRuntime(), buffer);
|
173
196
|
ThreadContext context = session.getContext();
|
174
197
|
RuntimeInfo info = session.getInfo();
|
175
|
-
|
176
|
-
result.force_encoding(context, info.utf8.get());
|
177
|
-
}
|
198
|
+
result.force_encoding(context, info.utf8.get());
|
178
199
|
return result;
|
179
200
|
}
|
180
201
|
|
@@ -381,8 +402,7 @@ public final class Generator {
|
|
381
402
|
RuntimeInfo info = session.getInfo();
|
382
403
|
RubyString src;
|
383
404
|
|
384
|
-
if (info.
|
385
|
-
object.encoding(session.getContext()) != info.utf8.get()) {
|
405
|
+
if (object.encoding(session.getContext()) != info.utf8.get()) {
|
386
406
|
src = (RubyString)object.encode(session.getContext(),
|
387
407
|
info.utf8.get());
|
388
408
|
} else {
|
@@ -207,45 +207,11 @@ public class GeneratorState extends RubyObject {
|
|
207
207
|
@JRubyMethod
|
208
208
|
public IRubyObject generate(ThreadContext context, IRubyObject obj) {
|
209
209
|
RubyString result = Generator.generateJson(context, obj, this);
|
210
|
-
if (!quirksMode && !objectOrArrayLiteral(result)) {
|
211
|
-
throw Utils.newException(context, Utils.M_GENERATOR_ERROR,
|
212
|
-
"only generation of JSON objects or arrays allowed");
|
213
|
-
}
|
214
210
|
RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
|
215
|
-
|
216
|
-
result.force_encoding(context, info.utf8.get());
|
217
|
-
}
|
211
|
+
result.force_encoding(context, info.utf8.get());
|
218
212
|
return result;
|
219
213
|
}
|
220
214
|
|
221
|
-
/**
|
222
|
-
* Ensures the given string is in the form "[...]" or "{...}", being
|
223
|
-
* possibly surrounded by white space.
|
224
|
-
* The string's encoding must be ASCII-compatible.
|
225
|
-
* @param value
|
226
|
-
* @return
|
227
|
-
*/
|
228
|
-
private static boolean objectOrArrayLiteral(RubyString value) {
|
229
|
-
ByteList bl = value.getByteList();
|
230
|
-
int len = bl.length();
|
231
|
-
|
232
|
-
for (int pos = 0; pos < len - 1; pos++) {
|
233
|
-
int b = bl.get(pos);
|
234
|
-
if (Character.isWhitespace(b)) continue;
|
235
|
-
|
236
|
-
// match the opening brace
|
237
|
-
switch (b) {
|
238
|
-
case '[':
|
239
|
-
return matchClosingBrace(bl, pos, len, ']');
|
240
|
-
case '{':
|
241
|
-
return matchClosingBrace(bl, pos, len, '}');
|
242
|
-
default:
|
243
|
-
return false;
|
244
|
-
}
|
245
|
-
}
|
246
|
-
return false;
|
247
|
-
}
|
248
|
-
|
249
215
|
private static boolean matchClosingBrace(ByteList bl, int pos, int len,
|
250
216
|
int brace) {
|
251
217
|
for (int endPos = len - 1; endPos > pos; endPos--) {
|
@@ -398,17 +364,6 @@ public class GeneratorState extends RubyObject {
|
|
398
364
|
return context.getRuntime().newBoolean(asciiOnly);
|
399
365
|
}
|
400
366
|
|
401
|
-
@JRubyMethod(name="quirks_mode")
|
402
|
-
public RubyBoolean quirks_mode_get(ThreadContext context) {
|
403
|
-
return context.getRuntime().newBoolean(quirksMode);
|
404
|
-
}
|
405
|
-
|
406
|
-
@JRubyMethod(name="quirks_mode=")
|
407
|
-
public IRubyObject quirks_mode_set(IRubyObject quirks_mode) {
|
408
|
-
quirksMode = quirks_mode.isTrue();
|
409
|
-
return quirks_mode.getRuntime().newBoolean(quirksMode);
|
410
|
-
}
|
411
|
-
|
412
367
|
@JRubyMethod(name="buffer_initial_length")
|
413
368
|
public RubyInteger buffer_initial_length_get(ThreadContext context) {
|
414
369
|
return context.getRuntime().newFixnum(bufferInitialLength);
|
@@ -421,11 +376,6 @@ public class GeneratorState extends RubyObject {
|
|
421
376
|
return buffer_initial_length;
|
422
377
|
}
|
423
378
|
|
424
|
-
@JRubyMethod(name="quirks_mode?")
|
425
|
-
public RubyBoolean quirks_mode_p(ThreadContext context) {
|
426
|
-
return context.getRuntime().newBoolean(quirksMode);
|
427
|
-
}
|
428
|
-
|
429
379
|
public int getDepth() {
|
430
380
|
return depth;
|
431
381
|
}
|
@@ -444,7 +394,7 @@ public class GeneratorState extends RubyObject {
|
|
444
394
|
private ByteList prepareByteList(ThreadContext context, IRubyObject value) {
|
445
395
|
RubyString str = value.convertToString();
|
446
396
|
RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
|
447
|
-
if (
|
397
|
+
if (str.encoding(context) != info.utf8.get()) {
|
448
398
|
str = (RubyString)str.encode(context, info.utf8.get());
|
449
399
|
}
|
450
400
|
return str.getByteList().dup();
|
@@ -480,7 +430,6 @@ public class GeneratorState extends RubyObject {
|
|
480
430
|
maxNesting = opts.getInt("max_nesting", DEFAULT_MAX_NESTING);
|
481
431
|
allowNaN = opts.getBool("allow_nan", DEFAULT_ALLOW_NAN);
|
482
432
|
asciiOnly = opts.getBool("ascii_only", DEFAULT_ASCII_ONLY);
|
483
|
-
quirksMode = opts.getBool("quirks_mode", DEFAULT_QUIRKS_MODE);
|
484
433
|
bufferInitialLength = opts.getInt("buffer_initial_length", DEFAULT_BUFFER_INITIAL_LENGTH);
|
485
434
|
|
486
435
|
depth = opts.getInt("depth", 0);
|
@@ -507,7 +456,6 @@ public class GeneratorState extends RubyObject {
|
|
507
456
|
result.op_aset(context, runtime.newSymbol("array_nl"), array_nl_get(context));
|
508
457
|
result.op_aset(context, runtime.newSymbol("allow_nan"), allow_nan_p(context));
|
509
458
|
result.op_aset(context, runtime.newSymbol("ascii_only"), ascii_only_p(context));
|
510
|
-
result.op_aset(context, runtime.newSymbol("quirks_mode"), quirks_mode_p(context));
|
511
459
|
result.op_aset(context, runtime.newSymbol("max_nesting"), max_nesting_get(context));
|
512
460
|
result.op_aset(context, runtime.newSymbol("depth"), depth_get(context));
|
513
461
|
result.op_aset(context, runtime.newSymbol("buffer_initial_length"), buffer_initial_length_get(context));
|
@@ -84,7 +84,7 @@ final class OptionsReader {
|
|
84
84
|
|
85
85
|
RubyString str = value.convertToString();
|
86
86
|
RuntimeInfo info = getRuntimeInfo();
|
87
|
-
if (
|
87
|
+
if (str.encoding(context) != info.utf8.get()) {
|
88
88
|
str = (RubyString)str.encode(context, info.utf8.get());
|
89
89
|
}
|
90
90
|
return str;
|
@@ -52,9 +52,9 @@ public class Parser extends RubyObject {
|
|
52
52
|
private int maxNesting;
|
53
53
|
private boolean allowNaN;
|
54
54
|
private boolean symbolizeNames;
|
55
|
-
private boolean quirksMode;
|
56
55
|
private RubyClass objectClass;
|
57
56
|
private RubyClass arrayClass;
|
57
|
+
private RubyClass decimalClass;
|
58
58
|
private RubyHash match_string;
|
59
59
|
|
60
60
|
private static final int DEFAULT_MAX_NESTING = 100;
|
@@ -123,10 +123,6 @@ public class Parser extends RubyObject {
|
|
123
123
|
* <dd>If set to <code>true</code>, returns symbols for the names (keys) in
|
124
124
|
* a JSON object. Otherwise strings are returned, which is also the default.
|
125
125
|
*
|
126
|
-
* <dt><code>:quirks_mode?</code>
|
127
|
-
* <dd>If set to <code>true</code>, if the parse is in quirks_mode, false
|
128
|
-
* otherwise.
|
129
|
-
*
|
130
126
|
* <dt><code>:create_additions</code>
|
131
127
|
* <dd>If set to <code>false</code>, the Parser doesn't create additions
|
132
128
|
* even if a matching class and <code>create_id</code> was found. This option
|
@@ -138,9 +134,10 @@ public class Parser extends RubyObject {
|
|
138
134
|
* <dt><code>:array_class</code>
|
139
135
|
* <dd>Defaults to Array.
|
140
136
|
*
|
141
|
-
* <dt><code>:
|
142
|
-
* <dd>
|
143
|
-
*
|
137
|
+
* <dt><code>:decimal_class</code>
|
138
|
+
* <dd>Specifies which class to use instead of the default (Float) when
|
139
|
+
* parsing decimal numbers. This class must accept a single string argument
|
140
|
+
* in its constructor.
|
144
141
|
* </dl>
|
145
142
|
*/
|
146
143
|
@JRubyMethod(name = "new", required = 1, optional = 1, meta = true)
|
@@ -163,15 +160,21 @@ public class Parser extends RubyObject {
|
|
163
160
|
this.maxNesting = opts.getInt("max_nesting", DEFAULT_MAX_NESTING);
|
164
161
|
this.allowNaN = opts.getBool("allow_nan", false);
|
165
162
|
this.symbolizeNames = opts.getBool("symbolize_names", false);
|
166
|
-
this.quirksMode = opts.getBool("quirks_mode", false);
|
167
163
|
this.createId = opts.getString("create_id", getCreateId(context));
|
168
164
|
this.createAdditions = opts.getBool("create_additions", false);
|
169
165
|
this.objectClass = opts.getClass("object_class", runtime.getHash());
|
170
166
|
this.arrayClass = opts.getClass("array_class", runtime.getArray());
|
167
|
+
this.decimalClass = opts.getClass("decimal_class", null);
|
171
168
|
this.match_string = opts.getHash("match_string");
|
172
169
|
|
170
|
+
if(symbolizeNames && createAdditions) {
|
171
|
+
throw runtime.newArgumentError(
|
172
|
+
"options :symbolize_names and :create_additions cannot be " +
|
173
|
+
" used in conjunction"
|
174
|
+
);
|
175
|
+
}
|
173
176
|
this.vSource = args[0].convertToString();
|
174
|
-
|
177
|
+
this.vSource = convertEncoding(context, vSource);
|
175
178
|
|
176
179
|
return this;
|
177
180
|
}
|
@@ -182,33 +185,16 @@ public class Parser extends RubyObject {
|
|
182
185
|
* Returns the source string if no conversion is needed.
|
183
186
|
*/
|
184
187
|
private RubyString convertEncoding(ThreadContext context, RubyString source) {
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
return (RubyString)source.encode(context, info.utf8.get());
|
196
|
-
}
|
197
|
-
|
198
|
-
String sniffedEncoding = sniffByteList(bl);
|
199
|
-
if (sniffedEncoding == null) return source; // assume UTF-8
|
200
|
-
return reinterpretEncoding(context, source, sniffedEncoding);
|
201
|
-
}
|
202
|
-
|
203
|
-
String sniffedEncoding = sniffByteList(bl);
|
204
|
-
if (sniffedEncoding == null) return source; // assume UTF-8
|
205
|
-
Ruby runtime = context.getRuntime();
|
206
|
-
return (RubyString)info.jsonModule.get().
|
207
|
-
callMethod(context, "iconv",
|
208
|
-
new IRubyObject[] {
|
209
|
-
runtime.newString("utf-8"),
|
210
|
-
runtime.newString(sniffedEncoding),
|
211
|
-
source});
|
188
|
+
RubyEncoding encoding = (RubyEncoding)source.encoding(context);
|
189
|
+
if (encoding == info.ascii8bit.get()) {
|
190
|
+
if (source.isFrozen()) {
|
191
|
+
source = (RubyString) source.dup();
|
192
|
+
}
|
193
|
+
source.force_encoding(context, info.utf8.get());
|
194
|
+
} else {
|
195
|
+
source = (RubyString) source.encode(context, info.utf8.get());
|
196
|
+
}
|
197
|
+
return source;
|
212
198
|
}
|
213
199
|
|
214
200
|
/**
|
@@ -261,17 +247,6 @@ public class Parser extends RubyObject {
|
|
261
247
|
return checkAndGetSource().dup();
|
262
248
|
}
|
263
249
|
|
264
|
-
/**
|
265
|
-
* <code>Parser#quirks_mode?()</code>
|
266
|
-
*
|
267
|
-
* <p>If set to <code>true</code>, if the parse is in quirks_mode, false
|
268
|
-
* otherwise.
|
269
|
-
*/
|
270
|
-
@JRubyMethod(name = "quirks_mode?")
|
271
|
-
public IRubyObject quirks_mode_p(ThreadContext context) {
|
272
|
-
return context.getRuntime().newBoolean(quirksMode);
|
273
|
-
}
|
274
|
-
|
275
250
|
public RubyString checkAndGetSource() {
|
276
251
|
if (vSource != null) {
|
277
252
|
return vSource;
|
@@ -338,11 +313,11 @@ public class Parser extends RubyObject {
|
|
338
313
|
}
|
339
314
|
|
340
315
|
|
341
|
-
// line
|
316
|
+
// line 339 "Parser.rl"
|
342
317
|
|
343
318
|
|
344
319
|
|
345
|
-
// line
|
320
|
+
// line 321 "Parser.java"
|
346
321
|
private static byte[] init__JSON_value_actions_0()
|
347
322
|
{
|
348
323
|
return new byte [] {
|
@@ -456,7 +431,7 @@ static final int JSON_value_error = 0;
|
|
456
431
|
static final int JSON_value_en_main = 1;
|
457
432
|
|
458
433
|
|
459
|
-
// line
|
434
|
+
// line 445 "Parser.rl"
|
460
435
|
|
461
436
|
|
462
437
|
void parseValue(ParserResult res, int p, int pe) {
|
@@ -464,14 +439,14 @@ static final int JSON_value_en_main = 1;
|
|
464
439
|
IRubyObject result = null;
|
465
440
|
|
466
441
|
|
467
|
-
// line
|
442
|
+
// line 443 "Parser.java"
|
468
443
|
{
|
469
444
|
cs = JSON_value_start;
|
470
445
|
}
|
471
446
|
|
472
|
-
// line
|
447
|
+
// line 452 "Parser.rl"
|
473
448
|
|
474
|
-
// line
|
449
|
+
// line 450 "Parser.java"
|
475
450
|
{
|
476
451
|
int _klen;
|
477
452
|
int _trans = 0;
|
@@ -497,13 +472,13 @@ case 1:
|
|
497
472
|
while ( _nacts-- > 0 ) {
|
498
473
|
switch ( _JSON_value_actions[_acts++] ) {
|
499
474
|
case 9:
|
500
|
-
// line
|
475
|
+
// line 430 "Parser.rl"
|
501
476
|
{
|
502
477
|
p--;
|
503
478
|
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
504
479
|
}
|
505
480
|
break;
|
506
|
-
// line
|
481
|
+
// line 482 "Parser.java"
|
507
482
|
}
|
508
483
|
}
|
509
484
|
|
@@ -566,25 +541,25 @@ case 1:
|
|
566
541
|
switch ( _JSON_value_actions[_acts++] )
|
567
542
|
{
|
568
543
|
case 0:
|
569
|
-
// line
|
544
|
+
// line 347 "Parser.rl"
|
570
545
|
{
|
571
546
|
result = getRuntime().getNil();
|
572
547
|
}
|
573
548
|
break;
|
574
549
|
case 1:
|
575
|
-
// line
|
550
|
+
// line 350 "Parser.rl"
|
576
551
|
{
|
577
552
|
result = getRuntime().getFalse();
|
578
553
|
}
|
579
554
|
break;
|
580
555
|
case 2:
|
581
|
-
// line
|
556
|
+
// line 353 "Parser.rl"
|
582
557
|
{
|
583
558
|
result = getRuntime().getTrue();
|
584
559
|
}
|
585
560
|
break;
|
586
561
|
case 3:
|
587
|
-
// line
|
562
|
+
// line 356 "Parser.rl"
|
588
563
|
{
|
589
564
|
if (parser.allowNaN) {
|
590
565
|
result = getConstant(CONST_NAN);
|
@@ -594,7 +569,7 @@ case 1:
|
|
594
569
|
}
|
595
570
|
break;
|
596
571
|
case 4:
|
597
|
-
// line
|
572
|
+
// line 363 "Parser.rl"
|
598
573
|
{
|
599
574
|
if (parser.allowNaN) {
|
600
575
|
result = getConstant(CONST_INFINITY);
|
@@ -604,9 +579,9 @@ case 1:
|
|
604
579
|
}
|
605
580
|
break;
|
606
581
|
case 5:
|
607
|
-
// line
|
582
|
+
// line 370 "Parser.rl"
|
608
583
|
{
|
609
|
-
if (pe > p +
|
584
|
+
if (pe > p + 8 &&
|
610
585
|
absSubSequence(p, p + 9).equals(JSON_MINUS_INFINITY)) {
|
611
586
|
|
612
587
|
if (parser.allowNaN) {
|
@@ -633,7 +608,7 @@ case 1:
|
|
633
608
|
}
|
634
609
|
break;
|
635
610
|
case 6:
|
636
|
-
// line
|
611
|
+
// line 396 "Parser.rl"
|
637
612
|
{
|
638
613
|
parseString(res, p, pe);
|
639
614
|
if (res.result == null) {
|
@@ -646,7 +621,7 @@ case 1:
|
|
646
621
|
}
|
647
622
|
break;
|
648
623
|
case 7:
|
649
|
-
// line
|
624
|
+
// line 406 "Parser.rl"
|
650
625
|
{
|
651
626
|
currentNesting++;
|
652
627
|
parseArray(res, p, pe);
|
@@ -661,7 +636,7 @@ case 1:
|
|
661
636
|
}
|
662
637
|
break;
|
663
638
|
case 8:
|
664
|
-
// line
|
639
|
+
// line 418 "Parser.rl"
|
665
640
|
{
|
666
641
|
currentNesting++;
|
667
642
|
parseObject(res, p, pe);
|
@@ -675,7 +650,7 @@ case 1:
|
|
675
650
|
}
|
676
651
|
}
|
677
652
|
break;
|
678
|
-
// line
|
653
|
+
// line 654 "Parser.java"
|
679
654
|
}
|
680
655
|
}
|
681
656
|
}
|
@@ -695,7 +670,7 @@ case 5:
|
|
695
670
|
break; }
|
696
671
|
}
|
697
672
|
|
698
|
-
// line
|
673
|
+
// line 453 "Parser.rl"
|
699
674
|
|
700
675
|
if (cs >= JSON_value_first_final && result != null) {
|
701
676
|
res.update(result, p);
|
@@ -705,7 +680,7 @@ case 5:
|
|
705
680
|
}
|
706
681
|
|
707
682
|
|
708
|
-
// line
|
683
|
+
// line 684 "Parser.java"
|
709
684
|
private static byte[] init__JSON_integer_actions_0()
|
710
685
|
{
|
711
686
|
return new byte [] {
|
@@ -804,7 +779,7 @@ static final int JSON_integer_error = 0;
|
|
804
779
|
static final int JSON_integer_en_main = 1;
|
805
780
|
|
806
781
|
|
807
|
-
// line
|
782
|
+
// line 472 "Parser.rl"
|
808
783
|
|
809
784
|
|
810
785
|
void parseInteger(ParserResult res, int p, int pe) {
|
@@ -822,15 +797,15 @@ static final int JSON_integer_en_main = 1;
|
|
822
797
|
int cs = EVIL;
|
823
798
|
|
824
799
|
|
825
|
-
// line
|
800
|
+
// line 801 "Parser.java"
|
826
801
|
{
|
827
802
|
cs = JSON_integer_start;
|
828
803
|
}
|
829
804
|
|
830
|
-
// line
|
805
|
+
// line 489 "Parser.rl"
|
831
806
|
int memo = p;
|
832
807
|
|
833
|
-
// line
|
808
|
+
// line 809 "Parser.java"
|
834
809
|
{
|
835
810
|
int _klen;
|
836
811
|
int _trans = 0;
|
@@ -911,13 +886,13 @@ case 1:
|
|
911
886
|
switch ( _JSON_integer_actions[_acts++] )
|
912
887
|
{
|
913
888
|
case 0:
|
914
|
-
// line
|
889
|
+
// line 466 "Parser.rl"
|
915
890
|
{
|
916
891
|
p--;
|
917
892
|
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
918
893
|
}
|
919
894
|
break;
|
920
|
-
// line
|
895
|
+
// line 896 "Parser.java"
|
921
896
|
}
|
922
897
|
}
|
923
898
|
}
|
@@ -937,7 +912,7 @@ case 5:
|
|
937
912
|
break; }
|
938
913
|
}
|
939
914
|
|
940
|
-
// line
|
915
|
+
// line 491 "Parser.rl"
|
941
916
|
|
942
917
|
if (cs < JSON_integer_first_final) {
|
943
918
|
return -1;
|
@@ -945,13 +920,13 @@ case 5:
|
|
945
920
|
|
946
921
|
return p;
|
947
922
|
}
|
948
|
-
|
923
|
+
|
949
924
|
RubyInteger createInteger(int p, int new_p) {
|
950
925
|
Ruby runtime = getRuntime();
|
951
926
|
ByteList num = absSubSequence(p, new_p);
|
952
927
|
return bytesToInum(runtime, num);
|
953
928
|
}
|
954
|
-
|
929
|
+
|
955
930
|
RubyInteger bytesToInum(Ruby runtime, ByteList num) {
|
956
931
|
return runtime.is1_9() ?
|
957
932
|
ConvertBytes.byteListToInum19(runtime, num, 10, true) :
|
@@ -959,7 +934,7 @@ case 5:
|
|
959
934
|
}
|
960
935
|
|
961
936
|
|
962
|
-
// line
|
937
|
+
// line 938 "Parser.java"
|
963
938
|
private static byte[] init__JSON_float_actions_0()
|
964
939
|
{
|
965
940
|
return new byte [] {
|
@@ -1061,7 +1036,7 @@ static final int JSON_float_error = 0;
|
|
1061
1036
|
static final int JSON_float_en_main = 1;
|
1062
1037
|
|
1063
1038
|
|
1064
|
-
// line
|
1039
|
+
// line 526 "Parser.rl"
|
1065
1040
|
|
1066
1041
|
|
1067
1042
|
void parseFloat(ParserResult res, int p, int pe) {
|
@@ -1070,7 +1045,9 @@ static final int JSON_float_en_main = 1;
|
|
1070
1045
|
res.update(null, p);
|
1071
1046
|
return;
|
1072
1047
|
}
|
1073
|
-
|
1048
|
+
IRubyObject number = parser.decimalClass == null ?
|
1049
|
+
createFloat(p, new_p) : createCustomDecimal(p, new_p);
|
1050
|
+
|
1074
1051
|
res.update(number, new_p + 1);
|
1075
1052
|
return;
|
1076
1053
|
}
|
@@ -1079,15 +1056,15 @@ static final int JSON_float_en_main = 1;
|
|
1079
1056
|
int cs = EVIL;
|
1080
1057
|
|
1081
1058
|
|
1082
|
-
// line
|
1059
|
+
// line 1060 "Parser.java"
|
1083
1060
|
{
|
1084
1061
|
cs = JSON_float_start;
|
1085
1062
|
}
|
1086
1063
|
|
1087
|
-
// line
|
1064
|
+
// line 545 "Parser.rl"
|
1088
1065
|
int memo = p;
|
1089
1066
|
|
1090
|
-
// line
|
1067
|
+
// line 1068 "Parser.java"
|
1091
1068
|
{
|
1092
1069
|
int _klen;
|
1093
1070
|
int _trans = 0;
|
@@ -1168,13 +1145,13 @@ case 1:
|
|
1168
1145
|
switch ( _JSON_float_actions[_acts++] )
|
1169
1146
|
{
|
1170
1147
|
case 0:
|
1171
|
-
// line
|
1148
|
+
// line 517 "Parser.rl"
|
1172
1149
|
{
|
1173
1150
|
p--;
|
1174
1151
|
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
1175
1152
|
}
|
1176
1153
|
break;
|
1177
|
-
// line
|
1154
|
+
// line 1155 "Parser.java"
|
1178
1155
|
}
|
1179
1156
|
}
|
1180
1157
|
}
|
@@ -1194,23 +1171,30 @@ case 5:
|
|
1194
1171
|
break; }
|
1195
1172
|
}
|
1196
1173
|
|
1197
|
-
// line
|
1174
|
+
// line 547 "Parser.rl"
|
1198
1175
|
|
1199
1176
|
if (cs < JSON_float_first_final) {
|
1200
1177
|
return -1;
|
1201
1178
|
}
|
1202
|
-
|
1179
|
+
|
1203
1180
|
return p;
|
1204
1181
|
}
|
1205
|
-
|
1182
|
+
|
1206
1183
|
RubyFloat createFloat(int p, int new_p) {
|
1207
1184
|
Ruby runtime = getRuntime();
|
1208
1185
|
ByteList num = absSubSequence(p, new_p);
|
1209
1186
|
return RubyFloat.newFloat(runtime, dc.parse(num, true, runtime.is1_9()));
|
1210
1187
|
}
|
1211
1188
|
|
1189
|
+
IRubyObject createCustomDecimal(int p, int new_p) {
|
1190
|
+
Ruby runtime = getRuntime();
|
1191
|
+
ByteList num = absSubSequence(p, new_p);
|
1192
|
+
IRubyObject numString = runtime.newString(num.toString());
|
1193
|
+
return parser.decimalClass.callMethod(context, "new", numString);
|
1194
|
+
}
|
1195
|
+
|
1212
1196
|
|
1213
|
-
// line
|
1197
|
+
// line 1198 "Parser.java"
|
1214
1198
|
private static byte[] init__JSON_string_actions_0()
|
1215
1199
|
{
|
1216
1200
|
return new byte [] {
|
@@ -1312,7 +1296,7 @@ static final int JSON_string_error = 0;
|
|
1312
1296
|
static final int JSON_string_en_main = 1;
|
1313
1297
|
|
1314
1298
|
|
1315
|
-
// line
|
1299
|
+
// line 599 "Parser.rl"
|
1316
1300
|
|
1317
1301
|
|
1318
1302
|
void parseString(ParserResult res, int p, int pe) {
|
@@ -1320,15 +1304,15 @@ static final int JSON_string_en_main = 1;
|
|
1320
1304
|
IRubyObject result = null;
|
1321
1305
|
|
1322
1306
|
|
1323
|
-
// line
|
1307
|
+
// line 1308 "Parser.java"
|
1324
1308
|
{
|
1325
1309
|
cs = JSON_string_start;
|
1326
1310
|
}
|
1327
1311
|
|
1328
|
-
// line
|
1312
|
+
// line 606 "Parser.rl"
|
1329
1313
|
int memo = p;
|
1330
1314
|
|
1331
|
-
// line
|
1315
|
+
// line 1316 "Parser.java"
|
1332
1316
|
{
|
1333
1317
|
int _klen;
|
1334
1318
|
int _trans = 0;
|
@@ -1409,7 +1393,7 @@ case 1:
|
|
1409
1393
|
switch ( _JSON_string_actions[_acts++] )
|
1410
1394
|
{
|
1411
1395
|
case 0:
|
1412
|
-
// line
|
1396
|
+
// line 574 "Parser.rl"
|
1413
1397
|
{
|
1414
1398
|
int offset = byteList.begin();
|
1415
1399
|
ByteList decoded = decoder.decode(byteList, memo + 1 - offset,
|
@@ -1424,13 +1408,13 @@ case 1:
|
|
1424
1408
|
}
|
1425
1409
|
break;
|
1426
1410
|
case 1:
|
1427
|
-
// line
|
1411
|
+
// line 587 "Parser.rl"
|
1428
1412
|
{
|
1429
1413
|
p--;
|
1430
1414
|
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
1431
1415
|
}
|
1432
1416
|
break;
|
1433
|
-
// line
|
1417
|
+
// line 1418 "Parser.java"
|
1434
1418
|
}
|
1435
1419
|
}
|
1436
1420
|
}
|
@@ -1450,14 +1434,14 @@ case 5:
|
|
1450
1434
|
break; }
|
1451
1435
|
}
|
1452
1436
|
|
1453
|
-
// line
|
1437
|
+
// line 608 "Parser.rl"
|
1454
1438
|
|
1455
1439
|
if (parser.createAdditions) {
|
1456
|
-
RubyHash
|
1457
|
-
if (
|
1440
|
+
RubyHash matchString = parser.match_string;
|
1441
|
+
if (matchString != null) {
|
1458
1442
|
final IRubyObject[] memoArray = { result, null };
|
1459
1443
|
try {
|
1460
|
-
|
1444
|
+
matchString.visitAll(new RubyHash.Visitor() {
|
1461
1445
|
@Override
|
1462
1446
|
public void visit(IRubyObject pattern, IRubyObject klass) {
|
1463
1447
|
if (pattern.callMethod(context, "===", memoArray[0]).isTrue()) {
|
@@ -1477,8 +1461,8 @@ case 5:
|
|
1477
1461
|
}
|
1478
1462
|
}
|
1479
1463
|
|
1480
|
-
if (cs >= JSON_string_first_final && result != null) {
|
1481
|
-
if (
|
1464
|
+
if (cs >= JSON_string_first_final && result != null) {
|
1465
|
+
if (result instanceof RubyString) {
|
1482
1466
|
((RubyString)result).force_encoding(context, info.utf8.get());
|
1483
1467
|
}
|
1484
1468
|
res.update(result, p + 1);
|
@@ -1488,7 +1472,7 @@ case 5:
|
|
1488
1472
|
}
|
1489
1473
|
|
1490
1474
|
|
1491
|
-
// line
|
1475
|
+
// line 1476 "Parser.java"
|
1492
1476
|
private static byte[] init__JSON_array_actions_0()
|
1493
1477
|
{
|
1494
1478
|
return new byte [] {
|
@@ -1601,7 +1585,7 @@ static final int JSON_array_error = 0;
|
|
1601
1585
|
static final int JSON_array_en_main = 1;
|
1602
1586
|
|
1603
1587
|
|
1604
|
-
// line
|
1588
|
+
// line 681 "Parser.rl"
|
1605
1589
|
|
1606
1590
|
|
1607
1591
|
void parseArray(ParserResult res, int p, int pe) {
|
@@ -1621,14 +1605,14 @@ static final int JSON_array_en_main = 1;
|
|
1621
1605
|
}
|
1622
1606
|
|
1623
1607
|
|
1624
|
-
// line
|
1608
|
+
// line 1609 "Parser.java"
|
1625
1609
|
{
|
1626
1610
|
cs = JSON_array_start;
|
1627
1611
|
}
|
1628
1612
|
|
1629
|
-
// line
|
1613
|
+
// line 700 "Parser.rl"
|
1630
1614
|
|
1631
|
-
// line
|
1615
|
+
// line 1616 "Parser.java"
|
1632
1616
|
{
|
1633
1617
|
int _klen;
|
1634
1618
|
int _trans = 0;
|
@@ -1709,7 +1693,7 @@ case 1:
|
|
1709
1693
|
switch ( _JSON_array_actions[_acts++] )
|
1710
1694
|
{
|
1711
1695
|
case 0:
|
1712
|
-
// line
|
1696
|
+
// line 650 "Parser.rl"
|
1713
1697
|
{
|
1714
1698
|
parseValue(res, p, pe);
|
1715
1699
|
if (res.result == null) {
|
@@ -1726,13 +1710,13 @@ case 1:
|
|
1726
1710
|
}
|
1727
1711
|
break;
|
1728
1712
|
case 1:
|
1729
|
-
// line
|
1713
|
+
// line 665 "Parser.rl"
|
1730
1714
|
{
|
1731
1715
|
p--;
|
1732
1716
|
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
1733
1717
|
}
|
1734
1718
|
break;
|
1735
|
-
// line
|
1719
|
+
// line 1720 "Parser.java"
|
1736
1720
|
}
|
1737
1721
|
}
|
1738
1722
|
}
|
@@ -1752,7 +1736,7 @@ case 5:
|
|
1752
1736
|
break; }
|
1753
1737
|
}
|
1754
1738
|
|
1755
|
-
// line
|
1739
|
+
// line 701 "Parser.rl"
|
1756
1740
|
|
1757
1741
|
if (cs >= JSON_array_first_final) {
|
1758
1742
|
res.update(result, p + 1);
|
@@ -1762,7 +1746,7 @@ case 5:
|
|
1762
1746
|
}
|
1763
1747
|
|
1764
1748
|
|
1765
|
-
// line
|
1749
|
+
// line 1750 "Parser.java"
|
1766
1750
|
private static byte[] init__JSON_object_actions_0()
|
1767
1751
|
{
|
1768
1752
|
return new byte [] {
|
@@ -1885,7 +1869,7 @@ static final int JSON_object_error = 0;
|
|
1885
1869
|
static final int JSON_object_en_main = 1;
|
1886
1870
|
|
1887
1871
|
|
1888
|
-
// line
|
1872
|
+
// line 760 "Parser.rl"
|
1889
1873
|
|
1890
1874
|
|
1891
1875
|
void parseObject(ParserResult res, int p, int pe) {
|
@@ -1910,14 +1894,14 @@ static final int JSON_object_en_main = 1;
|
|
1910
1894
|
}
|
1911
1895
|
|
1912
1896
|
|
1913
|
-
// line
|
1897
|
+
// line 1898 "Parser.java"
|
1914
1898
|
{
|
1915
1899
|
cs = JSON_object_start;
|
1916
1900
|
}
|
1917
1901
|
|
1918
|
-
// line
|
1902
|
+
// line 784 "Parser.rl"
|
1919
1903
|
|
1920
|
-
// line
|
1904
|
+
// line 1905 "Parser.java"
|
1921
1905
|
{
|
1922
1906
|
int _klen;
|
1923
1907
|
int _trans = 0;
|
@@ -1998,7 +1982,7 @@ case 1:
|
|
1998
1982
|
switch ( _JSON_object_actions[_acts++] )
|
1999
1983
|
{
|
2000
1984
|
case 0:
|
2001
|
-
// line
|
1985
|
+
// line 715 "Parser.rl"
|
2002
1986
|
{
|
2003
1987
|
parseValue(res, p, pe);
|
2004
1988
|
if (res.result == null) {
|
@@ -2015,7 +1999,7 @@ case 1:
|
|
2015
1999
|
}
|
2016
2000
|
break;
|
2017
2001
|
case 1:
|
2018
|
-
// line
|
2002
|
+
// line 730 "Parser.rl"
|
2019
2003
|
{
|
2020
2004
|
parseString(res, p, pe);
|
2021
2005
|
if (res.result == null) {
|
@@ -2035,13 +2019,13 @@ case 1:
|
|
2035
2019
|
}
|
2036
2020
|
break;
|
2037
2021
|
case 2:
|
2038
|
-
// line
|
2022
|
+
// line 748 "Parser.rl"
|
2039
2023
|
{
|
2040
2024
|
p--;
|
2041
2025
|
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
2042
2026
|
}
|
2043
2027
|
break;
|
2044
|
-
// line
|
2028
|
+
// line 2029 "Parser.java"
|
2045
2029
|
}
|
2046
2030
|
}
|
2047
2031
|
}
|
@@ -2061,7 +2045,7 @@ case 5:
|
|
2061
2045
|
break; }
|
2062
2046
|
}
|
2063
2047
|
|
2064
|
-
// line
|
2048
|
+
// line 785 "Parser.rl"
|
2065
2049
|
|
2066
2050
|
if (cs < JSON_object_first_final) {
|
2067
2051
|
res.update(null, p + 1);
|
@@ -2094,11 +2078,11 @@ case 5:
|
|
2094
2078
|
}
|
2095
2079
|
|
2096
2080
|
|
2097
|
-
// line
|
2081
|
+
// line 2082 "Parser.java"
|
2098
2082
|
private static byte[] init__JSON_actions_0()
|
2099
2083
|
{
|
2100
2084
|
return new byte [] {
|
2101
|
-
0, 1, 0
|
2085
|
+
0, 1, 0
|
2102
2086
|
};
|
2103
2087
|
}
|
2104
2088
|
|
@@ -2108,7 +2092,7 @@ private static final byte _JSON_actions[] = init__JSON_actions_0();
|
|
2108
2092
|
private static byte[] init__JSON_key_offsets_0()
|
2109
2093
|
{
|
2110
2094
|
return new byte [] {
|
2111
|
-
0, 0,
|
2095
|
+
0, 0, 16, 18, 19, 21, 22, 24, 25, 27, 28
|
2112
2096
|
};
|
2113
2097
|
}
|
2114
2098
|
|
@@ -2118,9 +2102,9 @@ private static final byte _JSON_key_offsets[] = init__JSON_key_offsets_0();
|
|
2118
2102
|
private static char[] init__JSON_trans_keys_0()
|
2119
2103
|
{
|
2120
2104
|
return new char [] {
|
2121
|
-
13, 32,
|
2122
|
-
|
2123
|
-
|
2105
|
+
13, 32, 34, 45, 47, 73, 78, 91, 102, 110, 116, 123,
|
2106
|
+
9, 10, 48, 57, 42, 47, 42, 42, 47, 10, 42, 47,
|
2107
|
+
42, 42, 47, 10, 13, 32, 47, 9, 10, 0
|
2124
2108
|
};
|
2125
2109
|
}
|
2126
2110
|
|
@@ -2130,7 +2114,7 @@ private static final char _JSON_trans_keys[] = init__JSON_trans_keys_0();
|
|
2130
2114
|
private static byte[] init__JSON_single_lengths_0()
|
2131
2115
|
{
|
2132
2116
|
return new byte [] {
|
2133
|
-
0,
|
2117
|
+
0, 12, 2, 1, 2, 1, 2, 1, 2, 1, 3
|
2134
2118
|
};
|
2135
2119
|
}
|
2136
2120
|
|
@@ -2140,7 +2124,7 @@ private static final byte _JSON_single_lengths[] = init__JSON_single_lengths_0()
|
|
2140
2124
|
private static byte[] init__JSON_range_lengths_0()
|
2141
2125
|
{
|
2142
2126
|
return new byte [] {
|
2143
|
-
0,
|
2127
|
+
0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1
|
2144
2128
|
};
|
2145
2129
|
}
|
2146
2130
|
|
@@ -2150,7 +2134,7 @@ private static final byte _JSON_range_lengths[] = init__JSON_range_lengths_0();
|
|
2150
2134
|
private static byte[] init__JSON_index_offsets_0()
|
2151
2135
|
{
|
2152
2136
|
return new byte [] {
|
2153
|
-
0, 0,
|
2137
|
+
0, 0, 15, 18, 20, 23, 25, 28, 30, 33, 35
|
2154
2138
|
};
|
2155
2139
|
}
|
2156
2140
|
|
@@ -2160,9 +2144,10 @@ private static final byte _JSON_index_offsets[] = init__JSON_index_offsets_0();
|
|
2160
2144
|
private static byte[] init__JSON_indicies_0()
|
2161
2145
|
{
|
2162
2146
|
return new byte [] {
|
2163
|
-
0, 0, 2,
|
2164
|
-
|
2165
|
-
8,
|
2147
|
+
0, 0, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2,
|
2148
|
+
0, 2, 1, 4, 5, 1, 6, 4, 6, 7, 4, 7,
|
2149
|
+
5, 8, 9, 1, 10, 8, 10, 0, 8, 0, 9, 7,
|
2150
|
+
7, 11, 7, 1, 0
|
2166
2151
|
};
|
2167
2152
|
}
|
2168
2153
|
|
@@ -2172,8 +2157,7 @@ private static final byte _JSON_indicies[] = init__JSON_indicies_0();
|
|
2172
2157
|
private static byte[] init__JSON_trans_targs_0()
|
2173
2158
|
{
|
2174
2159
|
return new byte [] {
|
2175
|
-
1, 0,
|
2176
|
-
6
|
2160
|
+
1, 0, 10, 6, 3, 5, 4, 10, 7, 9, 8, 2
|
2177
2161
|
};
|
2178
2162
|
}
|
2179
2163
|
|
@@ -2183,8 +2167,7 @@ private static final byte _JSON_trans_targs[] = init__JSON_trans_targs_0();
|
|
2183
2167
|
private static byte[] init__JSON_trans_actions_0()
|
2184
2168
|
{
|
2185
2169
|
return new byte [] {
|
2186
|
-
0, 0,
|
2187
|
-
0
|
2170
|
+
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
2188
2171
|
};
|
2189
2172
|
}
|
2190
2173
|
|
@@ -2198,26 +2181,26 @@ static final int JSON_error = 0;
|
|
2198
2181
|
static final int JSON_en_main = 1;
|
2199
2182
|
|
2200
2183
|
|
2201
|
-
// line
|
2184
|
+
// line 836 "Parser.rl"
|
2202
2185
|
|
2203
2186
|
|
2204
|
-
public IRubyObject
|
2187
|
+
public IRubyObject parseImplemetation() {
|
2205
2188
|
int cs = EVIL;
|
2206
2189
|
int p, pe;
|
2207
2190
|
IRubyObject result = null;
|
2208
2191
|
ParserResult res = new ParserResult();
|
2209
2192
|
|
2210
2193
|
|
2211
|
-
// line
|
2194
|
+
// line 2195 "Parser.java"
|
2212
2195
|
{
|
2213
2196
|
cs = JSON_start;
|
2214
2197
|
}
|
2215
2198
|
|
2216
|
-
// line
|
2199
|
+
// line 845 "Parser.rl"
|
2217
2200
|
p = byteList.begin();
|
2218
2201
|
pe = p + byteList.length();
|
2219
2202
|
|
2220
|
-
// line
|
2203
|
+
// line 2204 "Parser.java"
|
2221
2204
|
{
|
2222
2205
|
int _klen;
|
2223
2206
|
int _trans = 0;
|
@@ -2298,267 +2281,7 @@ case 1:
|
|
2298
2281
|
switch ( _JSON_actions[_acts++] )
|
2299
2282
|
{
|
2300
2283
|
case 0:
|
2301
|
-
// line
|
2302
|
-
{
|
2303
|
-
currentNesting = 1;
|
2304
|
-
parseObject(res, p, pe);
|
2305
|
-
if (res.result == null) {
|
2306
|
-
p--;
|
2307
|
-
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
2308
|
-
} else {
|
2309
|
-
result = res.result;
|
2310
|
-
{p = (( res.p))-1;}
|
2311
|
-
}
|
2312
|
-
}
|
2313
|
-
break;
|
2314
|
-
case 1:
|
2315
|
-
// line 851 "Parser.rl"
|
2316
|
-
{
|
2317
|
-
currentNesting = 1;
|
2318
|
-
parseArray(res, p, pe);
|
2319
|
-
if (res.result == null) {
|
2320
|
-
p--;
|
2321
|
-
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
2322
|
-
} else {
|
2323
|
-
result = res.result;
|
2324
|
-
{p = (( res.p))-1;}
|
2325
|
-
}
|
2326
|
-
}
|
2327
|
-
break;
|
2328
|
-
// line 2330 "Parser.java"
|
2329
|
-
}
|
2330
|
-
}
|
2331
|
-
}
|
2332
|
-
|
2333
|
-
case 2:
|
2334
|
-
if ( cs == 0 ) {
|
2335
|
-
_goto_targ = 5;
|
2336
|
-
continue _goto;
|
2337
|
-
}
|
2338
|
-
if ( ++p != pe ) {
|
2339
|
-
_goto_targ = 1;
|
2340
|
-
continue _goto;
|
2341
|
-
}
|
2342
|
-
case 4:
|
2343
|
-
case 5:
|
2344
|
-
}
|
2345
|
-
break; }
|
2346
|
-
}
|
2347
|
-
|
2348
|
-
// line 879 "Parser.rl"
|
2349
|
-
|
2350
|
-
if (cs >= JSON_first_final && p == pe) {
|
2351
|
-
return result;
|
2352
|
-
} else {
|
2353
|
-
throw unexpectedToken(p, pe);
|
2354
|
-
}
|
2355
|
-
}
|
2356
|
-
|
2357
|
-
|
2358
|
-
// line 2360 "Parser.java"
|
2359
|
-
private static byte[] init__JSON_quirks_mode_actions_0()
|
2360
|
-
{
|
2361
|
-
return new byte [] {
|
2362
|
-
0, 1, 0
|
2363
|
-
};
|
2364
|
-
}
|
2365
|
-
|
2366
|
-
private static final byte _JSON_quirks_mode_actions[] = init__JSON_quirks_mode_actions_0();
|
2367
|
-
|
2368
|
-
|
2369
|
-
private static byte[] init__JSON_quirks_mode_key_offsets_0()
|
2370
|
-
{
|
2371
|
-
return new byte [] {
|
2372
|
-
0, 0, 16, 18, 19, 21, 22, 24, 25, 27, 28
|
2373
|
-
};
|
2374
|
-
}
|
2375
|
-
|
2376
|
-
private static final byte _JSON_quirks_mode_key_offsets[] = init__JSON_quirks_mode_key_offsets_0();
|
2377
|
-
|
2378
|
-
|
2379
|
-
private static char[] init__JSON_quirks_mode_trans_keys_0()
|
2380
|
-
{
|
2381
|
-
return new char [] {
|
2382
|
-
13, 32, 34, 45, 47, 73, 78, 91, 102, 110, 116, 123,
|
2383
|
-
9, 10, 48, 57, 42, 47, 42, 42, 47, 10, 42, 47,
|
2384
|
-
42, 42, 47, 10, 13, 32, 47, 9, 10, 0
|
2385
|
-
};
|
2386
|
-
}
|
2387
|
-
|
2388
|
-
private static final char _JSON_quirks_mode_trans_keys[] = init__JSON_quirks_mode_trans_keys_0();
|
2389
|
-
|
2390
|
-
|
2391
|
-
private static byte[] init__JSON_quirks_mode_single_lengths_0()
|
2392
|
-
{
|
2393
|
-
return new byte [] {
|
2394
|
-
0, 12, 2, 1, 2, 1, 2, 1, 2, 1, 3
|
2395
|
-
};
|
2396
|
-
}
|
2397
|
-
|
2398
|
-
private static final byte _JSON_quirks_mode_single_lengths[] = init__JSON_quirks_mode_single_lengths_0();
|
2399
|
-
|
2400
|
-
|
2401
|
-
private static byte[] init__JSON_quirks_mode_range_lengths_0()
|
2402
|
-
{
|
2403
|
-
return new byte [] {
|
2404
|
-
0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1
|
2405
|
-
};
|
2406
|
-
}
|
2407
|
-
|
2408
|
-
private static final byte _JSON_quirks_mode_range_lengths[] = init__JSON_quirks_mode_range_lengths_0();
|
2409
|
-
|
2410
|
-
|
2411
|
-
private static byte[] init__JSON_quirks_mode_index_offsets_0()
|
2412
|
-
{
|
2413
|
-
return new byte [] {
|
2414
|
-
0, 0, 15, 18, 20, 23, 25, 28, 30, 33, 35
|
2415
|
-
};
|
2416
|
-
}
|
2417
|
-
|
2418
|
-
private static final byte _JSON_quirks_mode_index_offsets[] = init__JSON_quirks_mode_index_offsets_0();
|
2419
|
-
|
2420
|
-
|
2421
|
-
private static byte[] init__JSON_quirks_mode_indicies_0()
|
2422
|
-
{
|
2423
|
-
return new byte [] {
|
2424
|
-
0, 0, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2,
|
2425
|
-
0, 2, 1, 4, 5, 1, 6, 4, 6, 7, 4, 7,
|
2426
|
-
5, 8, 9, 1, 10, 8, 10, 0, 8, 0, 9, 7,
|
2427
|
-
7, 11, 7, 1, 0
|
2428
|
-
};
|
2429
|
-
}
|
2430
|
-
|
2431
|
-
private static final byte _JSON_quirks_mode_indicies[] = init__JSON_quirks_mode_indicies_0();
|
2432
|
-
|
2433
|
-
|
2434
|
-
private static byte[] init__JSON_quirks_mode_trans_targs_0()
|
2435
|
-
{
|
2436
|
-
return new byte [] {
|
2437
|
-
1, 0, 10, 6, 3, 5, 4, 10, 7, 9, 8, 2
|
2438
|
-
};
|
2439
|
-
}
|
2440
|
-
|
2441
|
-
private static final byte _JSON_quirks_mode_trans_targs[] = init__JSON_quirks_mode_trans_targs_0();
|
2442
|
-
|
2443
|
-
|
2444
|
-
private static byte[] init__JSON_quirks_mode_trans_actions_0()
|
2445
|
-
{
|
2446
|
-
return new byte [] {
|
2447
|
-
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
2448
|
-
};
|
2449
|
-
}
|
2450
|
-
|
2451
|
-
private static final byte _JSON_quirks_mode_trans_actions[] = init__JSON_quirks_mode_trans_actions_0();
|
2452
|
-
|
2453
|
-
|
2454
|
-
static final int JSON_quirks_mode_start = 1;
|
2455
|
-
static final int JSON_quirks_mode_first_final = 10;
|
2456
|
-
static final int JSON_quirks_mode_error = 0;
|
2457
|
-
|
2458
|
-
static final int JSON_quirks_mode_en_main = 1;
|
2459
|
-
|
2460
|
-
|
2461
|
-
// line 907 "Parser.rl"
|
2462
|
-
|
2463
|
-
|
2464
|
-
public IRubyObject parseQuirksMode() {
|
2465
|
-
int cs = EVIL;
|
2466
|
-
int p, pe;
|
2467
|
-
IRubyObject result = null;
|
2468
|
-
ParserResult res = new ParserResult();
|
2469
|
-
|
2470
|
-
|
2471
|
-
// line 2473 "Parser.java"
|
2472
|
-
{
|
2473
|
-
cs = JSON_quirks_mode_start;
|
2474
|
-
}
|
2475
|
-
|
2476
|
-
// line 916 "Parser.rl"
|
2477
|
-
p = byteList.begin();
|
2478
|
-
pe = p + byteList.length();
|
2479
|
-
|
2480
|
-
// line 2482 "Parser.java"
|
2481
|
-
{
|
2482
|
-
int _klen;
|
2483
|
-
int _trans = 0;
|
2484
|
-
int _acts;
|
2485
|
-
int _nacts;
|
2486
|
-
int _keys;
|
2487
|
-
int _goto_targ = 0;
|
2488
|
-
|
2489
|
-
_goto: while (true) {
|
2490
|
-
switch ( _goto_targ ) {
|
2491
|
-
case 0:
|
2492
|
-
if ( p == pe ) {
|
2493
|
-
_goto_targ = 4;
|
2494
|
-
continue _goto;
|
2495
|
-
}
|
2496
|
-
if ( cs == 0 ) {
|
2497
|
-
_goto_targ = 5;
|
2498
|
-
continue _goto;
|
2499
|
-
}
|
2500
|
-
case 1:
|
2501
|
-
_match: do {
|
2502
|
-
_keys = _JSON_quirks_mode_key_offsets[cs];
|
2503
|
-
_trans = _JSON_quirks_mode_index_offsets[cs];
|
2504
|
-
_klen = _JSON_quirks_mode_single_lengths[cs];
|
2505
|
-
if ( _klen > 0 ) {
|
2506
|
-
int _lower = _keys;
|
2507
|
-
int _mid;
|
2508
|
-
int _upper = _keys + _klen - 1;
|
2509
|
-
while (true) {
|
2510
|
-
if ( _upper < _lower )
|
2511
|
-
break;
|
2512
|
-
|
2513
|
-
_mid = _lower + ((_upper-_lower) >> 1);
|
2514
|
-
if ( data[p] < _JSON_quirks_mode_trans_keys[_mid] )
|
2515
|
-
_upper = _mid - 1;
|
2516
|
-
else if ( data[p] > _JSON_quirks_mode_trans_keys[_mid] )
|
2517
|
-
_lower = _mid + 1;
|
2518
|
-
else {
|
2519
|
-
_trans += (_mid - _keys);
|
2520
|
-
break _match;
|
2521
|
-
}
|
2522
|
-
}
|
2523
|
-
_keys += _klen;
|
2524
|
-
_trans += _klen;
|
2525
|
-
}
|
2526
|
-
|
2527
|
-
_klen = _JSON_quirks_mode_range_lengths[cs];
|
2528
|
-
if ( _klen > 0 ) {
|
2529
|
-
int _lower = _keys;
|
2530
|
-
int _mid;
|
2531
|
-
int _upper = _keys + (_klen<<1) - 2;
|
2532
|
-
while (true) {
|
2533
|
-
if ( _upper < _lower )
|
2534
|
-
break;
|
2535
|
-
|
2536
|
-
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
|
2537
|
-
if ( data[p] < _JSON_quirks_mode_trans_keys[_mid] )
|
2538
|
-
_upper = _mid - 2;
|
2539
|
-
else if ( data[p] > _JSON_quirks_mode_trans_keys[_mid+1] )
|
2540
|
-
_lower = _mid + 2;
|
2541
|
-
else {
|
2542
|
-
_trans += ((_mid - _keys)>>1);
|
2543
|
-
break _match;
|
2544
|
-
}
|
2545
|
-
}
|
2546
|
-
_trans += _klen;
|
2547
|
-
}
|
2548
|
-
} while (false);
|
2549
|
-
|
2550
|
-
_trans = _JSON_quirks_mode_indicies[_trans];
|
2551
|
-
cs = _JSON_quirks_mode_trans_targs[_trans];
|
2552
|
-
|
2553
|
-
if ( _JSON_quirks_mode_trans_actions[_trans] != 0 ) {
|
2554
|
-
_acts = _JSON_quirks_mode_trans_actions[_trans];
|
2555
|
-
_nacts = (int) _JSON_quirks_mode_actions[_acts++];
|
2556
|
-
while ( _nacts-- > 0 )
|
2557
|
-
{
|
2558
|
-
switch ( _JSON_quirks_mode_actions[_acts++] )
|
2559
|
-
{
|
2560
|
-
case 0:
|
2561
|
-
// line 893 "Parser.rl"
|
2284
|
+
// line 822 "Parser.rl"
|
2562
2285
|
{
|
2563
2286
|
parseValue(res, p, pe);
|
2564
2287
|
if (res.result == null) {
|
@@ -2570,7 +2293,7 @@ case 1:
|
|
2570
2293
|
}
|
2571
2294
|
}
|
2572
2295
|
break;
|
2573
|
-
// line
|
2296
|
+
// line 2297 "Parser.java"
|
2574
2297
|
}
|
2575
2298
|
}
|
2576
2299
|
}
|
@@ -2590,9 +2313,9 @@ case 5:
|
|
2590
2313
|
break; }
|
2591
2314
|
}
|
2592
2315
|
|
2593
|
-
// line
|
2316
|
+
// line 848 "Parser.rl"
|
2594
2317
|
|
2595
|
-
if (cs >=
|
2318
|
+
if (cs >= JSON_first_final && p == pe) {
|
2596
2319
|
return result;
|
2597
2320
|
} else {
|
2598
2321
|
throw unexpectedToken(p, pe);
|
@@ -2600,12 +2323,7 @@ case 5:
|
|
2600
2323
|
}
|
2601
2324
|
|
2602
2325
|
public IRubyObject parse() {
|
2603
|
-
|
2604
|
-
return parseQuirksMode();
|
2605
|
-
} else {
|
2606
|
-
return parseStrict();
|
2607
|
-
}
|
2608
|
-
|
2326
|
+
return parseImplemetation();
|
2609
2327
|
}
|
2610
2328
|
|
2611
2329
|
/**
|