json 1.8.3 → 2.0.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.

Potentially problematic release.


This version of json might be problematic. Click here for more details.

Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -10
  3. data/CHANGES +12 -0
  4. data/Gemfile +1 -2
  5. data/{README.rdoc → README.md} +145 -111
  6. data/Rakefile +26 -29
  7. data/VERSION +1 -1
  8. data/ext/json/ext/generator/generator.c +38 -55
  9. data/ext/json/ext/generator/generator.h +7 -1
  10. data/ext/json/ext/parser/extconf.rb +3 -0
  11. data/ext/json/ext/parser/parser.c +309 -439
  12. data/ext/json/ext/parser/parser.h +0 -1
  13. data/ext/json/ext/parser/parser.rl +67 -160
  14. data/ext/json/extconf.rb +0 -1
  15. data/java/src/json/ext/ByteListTranscoder.java +1 -2
  16. data/java/src/json/ext/Generator.java +11 -12
  17. data/java/src/json/ext/GeneratorMethods.java +1 -2
  18. data/java/src/json/ext/GeneratorService.java +1 -2
  19. data/java/src/json/ext/GeneratorState.java +3 -56
  20. data/java/src/json/ext/OptionsReader.java +2 -3
  21. data/java/src/json/ext/Parser.java +110 -411
  22. data/java/src/json/ext/Parser.rl +25 -119
  23. data/java/src/json/ext/ParserService.java +1 -2
  24. data/java/src/json/ext/RuntimeInfo.java +1 -6
  25. data/java/src/json/ext/StringDecoder.java +1 -2
  26. data/java/src/json/ext/StringEncoder.java +5 -0
  27. data/java/src/json/ext/Utils.java +1 -2
  28. data/json-java.gemspec +15 -0
  29. data/json.gemspec +0 -0
  30. data/json_pure.gemspec +23 -26
  31. data/lib/json/add/bigdecimal.rb +1 -0
  32. data/lib/json/add/complex.rb +2 -1
  33. data/lib/json/add/core.rb +1 -0
  34. data/lib/json/add/date.rb +1 -1
  35. data/lib/json/add/date_time.rb +1 -1
  36. data/lib/json/add/exception.rb +1 -1
  37. data/lib/json/add/ostruct.rb +1 -1
  38. data/lib/json/add/range.rb +1 -1
  39. data/lib/json/add/rational.rb +1 -0
  40. data/lib/json/add/regexp.rb +1 -1
  41. data/lib/json/add/struct.rb +1 -1
  42. data/lib/json/add/symbol.rb +1 -1
  43. data/lib/json/add/time.rb +1 -1
  44. data/lib/json/common.rb +24 -52
  45. data/lib/json/ext.rb +0 -6
  46. data/lib/json/generic_object.rb +5 -4
  47. data/lib/json/pure/generator.rb +61 -125
  48. data/lib/json/pure/parser.rb +28 -80
  49. data/lib/json/pure.rb +2 -8
  50. data/lib/json/version.rb +2 -1
  51. data/lib/json.rb +1 -0
  52. data/references/rfc7159.txt +899 -0
  53. data/tests/fixtures/obsolete_fail1.json +1 -0
  54. data/tests/{test_json_addition.rb → json_addition_test.rb} +22 -25
  55. data/tests/json_common_interface_test.rb +126 -0
  56. data/tests/json_encoding_test.rb +105 -0
  57. data/tests/json_ext_parser_test.rb +15 -0
  58. data/tests/{test_json_fixtures.rb → json_fixtures_test.rb} +5 -8
  59. data/tests/{test_json_generate.rb → json_generator_test.rb} +76 -37
  60. data/tests/{test_json_generic_object.rb → json_generic_object_test.rb} +15 -8
  61. data/tests/json_parser_test.rb +448 -0
  62. data/tests/json_string_matching_test.rb +38 -0
  63. data/tests/test_helper.rb +23 -0
  64. data/tools/diff.sh +18 -0
  65. data/tools/fuzz.rb +1 -9
  66. metadata +27 -42
  67. data/COPYING +0 -58
  68. data/COPYING-json-jruby +0 -57
  69. data/GPL +0 -340
  70. data/TODO +0 -1
  71. data/tests/fixtures/fail1.json +0 -1
  72. data/tests/setup_variant.rb +0 -11
  73. data/tests/test_json.rb +0 -553
  74. data/tests/test_json_encoding.rb +0 -65
  75. data/tests/test_json_string_matching.rb +0 -39
  76. data/tests/test_json_unicode.rb +0 -72
@@ -3,8 +3,7 @@
3
3
  /*
4
4
  * This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
5
5
  *
6
- * Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
7
- * for details.
6
+ * Distributed under the Ruby license: https://www.ruby-lang.org/en/about/license.txt
8
7
  */
9
8
  package json.ext;
10
9
 
