json-maglev- 1.5.4 → 1.6.1

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.
Files changed (57) hide show
  1. data/CHANGES +11 -1
  2. data/Rakefile +14 -12
  3. data/VERSION +1 -1
  4. data/ext/json/ext/generator/extconf.rb +0 -7
  5. data/ext/json/ext/generator/generator.c +55 -10
  6. data/ext/json/ext/generator/generator.h +7 -5
  7. data/ext/json/ext/parser/extconf.rb +0 -3
  8. data/ext/json/ext/parser/parser.c +418 -207
  9. data/ext/json/ext/parser/parser.h +11 -10
  10. data/ext/json/ext/parser/parser.rl +178 -104
  11. data/install.rb +1 -8
  12. data/java/src/json/ext/Generator.java +3 -3
  13. data/java/src/json/ext/GeneratorMethods.java +2 -2
  14. data/java/src/json/ext/GeneratorService.java +1 -1
  15. data/java/src/json/ext/GeneratorState.java +41 -13
  16. data/java/src/json/ext/OptionsReader.java +1 -1
  17. data/java/src/json/ext/Parser.java +382 -107
  18. data/java/src/json/ext/Parser.rl +97 -28
  19. data/java/src/json/ext/ParserService.java +1 -1
  20. data/java/src/json/ext/Utils.java +1 -1
  21. data/json.gemspec +5 -6
  22. data/json_pure.gemspec +5 -9
  23. data/lib/json.rb +4 -4
  24. data/lib/json/add/complex.rb +22 -0
  25. data/lib/json/add/core.rb +9 -241
  26. data/lib/json/add/date.rb +34 -0
  27. data/lib/json/add/date_time.rb +50 -0
  28. data/lib/json/add/exception.rb +31 -0
  29. data/lib/json/add/range.rb +29 -0
  30. data/lib/json/add/rational.rb +22 -0
  31. data/lib/json/add/regexp.rb +30 -0
  32. data/lib/json/add/struct.rb +30 -0
  33. data/lib/json/add/symbol.rb +25 -0
  34. data/lib/json/add/time.rb +35 -0
  35. data/lib/json/common.rb +47 -35
  36. data/lib/json/ext.rb +2 -15
  37. data/lib/json/pure/generator.rb +17 -2
  38. data/lib/json/pure/parser.rb +89 -55
  39. data/lib/json/version.rb +1 -1
  40. data/tests/test_json.rb +36 -0
  41. data/tests/test_json_addition.rb +8 -1
  42. data/tests/test_json_generate.rb +34 -1
  43. data/tools/server.rb +1 -0
  44. metadata +20 -24
  45. data/bin/edit_json.rb +0 -9
  46. data/bin/prettify_json.rb +0 -48
  47. data/lib/json/Array.xpm +0 -21
  48. data/lib/json/FalseClass.xpm +0 -21
  49. data/lib/json/Hash.xpm +0 -21
  50. data/lib/json/Key.xpm +0 -73
  51. data/lib/json/NilClass.xpm +0 -21
  52. data/lib/json/Numeric.xpm +0 -28
  53. data/lib/json/String.xpm +0 -96
  54. data/lib/json/TrueClass.xpm +0 -21
  55. data/lib/json/add/rails.rb +0 -8
  56. data/lib/json/editor.rb +0 -1369
  57. data/lib/json/json.xpm +0 -1499
data/install.rb CHANGED
@@ -6,21 +6,14 @@ include FileUtils::Verbose
6
6
 
7
7
  include Config
8
8
 
9
- bindir = CONFIG["bindir"]
10
- cd 'bin' do
11
- filename = 'edit_json.rb'
12
- #install(filename, bindir)
13
- end
14
9
  sitelibdir = CONFIG["sitelibdir"]
15
10
  cd 'lib' do
16
11
  install('json.rb', sitelibdir)
17
12
  mkdir_p File.join(sitelibdir, 'json')
18
- for file in Dir['json/**/*.{rb,xpm}']
13
+ for file in Dir['json/**/*}']
19
14
  d = File.join(sitelibdir, file)
20
15
  mkdir_p File.dirname(d)
21
16
  install(file, d)
22
17
  end
23
- install(File.join('json', 'editor.rb'), File.join(sitelibdir,'json'))
24
- install(File.join('json', 'json.xpm'), File.join(sitelibdir,'json'))
25
18
  end
26
19
  warn " *** Installed PURE ruby library."
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
3
- *
3
+ *
4
4
  * Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
5
5
  * for details.
6
6
  */
@@ -85,11 +85,11 @@ public final class Generator {
85
85
  /**
86
86
  * A class that concentrates all the information that is shared by
87
87
  * generators working on a single session.
88
- *
88
+ *
89
89
  * <p>A session is defined as the process of serializing a single root
90
90
  * object; any handler directly called by container handlers (arrays and
91
91
  * hashes/objects) shares this object with its caller.
92
- *
92
+ *
93
93
  * <p>Note that anything called indirectly (via {@link GENERIC_HANDLER})
94
94
  * won't be part of the session.
95
95
  */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
3
- *
3
+ *
4
4
  * Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
5
5
  * for details.
6
6
  */
@@ -25,7 +25,7 @@ import org.jruby.util.ByteList;
25
25
  /**
26
26
  * A class that populates the
27
27
  * <code>Json::Ext::Generator::GeneratorMethods</code> module.
28
- *
28
+ *
29
29
  * @author mernen
30
30
  */
31
31
  class GeneratorMethods {
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
3
- *
3
+ *
4
4
  * Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
5
5
  * for details.
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
3
- *
3
+ *
4
4
  * Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
5
5
  * for details.
6
6
  */
@@ -24,10 +24,10 @@ import org.jruby.util.ByteList;
24
24
 
25
25
  /**
26
26
  * The <code>JSON::Ext::Generator::State</code> class.
27
- *
27
+ *
28
28
  * <p>This class is used to create State instances, that are use to hold data
29
29
  * while generating a JSON text from a a Ruby data structure.
30
- *
30
+ *
31
31
  * @author mernen
32
32
  */
33
33
  public class GeneratorState extends RubyObject {
@@ -72,10 +72,17 @@ public class GeneratorState extends RubyObject {
72
72
  private boolean allowNaN = DEFAULT_ALLOW_NAN;
73
73
  static final boolean DEFAULT_ALLOW_NAN = false;
74
74
  /**
75
- * XXX
75
+ * If set to <code>true</code> all JSON documents generated do not contain
76
+ * any other characters than ASCII characters.
76
77
  */
77
78
  private boolean asciiOnly = DEFAULT_ASCII_ONLY;
78
79
  static final boolean DEFAULT_ASCII_ONLY = false;
80
+ /**
81
+ * If set to <code>true</code> all JSON values generated might not be
82
+ * RFC-conform JSON documents.
83
+ */
84
+ private boolean quirksMode = DEFAULT_QUIRKS_MODE;
85
+ static final boolean DEFAULT_QUIRKS_MODE = false;
79
86
 
80
87
  /**
81
88
  * The current depth (inside a #to_json call)
@@ -94,7 +101,7 @@ public class GeneratorState extends RubyObject {
94
101
 
95
102
  /**
96
103
  * <code>State.from_state(opts)</code>
97
- *
104
+ *
98
105
  * <p>Creates a State object from <code>opts</code>, which ought to be
99
106
  * {@link RubyHash Hash} to create a new <code>State</code> instance
100
107
  * configured by <codes>opts</code>, something else to create an
@@ -136,11 +143,11 @@ public class GeneratorState extends RubyObject {
136
143
 
137
144
  /**
138
145
  * <code>State#initialize(opts = {})</code>
139
- *
146
+ *
140
147
  * Instantiates a new <code>State</code> object, configured by <code>opts</code>.
141
- *
148
+ *
142
149
  * <code>opts</code> can have the following keys:
143
- *
150
+ *
144
151
  * <dl>
145
152
  * <dt><code>:indent</code>
146
153
  * <dd>a {@link RubyString String} used to indent levels (default: <code>""</code>)
@@ -151,7 +158,7 @@ public class GeneratorState extends RubyObject {
151
158
  * <dd>a String that is put before a <code>":"</code> pair delimiter
152
159
  * (default: <code>""</code>)
153
160
  * <dt><code>:object_nl</code>
154
- * <dd>a String that is put at the end of a JSON object (default: <code>""</code>)
161
+ * <dd>a String that is put at the end of a JSON object (default: <code>""</code>)
155
162
  * <dt><code>:array_nl</code>
156
163
  * <dd>a String that is put at the end of a JSON array (default: <code>""</code>)
157
164
  * <dt><code>:allow_nan</code>
@@ -181,17 +188,20 @@ public class GeneratorState extends RubyObject {
181
188
  this.maxNesting = orig.maxNesting;
182
189
  this.allowNaN = orig.allowNaN;
183
190
  this.asciiOnly = orig.asciiOnly;
191
+ this.quirksMode = orig.quirksMode;
184
192
  this.depth = orig.depth;
185
193
  return this;
186
194
  }
187
195
 
188
196
  /**
189
- * XXX
197
+ * Generates a valid JSON document from object <code>obj</code> and returns
198
+ * the result. If no valid JSON document can be created this method raises
199
+ * a GeneratorError exception.
190
200
  */
191
201
  @JRubyMethod
192
202
  public IRubyObject generate(ThreadContext context, IRubyObject obj) {
193
203
  RubyString result = Generator.generateJson(context, obj, this);
194
- if (!objectOrArrayLiteral(result)) {
204
+ if (!quirksMode && !objectOrArrayLiteral(result)) {
195
205
  throw Utils.newException(context, Utils.M_GENERATOR_ERROR,
196
206
  "only generation of JSON objects or arrays allowed");
197
207
  }
@@ -364,6 +374,22 @@ public class GeneratorState extends RubyObject {
364
374
  return context.getRuntime().newBoolean(asciiOnly);
365
375
  }
366
376
 
377
+ @JRubyMethod(name="quirks_mode")
378
+ public RubyBoolean quirks_mode_get(ThreadContext context) {
379
+ return context.getRuntime().newBoolean(quirksMode);
380
+ }
381
+
382
+ @JRubyMethod(name="quirks_mode=")
383
+ public IRubyObject quirks_mode_set(IRubyObject quirks_mode) {
384
+ quirksMode = quirks_mode.isTrue();
385
+ return quirks_mode.getRuntime().newBoolean(quirksMode);
386
+ }
387
+
388
+ @JRubyMethod(name="quirks_mode?")
389
+ public RubyBoolean quirks_mode_p(ThreadContext context) {
390
+ return context.getRuntime().newBoolean(quirksMode);
391
+ }
392
+
367
393
  public int getDepth() {
368
394
  return depth;
369
395
  }
@@ -390,7 +416,7 @@ public class GeneratorState extends RubyObject {
390
416
 
391
417
  /**
392
418
  * <code>State#configure(opts)</code>
393
- *
419
+ *
394
420
  * <p>Configures this State instance with the {@link RubyHash Hash}
395
421
  * <code>opts</code>, and returns itself.
396
422
  * @param vOpts The options hash
@@ -418,6 +444,7 @@ public class GeneratorState extends RubyObject {
418
444
  maxNesting = opts.getInt("max_nesting", DEFAULT_MAX_NESTING);
419
445
  allowNaN = opts.getBool("allow_nan", DEFAULT_ALLOW_NAN);
420
446
  asciiOnly = opts.getBool("ascii_only", DEFAULT_ASCII_ONLY);
447
+ quirksMode = opts.getBool("quirks_mode", DEFAULT_QUIRKS_MODE);
421
448
 
422
449
  depth = opts.getInt("depth", 0);
423
450
 
@@ -426,7 +453,7 @@ public class GeneratorState extends RubyObject {
426
453
 
427
454
  /**
428
455
  * <code>State#to_h()</code>
429
- *
456
+ *
430
457
  * <p>Returns the configuration instance variables as a hash, that can be
431
458
  * passed to the configure method.
432
459
  * @return
@@ -443,6 +470,7 @@ public class GeneratorState extends RubyObject {
443
470
  result.op_aset(context, runtime.newSymbol("array_nl"), array_nl_get(context));
444
471
  result.op_aset(context, runtime.newSymbol("allow_nan"), allow_nan_p(context));
445
472
  result.op_aset(context, runtime.newSymbol("ascii_only"), ascii_only_p(context));
473
+ result.op_aset(context, runtime.newSymbol("quirks_mode"), quirks_mode_p(context));
446
474
  result.op_aset(context, runtime.newSymbol("max_nesting"), max_nesting_get(context));
447
475
  result.op_aset(context, runtime.newSymbol("depth"), depth_get(context));
448
476
  return result;
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
3
- *
3
+ *
4
4
  * Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
5
5
  * for details.
6
6
  */
@@ -2,7 +2,7 @@
2
2
  // line 1 "Parser.rl"
3
3
  /*
4
4
  * This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
5
- *
5
+ *
6
6
  * Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
7
7
  * for details.
8
8
  */
@@ -31,16 +31,16 @@ import org.jruby.util.ByteList;
31
31
 
32
32
  /**
33
33
  * The <code>JSON::Ext::Parser</code> class.
34
- *
34
+ *
35
35
  * <p>This is the JSON parser implemented as a Java class. To use it as the
36
36
  * standard parser, set
37
37
  * <pre>JSON.parser = JSON::Ext::Parser</pre>
38
38
  * This is performed for you when you <code>include "json/ext"</code>.
39
- *
39
+ *
40
40
  * <p>This class does not perform the actual parsing, just acts as an interface
41
41
  * to Ruby code. When the {@link #parse()} method is invoked, a
42
42
  * Parser.ParserSession object is instantiated, which handles the process.
43
- *
43
+ *
44
44
  * @author mernen
45
45
  */
46
46
  public class Parser extends RubyObject {
@@ -51,6 +51,7 @@ public class Parser extends RubyObject {
51
51
  private int maxNesting;
52
52
  private boolean allowNaN;
53
53
  private boolean symbolizeNames;
54
+ private boolean quirksMode;
54
55
  private RubyClass objectClass;
55
56
  private RubyClass arrayClass;
56
57
  private RubyHash match_string;
@@ -71,7 +72,7 @@ public class Parser extends RubyObject {
71
72
 
72
73
  /**
73
74
  * Multiple-value return for internal parser methods.
74
- *
75
+ *
75
76
  * <p>All the <code>parse<var>Stuff</var></code> methods return instances of
76
77
  * <code>ParserResult</code> when successful, or <code>null</code> when
77
78
  * there's a problem with the input data.
@@ -100,18 +101,18 @@ public class Parser extends RubyObject {
100
101
 
101
102
  /**
102
103
  * <code>Parser.new(source, opts = {})</code>
103
- *
104
+ *
104
105
  * <p>Creates a new <code>JSON::Ext::Parser</code> instance for the string
105
106
  * <code>source</code>.
106
107
  * It will be configured by the <code>opts</code> Hash.
107
108
  * <code>opts</code> can have the following keys:
108
- *
109
+ *
109
110
  * <dl>
110
111
  * <dt><code>:max_nesting</code>
111
112
  * <dd>The maximum depth of nesting allowed in the parsed data
112
113
  * structures. Disable depth checking with <code>:max_nesting => false|nil|0</code>,
113
114
  * it defaults to 19.
114
- *
115
+ *
115
116
  * <dt><code>:allow_nan</code>
116
117
  * <dd>If set to <code>true</code>, allow <code>NaN</code>,
117
118
  * <code>Infinity</code> and <code>-Infinity</code> in defiance of RFC 4627
@@ -120,17 +121,25 @@ public class Parser extends RubyObject {
120
121
  * <dt><code>:symbolize_names</code>
121
122
  * <dd>If set to <code>true</code>, returns symbols for the names (keys) in
122
123
  * a JSON object. Otherwise strings are returned, which is also the default.
124
+ *
125
+ * <dt><code>:quirks_mode?</code>
126
+ * <dd>If set to <code>true</code>, if the parse is in quirks_mode, false
127
+ * otherwise.
123
128
  *
124
129
  * <dt><code>:create_additions</code>
125
130
  * <dd>If set to <code>false</code>, the Parser doesn't create additions
126
131
  * even if a matchin class and <code>create_id</code> was found. This option
127
132
  * defaults to <code>true</code>.
128
- *
133
+ *
129
134
  * <dt><code>:object_class</code>
130
135
  * <dd>Defaults to Hash.
131
- *
136
+ *
132
137
  * <dt><code>:array_class</code>
133
138
  * <dd>Defaults to Array.
139
+ *
140
+ * <dt><code>:quirks_mode</code>
141
+ * <dd>Enables quirks_mode for parser, that is for example parsing single
142
+ * JSON values instead of documents is possible.
134
143
  * </dl>
135
144
  */
136
145
  @JRubyMethod(name = "new", required = 1, optional = 1, meta = true)
@@ -148,19 +157,21 @@ public class Parser extends RubyObject {
148
157
  if (this.vSource != null) {
149
158
  throw runtime.newTypeError("already initialized instance");
150
159
  }
151
- RubyString source = convertEncoding(context, args[0].convertToString());
152
160
 
153
161
  OptionsReader opts = new OptionsReader(context, args.length > 1 ? args[1] : null);
154
162
  this.maxNesting = opts.getInt("max_nesting", DEFAULT_MAX_NESTING);
155
163
  this.allowNaN = opts.getBool("allow_nan", false);
156
164
  this.symbolizeNames = opts.getBool("symbolize_names", false);
165
+ this.quirksMode = opts.getBool("quirks_mode", false);
157
166
  this.createId = opts.getString("create_id", getCreateId(context));
158
167
  this.createAdditions = opts.getBool("create_additions", true);
159
168
  this.objectClass = opts.getClass("object_class", runtime.getHash());
160
169
  this.arrayClass = opts.getClass("array_class", runtime.getArray());
161
170
  this.match_string = opts.getHash("match_string");
162
171
 
163
- this.vSource = source;
172
+ this.vSource = args[0].convertToString();
173
+ if (!quirksMode) this.vSource = convertEncoding(context, vSource);
174
+
164
175
  return this;
165
176
  }
166
177
 
@@ -229,7 +240,7 @@ public class Parser extends RubyObject {
229
240
 
230
241
  /**
231
242
  * <code>Parser#parse()</code>
232
- *
243
+ *
233
244
  * <p>Parses the current JSON text <code>source</code> and returns the
234
245
  * complete data structure as a result.
235
246
  */
@@ -240,7 +251,7 @@ public class Parser extends RubyObject {
240
251
 
241
252
  /**
242
253
  * <code>Parser#source()</code>
243
- *
254
+ *
244
255
  * <p>Returns a copy of the current <code>source</code> string, that was
245
256
  * used to construct this Parser.
246
257
  */
@@ -249,6 +260,17 @@ public class Parser extends RubyObject {
249
260
  return checkAndGetSource().dup();
250
261
  }
251
262
 
263
+ /**
264
+ * <code>Parser#quirks_mode?()</code>
265
+ *
266
+ * <p>If set to <code>true</code>, if the parse is in quirks_mode, false
267
+ * otherwise.
268
+ */
269
+ @JRubyMethod(name = "quirks_mode?")
270
+ public IRubyObject quirks_mode_p(ThreadContext context) {
271
+ return context.getRuntime().newBoolean(quirksMode);
272
+ }
273
+
252
274
  public RubyString checkAndGetSource() {
253
275
  if (vSource != null) {
254
276
  return vSource;
@@ -268,7 +290,7 @@ public class Parser extends RubyObject {
268
290
 
269
291
  /**
270
292
  * A string parsing session.
271
- *
293
+ *
272
294
  * <p>Once a ParserSession is instantiated, the source string should not
273
295
  * change until the parsing is complete. The ParserSession object assumes
274
296
  * the source {@link RubyString} is still associated to its original
@@ -309,11 +331,11 @@ public class Parser extends RubyObject {
309
331
  }
310
332
 
311
333
 
312
- // line 335 "Parser.rl"
334
+ // line 357 "Parser.rl"
313
335
 
314
336
 
315
337
 
316
- // line 317 "Parser.java"
338
+ // line 339 "Parser.java"
317
339
  private static byte[] init__JSON_value_actions_0()
318
340
  {
319
341
  return new byte [] {
@@ -427,7 +449,7 @@ static final int JSON_value_error = 0;
427
449
  static final int JSON_value_en_main = 1;
428
450
 
429
451
 
430
- // line 441 "Parser.rl"
452
+ // line 463 "Parser.rl"
431
453
 
432
454
 
433
455
  ParserResult parseValue(int p, int pe) {
@@ -435,14 +457,14 @@ static final int JSON_value_en_main = 1;
435
457
  IRubyObject result = null;
436
458
 
437
459
 
438
- // line 439 "Parser.java"
460
+ // line 461 "Parser.java"
439
461
  {
440
462
  cs = JSON_value_start;
441
463
  }
442
464
 
443
- // line 448 "Parser.rl"
465
+ // line 470 "Parser.rl"
444
466
 
445
- // line 446 "Parser.java"
467
+ // line 468 "Parser.java"
446
468
  {
447
469
  int _klen;
448
470
  int _trans = 0;
@@ -468,13 +490,13 @@ case 1:
468
490
  while ( _nacts-- > 0 ) {
469
491
  switch ( _JSON_value_actions[_acts++] ) {
470
492
  case 9:
471
- // line 426 "Parser.rl"
493
+ // line 448 "Parser.rl"
472
494
  {
473
495
  p--;
474
496
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
475
497
  }
476
498
  break;
477
- // line 478 "Parser.java"
499
+ // line 500 "Parser.java"
478
500
  }
479
501
  }
480
502
 
@@ -537,25 +559,25 @@ case 1:
537
559
  switch ( _JSON_value_actions[_acts++] )
538
560
  {
539
561
  case 0:
540
- // line 343 "Parser.rl"
562
+ // line 365 "Parser.rl"
541
563
  {
542
564
  result = getRuntime().getNil();
543
565
  }
544
566
  break;
545
567
  case 1:
546
- // line 346 "Parser.rl"
568
+ // line 368 "Parser.rl"
547
569
  {
548
570
  result = getRuntime().getFalse();
549
571
  }
550
572
  break;
551
573
  case 2:
552
- // line 349 "Parser.rl"
574
+ // line 371 "Parser.rl"
553
575
  {
554
576
  result = getRuntime().getTrue();
555
577
  }
556
578
  break;
557
579
  case 3:
558
- // line 352 "Parser.rl"
580
+ // line 374 "Parser.rl"
559
581
  {
560
582
  if (parser.allowNaN) {
561
583
  result = getConstant(CONST_NAN);
@@ -565,7 +587,7 @@ case 1:
565
587
  }
566
588
  break;
567
589
  case 4:
568
- // line 359 "Parser.rl"
590
+ // line 381 "Parser.rl"
569
591
  {
570
592
  if (parser.allowNaN) {
571
593
  result = getConstant(CONST_INFINITY);
@@ -575,9 +597,9 @@ case 1:
575
597
  }
576
598
  break;
577
599
  case 5:
578
- // line 366 "Parser.rl"
600
+ // line 388 "Parser.rl"
579
601
  {
580
- if (pe > p + 9 &&
602
+ if (pe > p + 9 - (parser.quirksMode ? 1 : 0) &&
581
603
  absSubSequence(p, p + 9).toString().equals(JSON_MINUS_INFINITY)) {
582
604
 
583
605
  if (parser.allowNaN) {
@@ -604,7 +626,7 @@ case 1:
604
626
  }
605
627
  break;
606
628
  case 6:
607
- // line 392 "Parser.rl"
629
+ // line 414 "Parser.rl"
608
630
  {
609
631
  ParserResult res = parseString(p, pe);
610
632
  if (res == null) {
@@ -617,7 +639,7 @@ case 1:
617
639
  }
618
640
  break;
619
641
  case 7:
620
- // line 402 "Parser.rl"
642
+ // line 424 "Parser.rl"
621
643
  {
622
644
  currentNesting++;
623
645
  ParserResult res = parseArray(p, pe);
@@ -632,7 +654,7 @@ case 1:
632
654
  }
633
655
  break;
634
656
  case 8:
635
- // line 414 "Parser.rl"
657
+ // line 436 "Parser.rl"
636
658
  {
637
659
  currentNesting++;
638
660
  ParserResult res = parseObject(p, pe);
@@ -646,7 +668,7 @@ case 1:
646
668
  }
647
669
  }
648
670
  break;
649
- // line 650 "Parser.java"
671
+ // line 672 "Parser.java"
650
672
  }
651
673
  }
652
674
  }
@@ -666,7 +688,7 @@ case 5:
666
688
  break; }
667
689
  }
668
690
 
669
- // line 449 "Parser.rl"
691
+ // line 471 "Parser.rl"
670
692
 
671
693
  if (cs >= JSON_value_first_final && result != null) {
672
694
  return new ParserResult(result, p);
@@ -676,7 +698,7 @@ case 5:
676
698
  }
677
699
 
678
700
 
679
- // line 680 "Parser.java"
701
+ // line 702 "Parser.java"
680
702
  private static byte[] init__JSON_integer_actions_0()
681
703
  {
682
704
  return new byte [] {
@@ -690,7 +712,7 @@ private static final byte _JSON_integer_actions[] = init__JSON_integer_actions_0
690
712
  private static byte[] init__JSON_integer_key_offsets_0()
691
713
  {
692
714
  return new byte [] {
693
- 0, 0, 4, 7, 9, 11
715
+ 0, 0, 4, 7, 9, 9
694
716
  };
695
717
  }
696
718
 
@@ -720,7 +742,7 @@ private static final byte _JSON_integer_single_lengths[] = init__JSON_integer_si
720
742
  private static byte[] init__JSON_integer_range_lengths_0()
721
743
  {
722
744
  return new byte [] {
723
- 0, 1, 1, 1, 1, 0
745
+ 0, 1, 1, 1, 0, 1
724
746
  };
725
747
  }
726
748
 
@@ -730,7 +752,7 @@ private static final byte _JSON_integer_range_lengths[] = init__JSON_integer_ran
730
752
  private static byte[] init__JSON_integer_index_offsets_0()
731
753
  {
732
754
  return new byte [] {
733
- 0, 0, 4, 7, 9, 11
755
+ 0, 0, 4, 7, 9, 10
734
756
  };
735
757
  }
736
758
 
@@ -740,7 +762,7 @@ private static final byte _JSON_integer_index_offsets[] = init__JSON_integer_ind
740
762
  private static byte[] init__JSON_integer_indicies_0()
741
763
  {
742
764
  return new byte [] {
743
- 0, 2, 3, 1, 2, 3, 1, 1, 4, 3, 4, 1,
765
+ 0, 2, 3, 1, 2, 3, 1, 1, 4, 1, 3, 4,
744
766
  0
745
767
  };
746
768
  }
@@ -751,7 +773,7 @@ private static final byte _JSON_integer_indicies[] = init__JSON_integer_indicies
751
773
  private static byte[] init__JSON_integer_trans_targs_0()
752
774
  {
753
775
  return new byte [] {
754
- 2, 0, 3, 4, 5
776
+ 2, 0, 3, 5, 4
755
777
  };
756
778
  }
757
779
 
@@ -769,28 +791,28 @@ private static final byte _JSON_integer_trans_actions[] = init__JSON_integer_tra
769
791
 
770
792
 
771
793
  static final int JSON_integer_start = 1;
772
- static final int JSON_integer_first_final = 5;
794
+ static final int JSON_integer_first_final = 3;
773
795
  static final int JSON_integer_error = 0;
774
796
 
775
797
  static final int JSON_integer_en_main = 1;
776
798
 
777
799
 
778
- // line 468 "Parser.rl"
800
+ // line 490 "Parser.rl"
779
801
 
780
802
 
781
803
  ParserResult parseInteger(int p, int pe) {
782
804
  int cs = EVIL;
783
805
 
784
806
 
785
- // line 786 "Parser.java"
807
+ // line 808 "Parser.java"
786
808
  {
787
809
  cs = JSON_integer_start;
788
810
  }
789
811
 
790
- // line 474 "Parser.rl"
812
+ // line 496 "Parser.rl"
791
813
  int memo = p;
792
814
 
793
- // line 794 "Parser.java"
815
+ // line 816 "Parser.java"
794
816
  {
795
817
  int _klen;
796
818
  int _trans = 0;
@@ -871,13 +893,13 @@ case 1:
871
893
  switch ( _JSON_integer_actions[_acts++] )
872
894
  {
873
895
  case 0:
874
- // line 462 "Parser.rl"
896
+ // line 484 "Parser.rl"
875
897
  {
876
898
  p--;
877
899
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
878
900
  }
879
901
  break;
880
- // line 881 "Parser.java"
902
+ // line 903 "Parser.java"
881
903
  }
882
904
  }
883
905
  }
@@ -897,7 +919,7 @@ case 5:
897
919
  break; }
898
920
  }
899
921
 
900
- // line 476 "Parser.rl"
922
+ // line 498 "Parser.rl"
901
923
 
902
924
  if (cs < JSON_integer_first_final) {
903
925
  return null;
@@ -912,7 +934,7 @@ case 5:
912
934
  }
913
935
 
914
936
 
915
- // line 916 "Parser.java"
937
+ // line 938 "Parser.java"
916
938
  private static byte[] init__JSON_float_actions_0()
917
939
  {
918
940
  return new byte [] {
@@ -926,7 +948,7 @@ private static final byte _JSON_float_actions[] = init__JSON_float_actions_0();
926
948
  private static byte[] init__JSON_float_key_offsets_0()
927
949
  {
928
950
  return new byte [] {
929
- 0, 0, 4, 7, 10, 12, 18, 22, 24, 30, 35
951
+ 0, 0, 4, 7, 10, 12, 16, 18, 23, 29, 29
930
952
  };
931
953
  }
932
954
 
@@ -937,8 +959,8 @@ private static char[] init__JSON_float_trans_keys_0()
937
959
  {
938
960
  return new char [] {
939
961
  45, 48, 49, 57, 48, 49, 57, 46, 69, 101, 48, 57,
940
- 69, 101, 45, 46, 48, 57, 43, 45, 48, 57, 48, 57,
941
- 69, 101, 45, 46, 48, 57, 46, 69, 101, 48, 57, 0
962
+ 43, 45, 48, 57, 48, 57, 46, 69, 101, 48, 57, 69,
963
+ 101, 45, 46, 48, 57, 69, 101, 45, 46, 48, 57, 0
942
964
  };
943
965
  }
944
966
 
@@ -948,7 +970,7 @@ private static final char _JSON_float_trans_keys[] = init__JSON_float_trans_keys
948
970
  private static byte[] init__JSON_float_single_lengths_0()
949
971
  {
950
972
  return new byte [] {
951
- 0, 2, 1, 3, 0, 2, 2, 0, 2, 3, 0
973
+ 0, 2, 1, 3, 0, 2, 0, 3, 2, 0, 2
952
974
  };
953
975
  }
954
976
 
@@ -958,7 +980,7 @@ private static final byte _JSON_float_single_lengths[] = init__JSON_float_single
958
980
  private static byte[] init__JSON_float_range_lengths_0()
959
981
  {
960
982
  return new byte [] {
961
- 0, 1, 1, 0, 1, 2, 1, 1, 2, 1, 0
983
+ 0, 1, 1, 0, 1, 1, 1, 1, 2, 0, 2
962
984
  };
963
985
  }
964
986
 
@@ -968,7 +990,7 @@ private static final byte _JSON_float_range_lengths[] = init__JSON_float_range_l
968
990
  private static byte[] init__JSON_float_index_offsets_0()
969
991
  {
970
992
  return new byte [] {
971
- 0, 0, 4, 7, 11, 13, 18, 22, 24, 29, 34
993
+ 0, 0, 4, 7, 11, 13, 17, 19, 24, 29, 30
972
994
  };
973
995
  }
974
996
 
@@ -979,8 +1001,8 @@ private static byte[] init__JSON_float_indicies_0()
979
1001
  {
980
1002
  return new byte [] {
981
1003
  0, 2, 3, 1, 2, 3, 1, 4, 5, 5, 1, 6,
982
- 1, 5, 5, 1, 6, 7, 8, 8, 9, 1, 9, 1,
983
- 1, 1, 1, 9, 7, 4, 5, 5, 3, 1, 1, 0
1004
+ 1, 7, 7, 8, 1, 8, 1, 4, 5, 5, 3, 1,
1005
+ 5, 5, 1, 6, 9, 1, 1, 1, 1, 8, 9, 0
984
1006
  };
985
1007
  }
986
1008
 
@@ -990,7 +1012,7 @@ private static final byte _JSON_float_indicies[] = init__JSON_float_indicies_0()
990
1012
  private static byte[] init__JSON_float_trans_targs_0()
991
1013
  {
992
1014
  return new byte [] {
993
- 2, 0, 3, 9, 4, 6, 5, 10, 7, 8
1015
+ 2, 0, 3, 7, 4, 5, 8, 6, 10, 9
994
1016
  };
995
1017
  }
996
1018
 
@@ -1000,7 +1022,7 @@ private static final byte _JSON_float_trans_targs[] = init__JSON_float_trans_tar
1000
1022
  private static byte[] init__JSON_float_trans_actions_0()
1001
1023
  {
1002
1024
  return new byte [] {
1003
- 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
1025
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
1004
1026
  };
1005
1027
  }
1006
1028
 
@@ -1008,28 +1030,28 @@ private static final byte _JSON_float_trans_actions[] = init__JSON_float_trans_a
1008
1030
 
1009
1031
 
1010
1032
  static final int JSON_float_start = 1;
1011
- static final int JSON_float_first_final = 10;
1033
+ static final int JSON_float_first_final = 8;
1012
1034
  static final int JSON_float_error = 0;
1013
1035
 
1014
1036
  static final int JSON_float_en_main = 1;
1015
1037
 
1016
1038
 
1017
- // line 504 "Parser.rl"
1039
+ // line 526 "Parser.rl"
1018
1040
 
1019
1041
 
1020
1042
  ParserResult parseFloat(int p, int pe) {
1021
1043
  int cs = EVIL;
1022
1044
 
1023
1045
 
1024
- // line 1025 "Parser.java"
1046
+ // line 1047 "Parser.java"
1025
1047
  {
1026
1048
  cs = JSON_float_start;
1027
1049
  }
1028
1050
 
1029
- // line 510 "Parser.rl"
1051
+ // line 532 "Parser.rl"
1030
1052
  int memo = p;
1031
1053
 
1032
- // line 1033 "Parser.java"
1054
+ // line 1055 "Parser.java"
1033
1055
  {
1034
1056
  int _klen;
1035
1057
  int _trans = 0;
@@ -1110,13 +1132,13 @@ case 1:
1110
1132
  switch ( _JSON_float_actions[_acts++] )
1111
1133
  {
1112
1134
  case 0:
1113
- // line 495 "Parser.rl"
1135
+ // line 517 "Parser.rl"
1114
1136
  {
1115
1137
  p--;
1116
1138
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
1117
1139
  }
1118
1140
  break;
1119
- // line 1120 "Parser.java"
1141
+ // line 1142 "Parser.java"
1120
1142
  }
1121
1143
  }
1122
1144
  }
@@ -1136,7 +1158,7 @@ case 5:
1136
1158
  break; }
1137
1159
  }
1138
1160
 
1139
- // line 512 "Parser.rl"
1161
+ // line 534 "Parser.rl"
1140
1162
 
1141
1163
  if (cs < JSON_float_first_final) {
1142
1164
  return null;
@@ -1151,7 +1173,7 @@ case 5:
1151
1173
  }
1152
1174
 
1153
1175
 
1154
- // line 1155 "Parser.java"
1176
+ // line 1177 "Parser.java"
1155
1177
  private static byte[] init__JSON_string_actions_0()
1156
1178
  {
1157
1179
  return new byte [] {
@@ -1253,7 +1275,7 @@ static final int JSON_string_error = 0;
1253
1275
  static final int JSON_string_en_main = 1;
1254
1276
 
1255
1277
 
1256
- // line 556 "Parser.rl"
1278
+ // line 578 "Parser.rl"
1257
1279
 
1258
1280
 
1259
1281
  ParserResult parseString(int p, int pe) {
@@ -1261,15 +1283,15 @@ static final int JSON_string_en_main = 1;
1261
1283
  IRubyObject result = null;
1262
1284
 
1263
1285
 
1264
- // line 1265 "Parser.java"
1286
+ // line 1287 "Parser.java"
1265
1287
  {
1266
1288
  cs = JSON_string_start;
1267
1289
  }
1268
1290
 
1269
- // line 563 "Parser.rl"
1291
+ // line 585 "Parser.rl"
1270
1292
  int memo = p;
1271
1293
 
1272
- // line 1273 "Parser.java"
1294
+ // line 1295 "Parser.java"
1273
1295
  {
1274
1296
  int _klen;
1275
1297
  int _trans = 0;
@@ -1350,7 +1372,7 @@ case 1:
1350
1372
  switch ( _JSON_string_actions[_acts++] )
1351
1373
  {
1352
1374
  case 0:
1353
- // line 531 "Parser.rl"
1375
+ // line 553 "Parser.rl"
1354
1376
  {
1355
1377
  int offset = byteList.begin();
1356
1378
  ByteList decoded = decoder.decode(byteList, memo + 1 - offset,
@@ -1365,13 +1387,13 @@ case 1:
1365
1387
  }
1366
1388
  break;
1367
1389
  case 1:
1368
- // line 544 "Parser.rl"
1390
+ // line 566 "Parser.rl"
1369
1391
  {
1370
1392
  p--;
1371
1393
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
1372
1394
  }
1373
1395
  break;
1374
- // line 1375 "Parser.java"
1396
+ // line 1397 "Parser.java"
1375
1397
  }
1376
1398
  }
1377
1399
  }
@@ -1391,7 +1413,7 @@ case 5:
1391
1413
  break; }
1392
1414
  }
1393
1415
 
1394
- // line 565 "Parser.rl"
1416
+ // line 587 "Parser.rl"
1395
1417
 
1396
1418
  if (parser.createAdditions) {
1397
1419
  RubyHash match_string = parser.match_string;
@@ -1408,7 +1430,7 @@ case 5:
1408
1430
  }
1409
1431
  });
1410
1432
  } catch (JumpException e) { }
1411
- if (memoArray[1] != null) {
1433
+ if (memoArray[1] != null) {
1412
1434
  RubyClass klass = (RubyClass) memoArray[1];
1413
1435
  if (klass.respondsTo("json_creatable?") &&
1414
1436
  klass.callMethod(context, "json_creatable?").isTrue()) {
@@ -1426,7 +1448,7 @@ case 5:
1426
1448
  }
1427
1449
 
1428
1450
 
1429
- // line 1430 "Parser.java"
1451
+ // line 1452 "Parser.java"
1430
1452
  private static byte[] init__JSON_array_actions_0()
1431
1453
  {
1432
1454
  return new byte [] {
@@ -1539,7 +1561,7 @@ static final int JSON_array_error = 0;
1539
1561
  static final int JSON_array_en_main = 1;
1540
1562
 
1541
1563
 
1542
- // line 635 "Parser.rl"
1564
+ // line 657 "Parser.rl"
1543
1565
 
1544
1566
 
1545
1567
  ParserResult parseArray(int p, int pe) {
@@ -1557,14 +1579,14 @@ static final int JSON_array_en_main = 1;
1557
1579
  IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
1558
1580
 
1559
1581
 
1560
- // line 1561 "Parser.java"
1582
+ // line 1583 "Parser.java"
1561
1583
  {
1562
1584
  cs = JSON_array_start;
1563
1585
  }
1564
1586
 
1565
- // line 652 "Parser.rl"
1587
+ // line 674 "Parser.rl"
1566
1588
 
1567
- // line 1568 "Parser.java"
1589
+ // line 1590 "Parser.java"
1568
1590
  {
1569
1591
  int _klen;
1570
1592
  int _trans = 0;
@@ -1645,7 +1667,7 @@ case 1:
1645
1667
  switch ( _JSON_array_actions[_acts++] )
1646
1668
  {
1647
1669
  case 0:
1648
- // line 604 "Parser.rl"
1670
+ // line 626 "Parser.rl"
1649
1671
  {
1650
1672
  ParserResult res = parseValue(p, pe);
1651
1673
  if (res == null) {
@@ -1662,13 +1684,13 @@ case 1:
1662
1684
  }
1663
1685
  break;
1664
1686
  case 1:
1665
- // line 619 "Parser.rl"
1687
+ // line 641 "Parser.rl"
1666
1688
  {
1667
1689
  p--;
1668
1690
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
1669
1691
  }
1670
1692
  break;
1671
- // line 1672 "Parser.java"
1693
+ // line 1694 "Parser.java"
1672
1694
  }
1673
1695
  }
1674
1696
  }
@@ -1688,7 +1710,7 @@ case 5:
1688
1710
  break; }
1689
1711
  }
1690
1712
 
1691
- // line 653 "Parser.rl"
1713
+ // line 675 "Parser.rl"
1692
1714
 
1693
1715
  if (cs >= JSON_array_first_final) {
1694
1716
  return new ParserResult(result, p + 1);
@@ -1698,7 +1720,7 @@ case 5:
1698
1720
  }
1699
1721
 
1700
1722
 
1701
- // line 1702 "Parser.java"
1723
+ // line 1724 "Parser.java"
1702
1724
  private static byte[] init__JSON_object_actions_0()
1703
1725
  {
1704
1726
  return new byte [] {
@@ -1821,7 +1843,7 @@ static final int JSON_object_error = 0;
1821
1843
  static final int JSON_object_en_main = 1;
1822
1844
 
1823
1845
 
1824
- // line 713 "Parser.rl"
1846
+ // line 734 "Parser.rl"
1825
1847
 
1826
1848
 
1827
1849
  ParserResult parseObject(int p, int pe) {
@@ -1840,14 +1862,14 @@ static final int JSON_object_en_main = 1;
1840
1862
  IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
1841
1863
 
1842
1864
 
1843
- // line 1844 "Parser.java"
1865
+ // line 1866 "Parser.java"
1844
1866
  {
1845
1867
  cs = JSON_object_start;
1846
1868
  }
1847
1869
 
1848
- // line 731 "Parser.rl"
1870
+ // line 752 "Parser.rl"
1849
1871
 
1850
- // line 1851 "Parser.java"
1872
+ // line 1873 "Parser.java"
1851
1873
  {
1852
1874
  int _klen;
1853
1875
  int _trans = 0;
@@ -1928,7 +1950,7 @@ case 1:
1928
1950
  switch ( _JSON_object_actions[_acts++] )
1929
1951
  {
1930
1952
  case 0:
1931
- // line 667 "Parser.rl"
1953
+ // line 689 "Parser.rl"
1932
1954
  {
1933
1955
  ParserResult res = parseValue(p, pe);
1934
1956
  if (res == null) {
@@ -1945,7 +1967,7 @@ case 1:
1945
1967
  }
1946
1968
  break;
1947
1969
  case 1:
1948
- // line 682 "Parser.rl"
1970
+ // line 704 "Parser.rl"
1949
1971
  {
1950
1972
  ParserResult res = parseString(p, pe);
1951
1973
  if (res == null) {
@@ -1965,13 +1987,13 @@ case 1:
1965
1987
  }
1966
1988
  break;
1967
1989
  case 2:
1968
- // line 700 "Parser.rl"
1990
+ // line 722 "Parser.rl"
1969
1991
  {
1970
1992
  p--;
1971
1993
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
1972
1994
  }
1973
1995
  break;
1974
- // line 1975 "Parser.java"
1996
+ // line 1997 "Parser.java"
1975
1997
  }
1976
1998
  }
1977
1999
  }
@@ -1991,7 +2013,7 @@ case 5:
1991
2013
  break; }
1992
2014
  }
1993
2015
 
1994
- // line 732 "Parser.rl"
2016
+ // line 753 "Parser.rl"
1995
2017
 
1996
2018
  if (cs < JSON_object_first_final) {
1997
2019
  return null;
@@ -2017,7 +2039,7 @@ case 5:
2017
2039
  }
2018
2040
 
2019
2041
 
2020
- // line 2021 "Parser.java"
2042
+ // line 2043 "Parser.java"
2021
2043
  private static byte[] init__JSON_actions_0()
2022
2044
  {
2023
2045
  return new byte [] {
@@ -2121,25 +2143,25 @@ static final int JSON_error = 0;
2121
2143
  static final int JSON_en_main = 1;
2122
2144
 
2123
2145
 
2124
- // line 790 "Parser.rl"
2146
+ // line 811 "Parser.rl"
2125
2147
 
2126
2148
 
2127
- public IRubyObject parse() {
2149
+ public IRubyObject parseStrict() {
2128
2150
  int cs = EVIL;
2129
2151
  int p, pe;
2130
2152
  IRubyObject result = null;
2131
2153
 
2132
2154
 
2133
- // line 2134 "Parser.java"
2155
+ // line 2156 "Parser.java"
2134
2156
  {
2135
2157
  cs = JSON_start;
2136
2158
  }
2137
2159
 
2138
- // line 798 "Parser.rl"
2160
+ // line 819 "Parser.rl"
2139
2161
  p = byteList.begin();
2140
2162
  pe = p + byteList.length();
2141
2163
 
2142
- // line 2143 "Parser.java"
2164
+ // line 2165 "Parser.java"
2143
2165
  {
2144
2166
  int _klen;
2145
2167
  int _trans = 0;
@@ -2220,7 +2242,7 @@ case 1:
2220
2242
  switch ( _JSON_actions[_acts++] )
2221
2243
  {
2222
2244
  case 0:
2223
- // line 762 "Parser.rl"
2245
+ // line 783 "Parser.rl"
2224
2246
  {
2225
2247
  currentNesting = 1;
2226
2248
  ParserResult res = parseObject(p, pe);
@@ -2234,7 +2256,7 @@ case 1:
2234
2256
  }
2235
2257
  break;
2236
2258
  case 1:
2237
- // line 774 "Parser.rl"
2259
+ // line 795 "Parser.rl"
2238
2260
  {
2239
2261
  currentNesting = 1;
2240
2262
  ParserResult res = parseArray(p, pe);
@@ -2247,7 +2269,7 @@ case 1:
2247
2269
  }
2248
2270
  }
2249
2271
  break;
2250
- // line 2251 "Parser.java"
2272
+ // line 2273 "Parser.java"
2251
2273
  }
2252
2274
  }
2253
2275
  }
@@ -2267,7 +2289,7 @@ case 5:
2267
2289
  break; }
2268
2290
  }
2269
2291
 
2270
- // line 801 "Parser.rl"
2292
+ // line 822 "Parser.rl"
2271
2293
 
2272
2294
  if (cs >= JSON_first_final && p == pe) {
2273
2295
  return result;
@@ -2276,6 +2298,259 @@ case 5:
2276
2298
  }
2277
2299
  }
2278
2300
 
2301
+
2302
+ // line 2303 "Parser.java"
2303
+ private static byte[] init__JSON_quirks_mode_actions_0()
2304
+ {
2305
+ return new byte [] {
2306
+ 0, 1, 0
2307
+ };
2308
+ }
2309
+
2310
+ private static final byte _JSON_quirks_mode_actions[] = init__JSON_quirks_mode_actions_0();
2311
+
2312
+
2313
+ private static byte[] init__JSON_quirks_mode_key_offsets_0()
2314
+ {
2315
+ return new byte [] {
2316
+ 0, 0, 16, 18, 19, 21, 22, 24, 25, 27, 28
2317
+ };
2318
+ }
2319
+
2320
+ private static final byte _JSON_quirks_mode_key_offsets[] = init__JSON_quirks_mode_key_offsets_0();
2321
+
2322
+
2323
+ private static char[] init__JSON_quirks_mode_trans_keys_0()
2324
+ {
2325
+ return new char [] {
2326
+ 13, 32, 34, 45, 47, 73, 78, 91, 102, 110, 116, 123,
2327
+ 9, 10, 48, 57, 42, 47, 42, 42, 47, 10, 42, 47,
2328
+ 42, 42, 47, 10, 13, 32, 47, 9, 10, 0
2329
+ };
2330
+ }
2331
+
2332
+ private static final char _JSON_quirks_mode_trans_keys[] = init__JSON_quirks_mode_trans_keys_0();
2333
+
2334
+
2335
+ private static byte[] init__JSON_quirks_mode_single_lengths_0()
2336
+ {
2337
+ return new byte [] {
2338
+ 0, 12, 2, 1, 2, 1, 2, 1, 2, 1, 3
2339
+ };
2340
+ }
2341
+
2342
+ private static final byte _JSON_quirks_mode_single_lengths[] = init__JSON_quirks_mode_single_lengths_0();
2343
+
2344
+
2345
+ private static byte[] init__JSON_quirks_mode_range_lengths_0()
2346
+ {
2347
+ return new byte [] {
2348
+ 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1
2349
+ };
2350
+ }
2351
+
2352
+ private static final byte _JSON_quirks_mode_range_lengths[] = init__JSON_quirks_mode_range_lengths_0();
2353
+
2354
+
2355
+ private static byte[] init__JSON_quirks_mode_index_offsets_0()
2356
+ {
2357
+ return new byte [] {
2358
+ 0, 0, 15, 18, 20, 23, 25, 28, 30, 33, 35
2359
+ };
2360
+ }
2361
+
2362
+ private static final byte _JSON_quirks_mode_index_offsets[] = init__JSON_quirks_mode_index_offsets_0();
2363
+
2364
+
2365
+ private static byte[] init__JSON_quirks_mode_indicies_0()
2366
+ {
2367
+ return new byte [] {
2368
+ 0, 0, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2,
2369
+ 0, 2, 1, 4, 5, 1, 6, 4, 6, 7, 4, 7,
2370
+ 5, 8, 9, 1, 10, 8, 10, 0, 8, 0, 9, 7,
2371
+ 7, 11, 7, 1, 0
2372
+ };
2373
+ }
2374
+
2375
+ private static final byte _JSON_quirks_mode_indicies[] = init__JSON_quirks_mode_indicies_0();
2376
+
2377
+
2378
+ private static byte[] init__JSON_quirks_mode_trans_targs_0()
2379
+ {
2380
+ return new byte [] {
2381
+ 1, 0, 10, 6, 3, 5, 4, 10, 7, 9, 8, 2
2382
+ };
2383
+ }
2384
+
2385
+ private static final byte _JSON_quirks_mode_trans_targs[] = init__JSON_quirks_mode_trans_targs_0();
2386
+
2387
+
2388
+ private static byte[] init__JSON_quirks_mode_trans_actions_0()
2389
+ {
2390
+ return new byte [] {
2391
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
2392
+ };
2393
+ }
2394
+
2395
+ private static final byte _JSON_quirks_mode_trans_actions[] = init__JSON_quirks_mode_trans_actions_0();
2396
+
2397
+
2398
+ static final int JSON_quirks_mode_start = 1;
2399
+ static final int JSON_quirks_mode_first_final = 10;
2400
+ static final int JSON_quirks_mode_error = 0;
2401
+
2402
+ static final int JSON_quirks_mode_en_main = 1;
2403
+
2404
+
2405
+ // line 850 "Parser.rl"
2406
+
2407
+
2408
+ public IRubyObject parseQuirksMode() {
2409
+ int cs = EVIL;
2410
+ int p, pe;
2411
+ IRubyObject result = null;
2412
+
2413
+
2414
+ // line 2415 "Parser.java"
2415
+ {
2416
+ cs = JSON_quirks_mode_start;
2417
+ }
2418
+
2419
+ // line 858 "Parser.rl"
2420
+ p = byteList.begin();
2421
+ pe = p + byteList.length();
2422
+
2423
+ // line 2424 "Parser.java"
2424
+ {
2425
+ int _klen;
2426
+ int _trans = 0;
2427
+ int _acts;
2428
+ int _nacts;
2429
+ int _keys;
2430
+ int _goto_targ = 0;
2431
+
2432
+ _goto: while (true) {
2433
+ switch ( _goto_targ ) {
2434
+ case 0:
2435
+ if ( p == pe ) {
2436
+ _goto_targ = 4;
2437
+ continue _goto;
2438
+ }
2439
+ if ( cs == 0 ) {
2440
+ _goto_targ = 5;
2441
+ continue _goto;
2442
+ }
2443
+ case 1:
2444
+ _match: do {
2445
+ _keys = _JSON_quirks_mode_key_offsets[cs];
2446
+ _trans = _JSON_quirks_mode_index_offsets[cs];
2447
+ _klen = _JSON_quirks_mode_single_lengths[cs];
2448
+ if ( _klen > 0 ) {
2449
+ int _lower = _keys;
2450
+ int _mid;
2451
+ int _upper = _keys + _klen - 1;
2452
+ while (true) {
2453
+ if ( _upper < _lower )
2454
+ break;
2455
+
2456
+ _mid = _lower + ((_upper-_lower) >> 1);
2457
+ if ( data[p] < _JSON_quirks_mode_trans_keys[_mid] )
2458
+ _upper = _mid - 1;
2459
+ else if ( data[p] > _JSON_quirks_mode_trans_keys[_mid] )
2460
+ _lower = _mid + 1;
2461
+ else {
2462
+ _trans += (_mid - _keys);
2463
+ break _match;
2464
+ }
2465
+ }
2466
+ _keys += _klen;
2467
+ _trans += _klen;
2468
+ }
2469
+
2470
+ _klen = _JSON_quirks_mode_range_lengths[cs];
2471
+ if ( _klen > 0 ) {
2472
+ int _lower = _keys;
2473
+ int _mid;
2474
+ int _upper = _keys + (_klen<<1) - 2;
2475
+ while (true) {
2476
+ if ( _upper < _lower )
2477
+ break;
2478
+
2479
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1);
2480
+ if ( data[p] < _JSON_quirks_mode_trans_keys[_mid] )
2481
+ _upper = _mid - 2;
2482
+ else if ( data[p] > _JSON_quirks_mode_trans_keys[_mid+1] )
2483
+ _lower = _mid + 2;
2484
+ else {
2485
+ _trans += ((_mid - _keys)>>1);
2486
+ break _match;
2487
+ }
2488
+ }
2489
+ _trans += _klen;
2490
+ }
2491
+ } while (false);
2492
+
2493
+ _trans = _JSON_quirks_mode_indicies[_trans];
2494
+ cs = _JSON_quirks_mode_trans_targs[_trans];
2495
+
2496
+ if ( _JSON_quirks_mode_trans_actions[_trans] != 0 ) {
2497
+ _acts = _JSON_quirks_mode_trans_actions[_trans];
2498
+ _nacts = (int) _JSON_quirks_mode_actions[_acts++];
2499
+ while ( _nacts-- > 0 )
2500
+ {
2501
+ switch ( _JSON_quirks_mode_actions[_acts++] )
2502
+ {
2503
+ case 0:
2504
+ // line 836 "Parser.rl"
2505
+ {
2506
+ ParserResult res = parseValue(p, pe);
2507
+ if (res == null) {
2508
+ p--;
2509
+ { p += 1; _goto_targ = 5; if (true) continue _goto;}
2510
+ } else {
2511
+ result = res.result;
2512
+ {p = (( res.p))-1;}
2513
+ }
2514
+ }
2515
+ break;
2516
+ // line 2517 "Parser.java"
2517
+ }
2518
+ }
2519
+ }
2520
+
2521
+ case 2:
2522
+ if ( cs == 0 ) {
2523
+ _goto_targ = 5;
2524
+ continue _goto;
2525
+ }
2526
+ if ( ++p != pe ) {
2527
+ _goto_targ = 1;
2528
+ continue _goto;
2529
+ }
2530
+ case 4:
2531
+ case 5:
2532
+ }
2533
+ break; }
2534
+ }
2535
+
2536
+ // line 861 "Parser.rl"
2537
+
2538
+ if (cs >= JSON_quirks_mode_first_final && p == pe) {
2539
+ return result;
2540
+ } else {
2541
+ throw unexpectedToken(p, pe);
2542
+ }
2543
+ }
2544
+
2545
+ public IRubyObject parse() {
2546
+ if (parser.quirksMode) {
2547
+ return parseQuirksMode();
2548
+ } else {
2549
+ return parseStrict();
2550
+ }
2551
+
2552
+ }
2553
+
2279
2554
  /**
2280
2555
  * Returns a subsequence of the source ByteList, based on source
2281
2556
  * array byte offsets (i.e., the ByteList's own begin offset is not