@@ -53,10 +52,9 @@ public class Parser extends RubyObject {
53
52
  private int maxNesting;
54
53
  private boolean allowNaN;
55
54
  private boolean symbolizeNames;
56
- private boolean quirksMode;
57
55
  private RubyClass objectClass;
58
56
  private RubyClass arrayClass;
59
- private RubyHash match_string;
57
+ private RubyHash matchString;
60
58
 
61
59
  private static final int DEFAULT_MAX_NESTING = 100;
62
60
 
@@ -124,10 +122,6 @@ public class Parser extends RubyObject {
124
122
  * <dd>If set to <code>true</code>, returns symbols for the names (keys) in
125
123
  * a JSON object. Otherwise strings are returned, which is also the default.
126
124
  *
127
- * <dt><code>:quirks_mode?</code>
128
- * <dd>If set to <code>true</code>, if the parse is in quirks_mode, false
129
- * otherwise.
130
- *
131
125
  * <dt><code>:create_additions</code>
132
126
  * <dd>If set to <code>false</code>, the Parser doesn't create additions
133
127
  * even if a matching class and <code>create_id</code> was found. This option
@@ -139,9 +133,6 @@ public class Parser extends RubyObject {
139
133
  * <dt><code>:array_class</code>
140
134
  * <dd>Defaults to Array.
141
135
  *
142
- * <dt><code>:quirks_mode</code>
143
- * <dd>Enables quirks_mode for parser, that is for example parsing single
144
- * JSON values instead of documents is possible.
145
136
  * </dl>
146
137
  */
147
138
  @JRubyMethod(name = "new", required = 1, optional = 1, meta = true)
@@ -164,15 +155,20 @@ public class Parser extends RubyObject {
164
155
  this.maxNesting = opts.getInt("max_nesting", DEFAULT_MAX_NESTING);
165
156
  this.allowNaN = opts.getBool("allow_nan", false);
166
157
  this.symbolizeNames = opts.getBool("symbolize_names", false);
167
- this.quirksMode = opts.getBool("quirks_mode", false);
168
158
  this.createId = opts.getString("create_id", getCreateId(context));
169
159
  this.createAdditions = opts.getBool("create_additions", false);
170
160
  this.objectClass = opts.getClass("object_class", runtime.getHash());
171
161
  this.arrayClass = opts.getClass("array_class", runtime.getArray());
172
- this.match_string = opts.getHash("match_string");
162
+ this.matchString = opts.getHash("match_string");
173
163
 
164
+ if(symbolizeNames && createAdditions) {
165
+ throw runtime.newArgumentError(
166
+ "options :symbolize_names and :create_additions cannot be " +
167
+ " used in conjunction"
168
+ );
169
+ }
174
170
  this.vSource = args[0].convertToString();
175
- if (!quirksMode) this.vSource = convertEncoding(context, vSource);
171
+ this.vSource = convertEncoding(context, vSource);
176
172
 
177
173
  return this;
178
174
  }
@@ -183,33 +179,13 @@ public class Parser extends RubyObject {
183
179
  * Returns the source string if no conversion is needed.
184
180
  */
185
181
  private RubyString convertEncoding(ThreadContext context, RubyString source) {
186
- ByteList bl = source.getByteList();
187
- int len = bl.length();
188
- if (len < 2) {
189
- throw Utils.newException(context, Utils.M_PARSER_ERROR,
190
- "A JSON text must at least contain two octets!");
191
- }
192
-
193
- if (info.encodingsSupported()) {
194
- RubyEncoding encoding = (RubyEncoding)source.encoding(context);
195
- if (encoding != info.ascii8bit.get()) {
196
- return (RubyString)source.encode(context, info.utf8.get());
197
- }
198
-
199
- String sniffedEncoding = sniffByteList(bl);
200
- if (sniffedEncoding == null) return source; // assume UTF-8
201
- return reinterpretEncoding(context, source, sniffedEncoding);
202
- }
203
-
204
- String sniffedEncoding = sniffByteList(bl);
205
- if (sniffedEncoding == null) return source; // assume UTF-8
206
- Ruby runtime = context.getRuntime();
207
- return (RubyString)info.jsonModule.get().
208
- callMethod(context, "iconv",
209
- new IRubyObject[] {
210
- runtime.newString("utf-8"),
211
- runtime.newString(sniffedEncoding),
212
- source});
182
+ RubyEncoding encoding = (RubyEncoding)source.encoding(context);
183
+ if (encoding == info.ascii8bit.get()) {
184
+ source.force_encoding(context, info.utf8.get());
185
+ } else {
186
+ source = (RubyString) source.encode(context, info.utf8.get());
187
+ }
188
+ return source;
213
189
  }
214
190
 
215
191
  /**
@@ -262,17 +238,6 @@ public class Parser extends RubyObject {
262
238
  return checkAndGetSource().dup();
263
239
  }
264
240
 
265
- /**
266
- * <code>Parser#quirks_mode?()</code>
267
- *
268
- * <p>If set to <code>true</code>, if the parse is in quirks_mode, false
269
- * otherwise.
270
- */
271
- @JRubyMethod(name = "quirks_mode?")
272
- public IRubyObject quirks_mode_p(ThreadContext context) {
273
- return context.getRuntime().newBoolean(quirksMode);
274
- }
275
-
276
241
  public RubyString checkAndGetSource() {
277
242
  if (vSource != null) {
278
243
  return vSource;
@@ -339,11 +304,11 @@ public class Parser extends RubyObject {
339
304
  }
340
305
 
341
306
 
342
- // line 365 "Parser.rl"
307
+ // line 330 "Parser.rl"
343
308
 
344
309
 
345
310
 
346
- // line 347 "Parser.java"
311
+ // line 312 "Parser.java"
347
312
  private static byte[] init__JSON_value_actions_0()
348
313
  {
349
314
  return new byte [] {
@@ -457,7 +422,7 @@ static final int JSON_value_error = 0;
457
422
  static final int JSON_value_en_main = 1;
458
423
 
459
424
 
460
- // line 471 "Parser.rl"
425
+ // line 436 "Parser.rl"
461
426
 
462
427
 
463
428
  void parseValue(ParserResult res, int p, int pe) {
@@ -465,14 +430,14 @@ static final int JSON_value_en_main = 1;
465
430
  IRubyObject result = null;
466
431
 
467
432
 
468
- // line 469 "Parser.java"
433
+ // line 434 "Parser.java"
469
434
  {
470
435
  cs = JSON_value_start;
471
436
  }
472
437
 
473
- // line 478 "Parser.rl"
438
+ // line 443 "Parser.rl"
474
439
 
475
- // line 476 "Parser.java"
440
+ // line 441 "Parser.java"
476
441
  {
477
442
  int _klen;
478
443
  int _trans = 0;
@@ -498,13 +463,13 @@ case 1:
498
463
  while ( _nacts-- > 0 ) {
499
464
  switch ( _JSON_value_actions[_acts++] ) {
500
465
  case 9:
501
- // line 456 "Parser.rl"
466
+ // line 421 "Parser.rl"
502
467
  {
503
468
  p--;
504
469
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
505
470
  }
506
471
  break;
507
- // line 508 "Parser.java"
472
+ // line 473 "Parser.java"
508
473
  }
509
474
  }
510
475
 
@@ -567,25 +532,25 @@ case 1:
567
532
  switch ( _JSON_value_actions[_acts++] )
568
533
  {
569
534
  case 0:
570
- // line 373 "Parser.rl"
535
+ // line 338 "Parser.rl"
571
536
  {
572
537
  result = getRuntime().getNil();
573
538
  }
574
539
  break;
575
540
  case 1:
576
- // line 376 "Parser.rl"
541
+ // line 341 "Parser.rl"
577
542
  {
578
543
  result = getRuntime().getFalse();
579
544
  }
580
545
  break;
581
546
  case 2:
582
- // line 379 "Parser.rl"
547
+ // line 344 "Parser.rl"
583
548
  {
584
549
  result = getRuntime().getTrue();
585
550
  }
586
551
  break;
587
552
  case 3:
588
- // line 382 "Parser.rl"
553
+ // line 347 "Parser.rl"
589
554
  {
590
555
  if (parser.allowNaN) {
591
556
  result = getConstant(CONST_NAN);
@@ -595,7 +560,7 @@ case 1:
595
560
  }
596
561
  break;
597
562
  case 4:
598
- // line 389 "Parser.rl"
563
+ // line 354 "Parser.rl"
599
564
  {
600
565
  if (parser.allowNaN) {
601
566
  result = getConstant(CONST_INFINITY);
@@ -605,9 +570,9 @@ case 1:
605
570
  }
606
571
  break;
607
572
  case 5:
608
- // line 396 "Parser.rl"
573
+ // line 361 "Parser.rl"
609
574
  {
610
- if (pe > p + 9 - (parser.quirksMode ? 1 : 0) &&
575
+ if (pe > p + 8 &&
611
576
  absSubSequence(p, p + 9).equals(JSON_MINUS_INFINITY)) {
612
577
 
613
578
  if (parser.allowNaN) {
@@ -634,7 +599,7 @@ case 1:
634
599
  }
635
600
  break;
636
601
  case 6:
637
- // line 422 "Parser.rl"
602
+ // line 387 "Parser.rl"
638
603
  {
639
604
  parseString(res, p, pe);
640
605
  if (res.result == null) {
@@ -647,7 +612,7 @@ case 1:
647
612
  }
648
613
  break;
649
614
  case 7:
650
- // line 432 "Parser.rl"
615
+ // line 397 "Parser.rl"
651
616
  {
652
617
  currentNesting++;
653
618
  parseArray(res, p, pe);
@@ -662,7 +627,7 @@ case 1:
662
627
  }
663
628
  break;
664
629
  case 8:
665
- // line 444 "Parser.rl"
630
+ // line 409 "Parser.rl"
666
631
  {
667
632
  currentNesting++;
668
633
  parseObject(res, p, pe);
@@ -676,7 +641,7 @@ case 1:
676
641
  }
677
642
  }
678
643
  break;
679
- // line 680 "Parser.java"
644
+ // line 645 "Parser.java"
680
645
  }
681
646
  }
682
647
  }
@@ -696,7 +661,7 @@ case 5:
696
661
  break; }
697
662
  }
698
663
 
699
- // line 479 "Parser.rl"
664
+ // line 444 "Parser.rl"
700
665
 
701
666
  if (cs >= JSON_value_first_final && result != null) {
702
667
  res.update(result, p);
@@ -706,7 +671,7 @@ case 5:
706
671
  }
707
672
 
708
673
 
709
- // line 710 "Parser.java"
674
+ // line 675 "Parser.java"
710
675
  private static byte[] init__JSON_integer_actions_0()
711
676
  {
712
677
  return new byte [] {
@@ -805,7 +770,7 @@ static final int JSON_integer_error = 0;
805
770
  static final int JSON_integer_en_main = 1;
806
771
 
807
772
 
808
- // line 498 "Parser.rl"
773
+ // line 463 "Parser.rl"
809
774
 
810
775
 
811
776
  void parseInteger(ParserResult res, int p, int pe) {
@@ -823,15 +788,15 @@ static final int JSON_integer_en_main = 1;
823
788
  int cs = EVIL;
824
789
 
825
790
 
826
- // line 827 "Parser.java"
791
+ // line 792 "Parser.java"
827
792
  {
828
793
  cs = JSON_integer_start;
829
794
  }
830
795
 
831
- // line 515 "Parser.rl"
796
+ // line 480 "Parser.rl"
832
797
  int memo = p;
833
798
 
834
- // line 835 "Parser.java"
799
+ // line 800 "Parser.java"
835
800
  {
836
801
  int _klen;
837
802
  int _trans = 0;
@@ -912,13 +877,13 @@ case 1:
912
877
  switch ( _JSON_integer_actions[_acts++] )
913
878
  {
914
879
  case 0:
915
- // line 492 "Parser.rl"
880
+ // line 457 "Parser.rl"
916
881
  {
917
882
  p--;
918
883
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
919
884
  }
920
885
  break;
921
- // line 922 "Parser.java"
886
+ // line 887 "Parser.java"
922
887
  }
923
888
  }
924
889
  }
@@ -938,7 +903,7 @@ case 5:
938
903
  break; }
939
904
  }
940
905
 
941
- // line 517 "Parser.rl"
906
+ // line 482 "Parser.rl"
942
907
 
943
908
  if (cs < JSON_integer_first_final) {
944
909
  return -1;
@@ -960,7 +925,7 @@ case 5:
960
925
  }
961
926
 
962
927
 
963
- // line 964 "Parser.java"
928
+ // line 929 "Parser.java"
964
929
  private static byte[] init__JSON_float_actions_0()
965
930
  {
966
931
  return new byte [] {
@@ -1062,7 +1027,7 @@ static final int JSON_float_error = 0;
1062
1027
  static final int JSON_float_en_main = 1;
1063
1028
 
1064
1029
 
1065
- // line 552 "Parser.rl"
1030
+ // line 517 "Parser.rl"
1066
1031
 
1067
1032
 
1068
1033
  void parseFloat(ParserResult res, int p, int pe) {
@@ -1080,15 +1045,15 @@ static final int JSON_float_en_main = 1;
1080
1045
  int cs = EVIL;
1081
1046
 
1082
1047
 
1083
- // line 1084 "Parser.java"
1048
+ // line 1049 "Parser.java"
1084
1049
  {
1085
1050
  cs = JSON_float_start;
1086
1051
  }
1087
1052
 
1088
- // line 569 "Parser.rl"
1053
+ // line 534 "Parser.rl"
1089
1054
  int memo = p;
1090
1055
 
1091
- // line 1092 "Parser.java"
1056
+ // line 1057 "Parser.java"
1092
1057
  {
1093
1058
  int _klen;
1094
1059
  int _trans = 0;
@@ -1169,13 +1134,13 @@ case 1:
1169
1134
  switch ( _JSON_float_actions[_acts++] )
1170
1135
  {
1171
1136
  case 0:
1172
- // line 543 "Parser.rl"
1137
+ // line 508 "Parser.rl"
1173
1138
  {
1174
1139
  p--;
1175
1140
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
1176
1141
  }
1177
1142
  break;
1178
- // line 1179 "Parser.java"
1143
+ // line 1144 "Parser.java"
1179
1144
  }
1180
1145
  }
1181
1146
  }
@@ -1195,7 +1160,7 @@ case 5:
1195
1160
  break; }
1196
1161
  }
1197
1162
 
1198
- // line 571 "Parser.rl"
1163
+ // line 536 "Parser.rl"
1199
1164
 
1200
1165
  if (cs < JSON_float_first_final) {
1201
1166
  return -1;
@@ -1211,7 +1176,7 @@ case 5:
1211
1176
  }
1212
1177
 
1213
1178
 
1214
- // line 1215 "Parser.java"
1179
+ // line 1180 "Parser.java"
1215
1180
  private static byte[] init__JSON_string_actions_0()
1216
1181
  {
1217
1182
  return new byte [] {
@@ -1313,7 +1278,7 @@ static final int JSON_string_error = 0;
1313
1278
  static final int JSON_string_en_main = 1;
1314
1279
 
1315
1280
 
1316
- // line 616 "Parser.rl"
1281
+ // line 581 "Parser.rl"
1317
1282
 
1318
1283
 
1319
1284
  void parseString(ParserResult res, int p, int pe) {
@@ -1321,15 +1286,15 @@ static final int JSON_string_en_main = 1;
1321
1286
  IRubyObject result = null;
1322
1287
 
1323
1288
 
1324
- // line 1325 "Parser.java"
1289
+ // line 1290 "Parser.java"
1325
1290
  {
1326
1291
  cs = JSON_string_start;
1327
1292
  }
1328
1293
 
1329
- // line 623 "Parser.rl"
1294
+ // line 588 "Parser.rl"
1330
1295
  int memo = p;
1331
1296
 
1332
- // line 1333 "Parser.java"
1297
+ // line 1298 "Parser.java"
1333
1298
  {
1334
1299
  int _klen;
1335
1300
  int _trans = 0;
@@ -1410,7 +1375,7 @@ case 1:
1410
1375
  switch ( _JSON_string_actions[_acts++] )
1411
1376
  {
1412
1377
  case 0:
1413
- // line 591 "Parser.rl"
1378
+ // line 556 "Parser.rl"
1414
1379
  {
1415
1380
  int offset = byteList.begin();
1416
1381
  ByteList decoded = decoder.decode(byteList, memo + 1 - offset,
@@ -1425,13 +1390,13 @@ case 1:
1425
1390
  }
1426
1391
  break;
1427
1392
  case 1:
1428
- // line 604 "Parser.rl"
1393
+ // line 569 "Parser.rl"
1429
1394
  {
1430
1395
  p--;
1431
1396
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
1432
1397
  }
1433
1398
  break;
1434
- // line 1435 "Parser.java"
1399
+ // line 1400 "Parser.java"
1435
1400
  }
1436
1401
  }
1437
1402
  }
@@ -1451,14 +1416,14 @@ case 5:
1451
1416
  break; }
1452
1417
  }
1453
1418
 
1454
- // line 625 "Parser.rl"
1419
+ // line 590 "Parser.rl"
1455
1420
 
1456
1421
  if (parser.createAdditions) {
1457
- RubyHash match_string = parser.match_string;
1458
- if (match_string != null) {
1422
+ RubyHash matchString = parser.matchString;
1423
+ if (matchString != null) {
1459
1424
  final IRubyObject[] memoArray = { result, null };
1460
1425
  try {
1461
- match_string.visitAll(new RubyHash.Visitor() {
1426
+ matchString.visitAll(new RubyHash.Visitor() {
1462
1427
  @Override
1463
1428
  public void visit(IRubyObject pattern, IRubyObject klass) {
1464
1429
  if (pattern.callMethod(context, "===", memoArray[0]).isTrue()) {
@@ -1479,7 +1444,7 @@ case 5:
1479
1444
  }
1480
1445
 
1481
1446
  if (cs >= JSON_string_first_final && result != null) {
1482
- if (info.encodingsSupported() && result instanceof RubyString) {
1447
+ if (result instanceof RubyString) {
1483
1448
  ((RubyString)result).force_encoding(context, info.utf8.get());
1484
1449
  }
1485
1450
  res.update(result, p + 1);
@@ -1489,7 +1454,7 @@ case 5:
1489
1454
  }
1490
1455
 
1491
1456
 
1492
- // line 1493 "Parser.java"
1457
+ // line 1458 "Parser.java"
1493
1458
  private static byte[] init__JSON_array_actions_0()
1494
1459
  {
1495
1460
  return new byte [] {
@@ -1602,7 +1567,7 @@ static final int JSON_array_error = 0;
1602
1567
  static final int JSON_array_en_main = 1;
1603
1568
 
1604
1569
 
1605
- // line 698 "Parser.rl"
1570
+ // line 663 "Parser.rl"
1606
1571
 
1607
1572
 
1608
1573
  void parseArray(ParserResult res, int p, int pe) {
@@ -1622,14 +1587,14 @@ static final int JSON_array_en_main = 1;
1622
1587
  }
1623
1588
 
1624
1589
 
1625
- // line 1626 "Parser.java"
1590
+ // line 1591 "Parser.java"
1626
1591
  {
1627
1592
  cs = JSON_array_start;
1628
1593
  }
1629
1594
 
1630
- // line 717 "Parser.rl"
1595
+ // line 682 "Parser.rl"
1631
1596
 
1632
- // line 1633 "Parser.java"
1597
+ // line 1598 "Parser.java"
1633
1598
  {
1634
1599
  int _klen;
1635
1600
  int _trans = 0;
@@ -1710,7 +1675,7 @@ case 1:
1710
1675
  switch ( _JSON_array_actions[_acts++] )
1711
1676
  {
1712
1677
  case 0:
1713
- // line 667 "Parser.rl"
1678
+ // line 632 "Parser.rl"
1714
1679
  {
1715
1680
  parseValue(res, p, pe);
1716
1681
  if (res.result == null) {
@@ -1727,13 +1692,13 @@ case 1:
1727
1692
  }
1728
1693
  break;
1729
1694
  case 1:
1730
- // line 682 "Parser.rl"
1695
+ // line 647 "Parser.rl"
1731
1696
  {
1732
1697
  p--;
1733
1698
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
1734
1699
  }
1735
1700
  break;
1736
- // line 1737 "Parser.java"
1701
+ // line 1702 "Parser.java"
1737
1702
  }
1738
1703
  }
1739
1704
  }
@@ -1753,7 +1718,7 @@ case 5:
1753
1718
  break; }
1754
1719
  }
1755
1720
 
1756
- // line 718 "Parser.rl"
1721
+ // line 683 "Parser.rl"
1757
1722
 
1758
1723
  if (cs >= JSON_array_first_final) {
1759
1724
  res.update(result, p + 1);
@@ -1763,7 +1728,7 @@ case 5:
1763
1728
  }
1764
1729
 
1765
1730
 
1766
- // line 1767 "Parser.java"
1731
+ // line 1732 "Parser.java"
1767
1732
  private static byte[] init__JSON_object_actions_0()
1768
1733
  {
1769
1734
  return new byte [] {
@@ -1886,7 +1851,7 @@ static final int JSON_object_error = 0;
1886
1851
  static final int JSON_object_en_main = 1;
1887
1852
 
1888
1853
 
1889
- // line 777 "Parser.rl"
1854
+ // line 742 "Parser.rl"
1890
1855
 
1891
1856
 
1892
1857
  void parseObject(ParserResult res, int p, int pe) {
@@ -1911,14 +1876,14 @@ static final int JSON_object_en_main = 1;
1911
1876
  }
1912
1877
 
1913
1878
 
1914
- // line 1915 "Parser.java"
1879
+ // line 1880 "Parser.java"
1915
1880
  {
1916
1881
  cs = JSON_object_start;
1917
1882
  }
1918
1883
 
1919
- // line 801 "Parser.rl"
1884
+ // line 766 "Parser.rl"
1920
1885
 
1921
- // line 1922 "Parser.java"
1886
+ // line 1887 "Parser.java"
1922
1887
  {
1923
1888
  int _klen;
1924
1889
  int _trans = 0;
@@ -1999,7 +1964,7 @@ case 1:
1999
1964
  switch ( _JSON_object_actions[_acts++] )
2000
1965
  {
2001
1966
  case 0:
2002
- // line 732 "Parser.rl"
1967
+ // line 697 "Parser.rl"
2003
1968
  {
2004
1969
  parseValue(res, p, pe);
2005
1970
  if (res.result == null) {
@@ -2016,7 +1981,7 @@ case 1:
2016
1981
  }
2017
1982
  break;
2018
1983
  case 1:
2019
- // line 747 "Parser.rl"
1984
+ // line 712 "Parser.rl"
2020
1985
  {
2021
1986
  parseString(res, p, pe);
2022
1987
  if (res.result == null) {
@@ -2036,13 +2001,13 @@ case 1:
2036
2001
  }
2037
2002
  break;
2038
2003
  case 2:
2039
- // line 765 "Parser.rl"
2004
+ // line 730 "Parser.rl"
2040
2005
  {
2041
2006
  p--;
2042
2007
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
2043
2008
  }
2044
2009
  break;
2045
- // line 2046 "Parser.java"
2010
+ // line 2011 "Parser.java"
2046
2011
  }
2047
2012
  }
2048
2013
  }
@@ -2062,7 +2027,7 @@ case 5:
2062
2027
  break; }
2063
2028
  }
2064
2029
 
2065
- // line 802 "Parser.rl"
2030
+ // line 767 "Parser.rl"
2066
2031
 
2067
2032
  if (cs < JSON_object_first_final) {
2068
2033
  res.update(null, p + 1);
@@ -2095,11 +2060,11 @@ case 5:
2095
2060
  }
2096
2061
 
2097
2062
 
2098
- // line 2099 "Parser.java"
2063
+ // line 2064 "Parser.java"
2099
2064
  private static byte[] init__JSON_actions_0()
2100
2065
  {
2101
2066
  return new byte [] {
2102
- 0, 1, 0, 1, 1
2067
+ 0, 1, 0
2103
2068
  };
2104
2069
  }
2105
2070
 
@@ -2109,7 +2074,7 @@ private static final byte _JSON_actions[] = init__JSON_actions_0();
2109
2074
  private static byte[] init__JSON_key_offsets_0()
2110
2075
  {
2111
2076
  return new byte [] {
2112
- 0, 0, 7, 9, 10, 12, 13, 15, 16, 18, 19
2077
+ 0, 0, 16, 18, 19, 21, 22, 24, 25, 27, 28
2113
2078
  };
2114
2079
  }
2115
2080
 
@@ -2119,9 +2084,9 @@ private static final byte _JSON_key_offsets[] = init__JSON_key_offsets_0();
2119
2084
  private static char[] init__JSON_trans_keys_0()
2120
2085
  {
2121
2086
  return new char [] {
2122
- 13, 32, 47, 91, 123, 9, 10, 42, 47, 42, 42, 47,
2123
- 10, 42, 47, 42, 42, 47, 10, 13, 32, 47, 9, 10,
2124
- 0
2087
+ 13, 32, 34, 45, 47, 73, 78, 91, 102, 110, 116, 123,
2088
+ 9, 10, 48, 57, 42, 47, 42, 42, 47, 10, 42, 47,
2089
+ 42, 42, 47, 10, 13, 32, 47, 9, 10, 0
2125
2090
  };
2126
2091
  }
2127
2092
 
@@ -2131,7 +2096,7 @@ private static final char _JSON_trans_keys[] = init__JSON_trans_keys_0();
2131
2096
  private static byte[] init__JSON_single_lengths_0()
2132
2097
  {
2133
2098
  return new byte [] {
2134
- 0, 5, 2, 1, 2, 1, 2, 1, 2, 1, 3
2099
+ 0, 12, 2, 1, 2, 1, 2, 1, 2, 1, 3
2135
2100
  };
2136
2101
  }
2137
2102
 
@@ -2141,7 +2106,7 @@ private static final byte _JSON_single_lengths[] = init__JSON_single_lengths_0()
2141
2106
  private static byte[] init__JSON_range_lengths_0()
2142
2107
  {
2143
2108
  return new byte [] {
2144
- 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
2109
+ 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1
2145
2110
  };
2146
2111
  }
2147
2112
 
@@ -2151,7 +2116,7 @@ private static final byte _JSON_range_lengths[] = init__JSON_range_lengths_0();
2151
2116
  private static byte[] init__JSON_index_offsets_0()
2152
2117
  {
2153
2118
  return new byte [] {
2154
- 0, 0, 7, 10, 12, 15, 17, 20, 22, 25, 27
2119
+ 0, 0, 15, 18, 20, 23, 25, 28, 30, 33, 35
2155
2120
  };
2156
2121
  }
2157
2122
 
@@ -2161,9 +2126,10 @@ private static final byte _JSON_index_offsets[] = init__JSON_index_offsets_0();
2161
2126
  private static byte[] init__JSON_indicies_0()
2162
2127
  {
2163
2128
  return new byte [] {
2164
- 0, 0, 2, 3, 4, 0, 1, 5, 6, 1, 7, 5,
2165
- 7, 0, 5, 0, 6, 8, 9, 1, 10, 8, 10, 11,
2166
- 8, 11, 9, 11, 11, 12, 11, 1, 0
2129
+ 0, 0, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2,
2130
+ 0, 2, 1, 4, 5, 1, 6, 4, 6, 7, 4, 7,
2131
+ 5, 8, 9, 1, 10, 8, 10, 0, 8, 0, 9, 7,
2132
+ 7, 11, 7, 1, 0
2167
2133
  };
2168
2134
  }
2169
2135
 
@@ -2173,8 +2139,7 @@ private static final byte _JSON_indicies[] = init__JSON_indicies_0();
2173
2139
  private static byte[] init__JSON_trans_targs_0()
2174
2140
  {
2175
2141
  return new byte [] {
2176
- 1, 0, 2, 10, 10, 3, 5, 4, 7, 9, 8, 10,
2177
- 6
2142
+ 1, 0, 10, 6, 3, 5, 4, 10, 7, 9, 8, 2
2178
2143
  };
2179
2144
  }
2180
2145
 
@@ -2184,8 +2149,7 @@ private static final byte _JSON_trans_targs[] = init__JSON_trans_targs_0();
2184
2149
  private static byte[] init__JSON_trans_actions_0()
2185
2150
  {
2186
2151
  return new byte [] {
2187
- 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0,
2188
- 0
2152
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
2189
2153
  };
2190
2154
  }
2191
2155
 
@@ -2199,26 +2163,26 @@ static final int JSON_error = 0;
2199
2163
  static final int JSON_en_main = 1;
2200
2164
 
2201
2165
 
2202
- // line 867 "Parser.rl"
2166
+ // line 818 "Parser.rl"
2203
2167
 
2204
2168
 
2205
- public IRubyObject parseStrict() {
2169
+ public IRubyObject parseImplemetation() {
2206
2170
  int cs = EVIL;
2207
2171
  int p, pe;
2208
2172
  IRubyObject result = null;
2209
2173
  ParserResult res = new ParserResult();
2210
2174
 
2211
2175
 
2212
- // line 2213 "Parser.java"
2176
+ // line 2177 "Parser.java"
2213
2177
  {
2214
2178
  cs = JSON_start;
2215
2179
  }
2216
2180
 
2217
- // line 876 "Parser.rl"
2181
+ // line 827 "Parser.rl"
2218
2182
  p = byteList.begin();
2219
2183
  pe = p + byteList.length();
2220
2184
 
2221
- // line 2222 "Parser.java"
2185
+ // line 2186 "Parser.java"
2222
2186
  {
2223
2187
  int _klen;
2224
2188
  int _trans = 0;
@@ -2299,267 +2263,7 @@ case 1:
2299
2263
  switch ( _JSON_actions[_acts++] )
2300
2264
  {
2301
2265
  case 0:
2302
- // line 839 "Parser.rl"
2303
- {
2304
- currentNesting = 1;
2305
- parseObject(res, p, pe);
2306
- if (res.result == null) {
2307
- p--;
2308
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
2309
- } else {
2310
- result = res.result;
2311
- {p = (( res.p))-1;}
2312
- }
2313
- }
2314
- break;
2315
- case 1:
2316
- // line 851 "Parser.rl"
2317
- {
2318
- currentNesting = 1;
2319
- parseArray(res, p, pe);
2320
- if (res.result == null) {
2321
- p--;
2322
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
2323
- } else {
2324
- result = res.result;
2325
- {p = (( res.p))-1;}
2326
- }
2327
- }
2328
- break;
2329
- // line 2330 "Parser.java"
2330
- }
2331
- }
2332
- }
2333
-
2334
- case 2:
2335
- if ( cs == 0 ) {
2336
- _goto_targ = 5;
2337
- continue _goto;
2338
- }
2339
- if ( ++p != pe ) {
2340
- _goto_targ = 1;
2341
- continue _goto;
2342
- }
2343
- case 4:
2344
- case 5:
2345
- }
2346
- break; }
2347
- }
2348
-
2349
- // line 879 "Parser.rl"
2350
-
2351
- if (cs >= JSON_first_final && p == pe) {
2352
- return result;
2353
- } else {
2354
- throw unexpectedToken(p, pe);
2355
- }
2356
- }
2357
-
2358
-
2359
- // line 2360 "Parser.java"
2360
- private static byte[] init__JSON_quirks_mode_actions_0()
2361
- {
2362
- return new byte [] {
2363
- 0, 1, 0
2364
- };
2365
- }
2366
-
2367
- private static final byte _JSON_quirks_mode_actions[] = init__JSON_quirks_mode_actions_0();
2368
-
2369
-
2370
- private static byte[] init__JSON_quirks_mode_key_offsets_0()
2371
- {
2372
- return new byte [] {
2373
- 0, 0, 16, 18, 19, 21, 22, 24, 25, 27, 28
2374
- };
2375
- }
2376
-
2377
- private static final byte _JSON_quirks_mode_key_offsets[] = init__JSON_quirks_mode_key_offsets_0();
2378
-
2379
-
2380
- private static char[] init__JSON_quirks_mode_trans_keys_0()
2381
- {
2382
- return new char [] {
2383
- 13, 32, 34, 45, 47, 73, 78, 91, 102, 110, 116, 123,
2384
- 9, 10, 48, 57, 42, 47, 42, 42, 47, 10, 42, 47,
2385
- 42, 42, 47, 10, 13, 32, 47, 9, 10, 0
2386
- };
2387
- }
2388
-
2389
- private static final char _JSON_quirks_mode_trans_keys[] = init__JSON_quirks_mode_trans_keys_0();
2390
-
2391
-
2392
- private static byte[] init__JSON_quirks_mode_single_lengths_0()
2393
- {
2394
- return new byte [] {
2395
- 0, 12, 2, 1, 2, 1, 2, 1, 2, 1, 3
2396
- };
2397
- }
2398
-
2399
- private static final byte _JSON_quirks_mode_single_lengths[] = init__JSON_quirks_mode_single_lengths_0();
2400
-
2401
-
2402
- private static byte[] init__JSON_quirks_mode_range_lengths_0()
2403
- {
2404
- return new byte [] {
2405
- 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1
2406
- };
2407
- }
2408
-
2409
- private static final byte _JSON_quirks_mode_range_lengths[] = init__JSON_quirks_mode_range_lengths_0();
2410
-
2411
-
2412
- private static byte[] init__JSON_quirks_mode_index_offsets_0()
2413
- {
2414
- return new byte [] {
2415
- 0, 0, 15, 18, 20, 23, 25, 28, 30, 33, 35
2416
- };
2417
- }
2418
-
2419
- private static final byte _JSON_quirks_mode_index_offsets[] = init__JSON_quirks_mode_index_offsets_0();
2420
-
2421
-
2422
- private static byte[] init__JSON_quirks_mode_indicies_0()
2423
- {
2424
- return new byte [] {
2425
- 0, 0, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2,
2426
- 0, 2, 1, 4, 5, 1, 6, 4, 6, 7, 4, 7,
2427
- 5, 8, 9, 1, 10, 8, 10, 0, 8, 0, 9, 7,
2428
- 7, 11, 7, 1, 0
2429
- };
2430
- }
2431
-
2432
- private static final byte _JSON_quirks_mode_indicies[] = init__JSON_quirks_mode_indicies_0();
2433
-
2434
-
2435
- private static byte[] init__JSON_quirks_mode_trans_targs_0()
2436
- {
2437
- return new byte [] {
2438
- 1, 0, 10, 6, 3, 5, 4, 10, 7, 9, 8, 2
2439
- };
2440
- }
2441
-
2442
- private static final byte _JSON_quirks_mode_trans_targs[] = init__JSON_quirks_mode_trans_targs_0();
2443
-
2444
-
2445
- private static byte[] init__JSON_quirks_mode_trans_actions_0()
2446
- {
2447
- return new byte [] {
2448
- 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
2449
- };
2450
- }
2451
-
2452
- private static final byte _JSON_quirks_mode_trans_actions[] = init__JSON_quirks_mode_trans_actions_0();
2453
-
2454
-
2455
- static final int JSON_quirks_mode_start = 1;
2456
- static final int JSON_quirks_mode_first_final = 10;
2457
- static final int JSON_quirks_mode_error = 0;
2458
-
2459
- static final int JSON_quirks_mode_en_main = 1;
2460
-
2461
-
2462
- // line 907 "Parser.rl"
2463
-
2464
-
2465
- public IRubyObject parseQuirksMode() {
2466
- int cs = EVIL;
2467
- int p, pe;
2468
- IRubyObject result = null;
2469
- ParserResult res = new ParserResult();
2470
-
2471
-
2472
- // line 2473 "Parser.java"
2473
- {
2474
- cs = JSON_quirks_mode_start;
2475
- }
2476
-
2477
- // line 916 "Parser.rl"
2478
- p = byteList.begin();
2479
- pe = p + byteList.length();
2480
-
2481
- // line 2482 "Parser.java"
2482
- {
2483
- int _klen;
2484
- int _trans = 0;
2485
- int _acts;
2486
- int _nacts;
2487
- int _keys;
2488
- int _goto_targ = 0;
2489
-
2490
- _goto: while (true) {
2491
- switch ( _goto_targ ) {
2492
- case 0:
2493
- if ( p == pe ) {
2494
- _goto_targ = 4;
2495
- continue _goto;
2496
- }
2497
- if ( cs == 0 ) {
2498
- _goto_targ = 5;
2499
- continue _goto;
2500
- }
2501
- case 1:
2502
- _match: do {
2503
- _keys = _JSON_quirks_mode_key_offsets[cs];
2504
- _trans = _JSON_quirks_mode_index_offsets[cs];
2505
- _klen = _JSON_quirks_mode_single_lengths[cs];
2506
- if ( _klen > 0 ) {
2507
- int _lower = _keys;
2508
- int _mid;
2509
- int _upper = _keys + _klen - 1;
2510
- while (true) {
2511
- if ( _upper < _lower )
2512
- break;
2513
-
2514
- _mid = _lower + ((_upper-_lower) >> 1);
2515
- if ( data[p] < _JSON_quirks_mode_trans_keys[_mid] )
2516
- _upper = _mid - 1;
2517
- else if ( data[p] > _JSON_quirks_mode_trans_keys[_mid] )
2518
- _lower = _mid + 1;
2519
- else {
2520
- _trans += (_mid - _keys);
2521
- break _match;
2522
- }
2523
- }
2524
- _keys += _klen;
2525
- _trans += _klen;
2526
- }
2527
-
2528
- _klen = _JSON_quirks_mode_range_lengths[cs];
2529
- if ( _klen > 0 ) {
2530
- int _lower = _keys;
2531
- int _mid;
2532
- int _upper = _keys + (_klen<<1) - 2;
2533
- while (true) {
2534
- if ( _upper < _lower )
2535
- break;
2536
-
2537
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
2538
- if ( data[p] < _JSON_quirks_mode_trans_keys[_mid] )
2539
- _upper = _mid - 2;
2540
- else if ( data[p] > _JSON_quirks_mode_trans_keys[_mid+1] )
2541
- _lower = _mid + 2;
2542
- else {
2543
- _trans += ((_mid - _keys)>>1);
2544
- break _match;
2545
- }
2546
- }
2547
- _trans += _klen;
2548
- }
2549
- } while (false);
2550
-
2551
- _trans = _JSON_quirks_mode_indicies[_trans];
2552
- cs = _JSON_quirks_mode_trans_targs[_trans];
2553
-
2554
- if ( _JSON_quirks_mode_trans_actions[_trans] != 0 ) {
2555
- _acts = _JSON_quirks_mode_trans_actions[_trans];
2556
- _nacts = (int) _JSON_quirks_mode_actions[_acts++];
2557
- while ( _nacts-- > 0 )
2558
- {
2559
- switch ( _JSON_quirks_mode_actions[_acts++] )
2560
- {
2561
- case 0:
2562
- // line 893 "Parser.rl"
2266
+ // line 804 "Parser.rl"
2563
2267
  {
2564
2268
  parseValue(res, p, pe);
2565
2269
  if (res.result == null) {
@@ -2571,7 +2275,7 @@ case 1:
2571
2275
  }
2572
2276
  }
2573
2277
  break;
2574
- // line 2575 "Parser.java"
2278
+ // line 2279 "Parser.java"
2575
2279
  }
2576
2280
  }
2577
2281
  }
@@ -2591,9 +2295,9 @@ case 5:
2591
2295
  break; }
2592
2296
  }
2593
2297
 
2594
- // line 919 "Parser.rl"
2298
+ // line 830 "Parser.rl"
2595
2299
 
2596
- if (cs >= JSON_quirks_mode_first_final && p == pe) {
2300
+ if (cs >= JSON_first_final && p == pe) {
2597
2301
  return result;
2598
2302
  } else {
2599
2303
  throw unexpectedToken(p, pe);
@@ -2601,12 +2305,7 @@ case 5:
2601
2305
  }
2602
2306
 
2603
2307
  public IRubyObject parse() {
2604
- if (parser.quirksMode) {
2605
- return parseQuirksMode();
2606
- } else {
2607
- return parseStrict();
2608
- }
2609
-
2308
+ return parseImplemetation();
2610
2309
  }
2611
2310
 
2612
2311
  /**