json_pure 1.5.3 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,12 @@
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
  */
7
7
  package json.ext;
8
8
 
9
+ import java.lang.ref.WeakReference;
9
10
  import org.jruby.Ruby;
10
11
  import org.jruby.RubyArray;
11
12
  import org.jruby.RubyBoolean;
@@ -24,7 +25,7 @@ import org.jruby.util.ByteList;
24
25
  /**
25
26
  * A class that populates the
26
27
  * <code>Json::Ext::Generator::GeneratorMethods</code> module.
27
- *
28
+ *
28
29
  * @author mernen
29
30
  */
30
31
  class GeneratorMethods {
@@ -45,9 +46,9 @@ class GeneratorMethods {
45
46
  defineMethods(module, "String", RbString.class);
46
47
  defineMethods(module, "TrueClass", RbTrue.class);
47
48
 
48
- info.stringExtendModule = module.defineModuleUnder("String")
49
- .defineModuleUnder("Extend");
50
- info.stringExtendModule.defineAnnotatedMethods(StringExtend.class);
49
+ info.stringExtendModule = new WeakReference<RubyModule>(module.defineModuleUnder("String")
50
+ .defineModuleUnder("Extend"));
51
+ info.stringExtendModule.get().defineAnnotatedMethods(StringExtend.class);
51
52
  }
52
53
 
53
54
  /**
@@ -140,7 +141,7 @@ class GeneratorMethods {
140
141
  RubyHash result = RubyHash.newHash(runtime);
141
142
 
142
143
  IRubyObject createId = RuntimeInfo.forRuntime(runtime)
143
- .jsonModule.callMethod(context, "create_id");
144
+ .jsonModule.get().callMethod(context, "create_id");
144
145
  result.op_aset(context, createId, self.getMetaClass().to_s());
145
146
 
146
147
  ByteList bl = self.getByteList();
@@ -158,7 +159,7 @@ class GeneratorMethods {
158
159
  public static IRubyObject included(ThreadContext context,
159
160
  IRubyObject vSelf, IRubyObject module) {
160
161
  RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
161
- return module.callMethod(context, "extend", info.stringExtendModule);
162
+ return module.callMethod(context, "extend", info.stringExtendModule.get());
162
163
  }
163
164
  }
164
165
 
@@ -1,12 +1,13 @@
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
  */
7
7
  package json.ext;
8
8
 
9
9
  import java.io.IOException;
10
+ import java.lang.ref.WeakReference;
10
11
 
11
12
  import org.jruby.Ruby;
12
13
  import org.jruby.RubyClass;
@@ -23,15 +24,15 @@ public class GeneratorService implements BasicLibraryService {
23
24
  runtime.getLoadService().require("json/common");
24
25
  RuntimeInfo info = RuntimeInfo.initRuntime(runtime);
25
26
 
26
- info.jsonModule = runtime.defineModule("JSON");
27
- RubyModule jsonExtModule = info.jsonModule.defineModuleUnder("Ext");
27
+ info.jsonModule = new WeakReference<RubyModule>(runtime.defineModule("JSON"));
28
+ RubyModule jsonExtModule = info.jsonModule.get().defineModuleUnder("Ext");
28
29
  RubyModule generatorModule = jsonExtModule.defineModuleUnder("Generator");
29
30
 
30
31
  RubyClass stateClass =
31
32
  generatorModule.defineClassUnder("State", runtime.getObject(),
32
33
  GeneratorState.ALLOCATOR);
33
34
  stateClass.defineAnnotatedMethods(GeneratorState.class);
34
- info.generatorStateClass = stateClass;
35
+ info.generatorStateClass = new WeakReference<RubyClass>(stateClass);
35
36
 
36
37
  RubyModule generatorMethods =
37
38
  generatorModule.defineModuleUnder("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
  */
@@ -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
@@ -118,7 +125,7 @@ public class GeneratorState extends RubyObject {
118
125
 
119
126
  static GeneratorState fromState(ThreadContext context, RuntimeInfo info,
120
127
  IRubyObject opts) {
121
- RubyClass klass = info.generatorStateClass;
128
+ RubyClass klass = info.generatorStateClass.get();
122
129
  if (opts != null) {
123
130
  // if the given parameter is a Generator::State, return itself
124
131
  if (klass.isInstance(opts)) return (GeneratorState)opts;
@@ -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
  }
@@ -382,15 +408,15 @@ public class GeneratorState extends RubyObject {
382
408
  private ByteList prepareByteList(ThreadContext context, IRubyObject value) {
383
409
  RubyString str = value.convertToString();
384
410
  RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
385
- if (info.encodingsSupported() && str.encoding(context) != info.utf8) {
386
- str = (RubyString)str.encode(context, info.utf8);
411
+ if (info.encodingsSupported() && str.encoding(context) != info.utf8.get()) {
412
+ str = (RubyString)str.encode(context, info.utf8.get());
387
413
  }
388
414
  return str.getByteList().dup();
389
415
  }
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
  */
@@ -84,8 +84,8 @@ final class OptionsReader {
84
84
 
85
85
  RubyString str = value.convertToString();
86
86
  RuntimeInfo info = getRuntimeInfo();
87
- if (info.encodingsSupported() && str.encoding(context) != info.utf8) {
88
- str = (RubyString)str.encode(context, info.utf8);
87
+ if (info.encodingsSupported() && str.encoding(context) != info.utf8.get()) {
88
+ str = (RubyString)str.encode(context, info.utf8.get());
89
89
  }
90
90
  return str;
91
91
  }
@@ -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,15 +121,19 @@ 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.
134
139
  * </dl>
@@ -144,20 +149,25 @@ public class Parser extends RubyObject {
144
149
 
145
150
  @JRubyMethod(required = 1, optional = 1, visibility = Visibility.PRIVATE)
146
151
  public IRubyObject initialize(ThreadContext context, IRubyObject[] args) {
147
- Ruby runtime = context.getRuntime();
148
- RubyString source = convertEncoding(context, args[0].convertToString());
152
+ Ruby runtime = context.getRuntime();
153
+ if (this.vSource != null) {
154
+ throw runtime.newTypeError("already initialized instance");
155
+ }
149
156
 
150
157
  OptionsReader opts = new OptionsReader(context, args.length > 1 ? args[1] : null);
151
158
  this.maxNesting = opts.getInt("max_nesting", DEFAULT_MAX_NESTING);
152
159
  this.allowNaN = opts.getBool("allow_nan", false);
153
160
  this.symbolizeNames = opts.getBool("symbolize_names", false);
161
+ this.quirksMode = opts.getBool("quirks_mode", false);
154
162
  this.createId = opts.getString("create_id", getCreateId(context));
155
163
  this.createAdditions = opts.getBool("create_additions", true);
156
164
  this.objectClass = opts.getClass("object_class", runtime.getHash());
157
165
  this.arrayClass = opts.getClass("array_class", runtime.getArray());
158
166
  this.match_string = opts.getHash("match_string");
159
167
 
160
- this.vSource = source;
168
+ this.vSource = args[0].convertToString();
169
+ if (!quirksMode) this.vSource = convertEncoding(context, vSource);
170
+
161
171
  return this;
162
172
  }
163
173
 
@@ -176,8 +186,8 @@ public class Parser extends RubyObject {
176
186
 
177
187
  if (info.encodingsSupported()) {
178
188
  RubyEncoding encoding = (RubyEncoding)source.encoding(context);
179
- if (encoding != info.ascii8bit) {
180
- return (RubyString)source.encode(context, info.utf8);
189
+ if (encoding != info.ascii8bit.get()) {
190
+ return (RubyString)source.encode(context, info.utf8.get());
181
191
  }
182
192
 
183
193
  String sniffedEncoding = sniffByteList(bl);
@@ -188,7 +198,7 @@ public class Parser extends RubyObject {
188
198
  String sniffedEncoding = sniffByteList(bl);
189
199
  if (sniffedEncoding == null) return source; // assume UTF-8
190
200
  Ruby runtime = context.getRuntime();
191
- return (RubyString)info.jsonModule.
201
+ return (RubyString)info.jsonModule.get().
192
202
  callMethod(context, "iconv",
193
203
  new IRubyObject[] {
194
204
  runtime.newString("utf-8"),
@@ -218,7 +228,7 @@ public class Parser extends RubyObject {
218
228
  private RubyString reinterpretEncoding(ThreadContext context,
219
229
  RubyString str, String sniffedEncoding) {
220
230
  RubyEncoding actualEncoding = info.getEncoding(context, sniffedEncoding);
221
- RubyEncoding targetEncoding = info.utf8;
231
+ RubyEncoding targetEncoding = info.utf8.get();
222
232
  RubyString dup = (RubyString)str.dup();
223
233
  dup.force_encoding(context, actualEncoding);
224
234
  return (RubyString)dup.encode_bang(context, targetEncoding);
@@ -226,7 +236,7 @@ public class Parser extends RubyObject {
226
236
 
227
237
  /**
228
238
  * <code>Parser#parse()</code>
229
- *
239
+ *
230
240
  * <p>Parses the current JSON text <code>source</code> and returns the
231
241
  * complete data structure as a result.
232
242
  */
@@ -237,13 +247,32 @@ public class Parser extends RubyObject {
237
247
 
238
248
  /**
239
249
  * <code>Parser#source()</code>
240
- *
250
+ *
241
251
  * <p>Returns a copy of the current <code>source</code> string, that was
242
252
  * used to construct this Parser.
243
253
  */
244
254
  @JRubyMethod(name = "source")
245
255
  public IRubyObject source_get() {
246
- return vSource.dup();
256
+ return checkAndGetSource().dup();
257
+ }
258
+
259
+ /**
260
+ * <code>Parser#quirks_mode?()</code>
261
+ *
262
+ * <p>If set to <code>true</code>, if the parse is in quirks_mode, false
263
+ * otherwise.
264
+ */
265
+ @JRubyMethod(name = "quirks_mode?")
266
+ public IRubyObject quirks_mode_p(ThreadContext context) {
267
+ return context.getRuntime().newBoolean(quirksMode);
268
+ }
269
+
270
+ public RubyString checkAndGetSource() {
271
+ if (vSource != null) {
272
+ return vSource;
273
+ } else {
274
+ throw getRuntime().newTypeError("uninitialized instance");
275
+ }
247
276
  }
248
277
 
249
278
  /**
@@ -251,13 +280,13 @@ public class Parser extends RubyObject {
251
280
  * set to <code>nil</code> or <code>false</code>, and a String if not.
252
281
  */
253
282
  private RubyString getCreateId(ThreadContext context) {
254
- IRubyObject v = info.jsonModule.callMethod(context, "create_id");
283
+ IRubyObject v = info.jsonModule.get().callMethod(context, "create_id");
255
284
  return v.isTrue() ? v.convertToString() : null;
256
285
  }
257
286
 
258
287
  /**
259
288
  * A string parsing session.
260
- *
289
+ *
261
290
  * <p>Once a ParserSession is instantiated, the source string should not
262
291
  * change until the parsing is complete. The ParserSession object assumes
263
292
  * the source {@link RubyString} is still associated to its original
@@ -281,7 +310,7 @@ public class Parser extends RubyObject {
281
310
  private ParserSession(Parser parser, ThreadContext context) {
282
311
  this.parser = parser;
283
312
  this.context = context;
284
- this.byteList = parser.vSource.getByteList();
313
+ this.byteList = parser.checkAndGetSource().getByteList();
285
314
  this.data = byteList.unsafeBytes();
286
315
  this.decoder = new StringDecoder(context);
287
316
  }
@@ -298,11 +327,11 @@ public class Parser extends RubyObject {
298
327
  }
299
328
 
300
329
 
301
- // line 324 "Parser.rl"
330
+ // line 353 "Parser.rl"
302
331
 
303
332
 
304
333
 
305
- // line 306 "Parser.java"
334
+ // line 335 "Parser.java"
306
335
  private static byte[] init__JSON_value_actions_0()
307
336
  {
308
337
  return new byte [] {
@@ -416,7 +445,7 @@ static final int JSON_value_error = 0;
416
445
  static final int JSON_value_en_main = 1;
417
446
 
418
447
 
419
- // line 430 "Parser.rl"
448
+ // line 459 "Parser.rl"
420
449
 
421
450
 
422
451
  ParserResult parseValue(int p, int pe) {
@@ -424,14 +453,14 @@ static final int JSON_value_en_main = 1;
424
453
  IRubyObject result = null;
425
454
 
426
455
 
427
- // line 428 "Parser.java"
456
+ // line 457 "Parser.java"
428
457
  {
429
458
  cs = JSON_value_start;
430
459
  }
431
460
 
432
- // line 437 "Parser.rl"
461
+ // line 466 "Parser.rl"
433
462
 
434
- // line 435 "Parser.java"
463
+ // line 464 "Parser.java"
435
464
  {
436
465
  int _klen;
437
466
  int _trans = 0;
@@ -457,13 +486,13 @@ case 1:
457
486
  while ( _nacts-- > 0 ) {
458
487
  switch ( _JSON_value_actions[_acts++] ) {
459
488
  case 9:
460
- // line 415 "Parser.rl"
489
+ // line 444 "Parser.rl"
461
490
  {
462
491
  p--;
463
492
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
464
493
  }
465
494
  break;
466
- // line 467 "Parser.java"
495
+ // line 496 "Parser.java"
467
496
  }
468
497
  }
469
498
 
@@ -526,25 +555,25 @@ case 1:
526
555
  switch ( _JSON_value_actions[_acts++] )
527
556
  {
528
557
  case 0:
529
- // line 332 "Parser.rl"
558
+ // line 361 "Parser.rl"
530
559
  {
531
560
  result = getRuntime().getNil();
532
561
  }
533
562
  break;
534
563
  case 1:
535
- // line 335 "Parser.rl"
564
+ // line 364 "Parser.rl"
536
565
  {
537
566
  result = getRuntime().getFalse();
538
567
  }
539
568
  break;
540
569
  case 2:
541
- // line 338 "Parser.rl"
570
+ // line 367 "Parser.rl"
542
571
  {
543
572
  result = getRuntime().getTrue();
544
573
  }
545
574
  break;
546
575
  case 3:
547
- // line 341 "Parser.rl"
576
+ // line 370 "Parser.rl"
548
577
  {
549
578
  if (parser.allowNaN) {
550
579
  result = getConstant(CONST_NAN);
@@ -554,7 +583,7 @@ case 1:
554
583
  }
555
584
  break;
556
585
  case 4:
557
- // line 348 "Parser.rl"
586
+ // line 377 "Parser.rl"
558
587
  {
559
588
  if (parser.allowNaN) {
560
589
  result = getConstant(CONST_INFINITY);
@@ -564,9 +593,9 @@ case 1:
564
593
  }
565
594
  break;
566
595
  case 5:
567
- // line 355 "Parser.rl"
596
+ // line 384 "Parser.rl"
568
597
  {
569
- if (pe > p + 9 &&
598
+ if (pe > p + 9 - (parser.quirksMode ? 1 : 0) &&
570
599
  absSubSequence(p, p + 9).toString().equals(JSON_MINUS_INFINITY)) {
571
600
 
572
601
  if (parser.allowNaN) {
@@ -593,7 +622,7 @@ case 1:
593
622
  }
594
623
  break;
595
624
  case 6:
596
- // line 381 "Parser.rl"
625
+ // line 410 "Parser.rl"
597
626
  {
598
627
  ParserResult res = parseString(p, pe);
599
628
  if (res == null) {
@@ -606,7 +635,7 @@ case 1:
606
635
  }
607
636
  break;
608
637
  case 7:
609
- // line 391 "Parser.rl"
638
+ // line 420 "Parser.rl"
610
639
  {
611
640
  currentNesting++;
612
641
  ParserResult res = parseArray(p, pe);
@@ -621,7 +650,7 @@ case 1:
621
650
  }
622
651
  break;
623
652
  case 8:
624
- // line 403 "Parser.rl"
653
+ // line 432 "Parser.rl"
625
654
  {
626
655
  currentNesting++;
627
656
  ParserResult res = parseObject(p, pe);
@@ -635,7 +664,7 @@ case 1:
635
664
  }
636
665
  }
637
666
  break;
638
- // line 639 "Parser.java"
667
+ // line 668 "Parser.java"
639
668
  }
640
669
  }
641
670
  }
@@ -655,7 +684,7 @@ case 5:
655
684
  break; }
656
685
  }
657
686
 
658
- // line 438 "Parser.rl"
687
+ // line 467 "Parser.rl"
659
688
 
660
689
  if (cs >= JSON_value_first_final && result != null) {
661
690
  return new ParserResult(result, p);
@@ -665,7 +694,7 @@ case 5:
665
694
  }
666
695
 
667
696
 
668
- // line 669 "Parser.java"
697
+ // line 698 "Parser.java"
669
698
  private static byte[] init__JSON_integer_actions_0()
670
699
  {
671
700
  return new byte [] {
@@ -679,7 +708,7 @@ private static final byte _JSON_integer_actions[] = init__JSON_integer_actions_0
679
708
  private static byte[] init__JSON_integer_key_offsets_0()
680
709
  {
681
710
  return new byte [] {
682
- 0, 0, 4, 7, 9, 11
711
+ 0, 0, 4, 7, 9, 9
683
712
  };
684
713
  }
685
714
 
@@ -709,7 +738,7 @@ private static final byte _JSON_integer_single_lengths[] = init__JSON_integer_si
709
738
  private static byte[] init__JSON_integer_range_lengths_0()
710
739
  {
711
740
  return new byte [] {
712
- 0, 1, 1, 1, 1, 0
741
+ 0, 1, 1, 1, 0, 1
713
742
  };
714
743
  }
715
744
 
@@ -719,7 +748,7 @@ private static final byte _JSON_integer_range_lengths[] = init__JSON_integer_ran
719
748
  private static byte[] init__JSON_integer_index_offsets_0()
720
749
  {
721
750
  return new byte [] {
722
- 0, 0, 4, 7, 9, 11
751
+ 0, 0, 4, 7, 9, 10
723
752
  };
724
753
  }
725
754
 
@@ -729,7 +758,7 @@ private static final byte _JSON_integer_index_offsets[] = init__JSON_integer_ind
729
758
  private static byte[] init__JSON_integer_indicies_0()
730
759
  {
731
760
  return new byte [] {
732
- 0, 2, 3, 1, 2, 3, 1, 1, 4, 3, 4, 1,
761
+ 0, 2, 3, 1, 2, 3, 1, 1, 4, 1, 3, 4,
733
762
  0
734
763
  };
735
764
  }
@@ -740,7 +769,7 @@ private static final byte _JSON_integer_indicies[] = init__JSON_integer_indicies
740
769
  private static byte[] init__JSON_integer_trans_targs_0()
741
770
  {
742
771
  return new byte [] {
743
- 2, 0, 3, 4, 5
772
+ 2, 0, 3, 5, 4
744
773
  };
745
774
  }
746
775
 
@@ -758,28 +787,28 @@ private static final byte _JSON_integer_trans_actions[] = init__JSON_integer_tra
758
787
 
759
788
 
760
789
  static final int JSON_integer_start = 1;
761
- static final int JSON_integer_first_final = 5;
790
+ static final int JSON_integer_first_final = 3;
762
791
  static final int JSON_integer_error = 0;
763
792
 
764
793
  static final int JSON_integer_en_main = 1;
765
794
 
766
795
 
767
- // line 457 "Parser.rl"
796
+ // line 486 "Parser.rl"
768
797
 
769
798
 
770
799
  ParserResult parseInteger(int p, int pe) {
771
800
  int cs = EVIL;
772
801
 
773
802
 
774
- // line 775 "Parser.java"
803
+ // line 804 "Parser.java"
775
804
  {
776
805
  cs = JSON_integer_start;
777
806
  }
778
807
 
779
- // line 463 "Parser.rl"
808
+ // line 492 "Parser.rl"
780
809
  int memo = p;
781
810
 
782
- // line 783 "Parser.java"
811
+ // line 812 "Parser.java"
783
812
  {
784
813
  int _klen;
785
814
  int _trans = 0;
@@ -860,13 +889,13 @@ case 1:
860
889
  switch ( _JSON_integer_actions[_acts++] )
861
890
  {
862
891
  case 0:
863
- // line 451 "Parser.rl"
892
+ // line 480 "Parser.rl"
864
893
  {
865
894
  p--;
866
895
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
867
896
  }
868
897
  break;
869
- // line 870 "Parser.java"
898
+ // line 899 "Parser.java"
870
899
  }
871
900
  }
872
901
  }
@@ -886,7 +915,7 @@ case 5:
886
915
  break; }
887
916
  }
888
917
 
889
- // line 465 "Parser.rl"
918
+ // line 494 "Parser.rl"
890
919
 
891
920
  if (cs < JSON_integer_first_final) {
892
921
  return null;
@@ -901,7 +930,7 @@ case 5:
901
930
  }
902
931
 
903
932
 
904
- // line 905 "Parser.java"
933
+ // line 934 "Parser.java"
905
934
  private static byte[] init__JSON_float_actions_0()
906
935
  {
907
936
  return new byte [] {
@@ -915,7 +944,7 @@ private static final byte _JSON_float_actions[] = init__JSON_float_actions_0();
915
944
  private static byte[] init__JSON_float_key_offsets_0()
916
945
  {
917
946
  return new byte [] {
918
- 0, 0, 4, 7, 10, 12, 18, 22, 24, 30, 35
947
+ 0, 0, 4, 7, 10, 12, 16, 18, 23, 29, 29
919
948
  };
920
949
  }
921
950
 
@@ -926,8 +955,8 @@ private static char[] init__JSON_float_trans_keys_0()
926
955
  {
927
956
  return new char [] {
928
957
  45, 48, 49, 57, 48, 49, 57, 46, 69, 101, 48, 57,
929
- 69, 101, 45, 46, 48, 57, 43, 45, 48, 57, 48, 57,
930
- 69, 101, 45, 46, 48, 57, 46, 69, 101, 48, 57, 0
958
+ 43, 45, 48, 57, 48, 57, 46, 69, 101, 48, 57, 69,
959
+ 101, 45, 46, 48, 57, 69, 101, 45, 46, 48, 57, 0
931
960
  };
932
961
  }
933
962
 
@@ -937,7 +966,7 @@ private static final char _JSON_float_trans_keys[] = init__JSON_float_trans_keys
937
966
  private static byte[] init__JSON_float_single_lengths_0()
938
967
  {
939
968
  return new byte [] {
940
- 0, 2, 1, 3, 0, 2, 2, 0, 2, 3, 0
969
+ 0, 2, 1, 3, 0, 2, 0, 3, 2, 0, 2
941
970
  };
942
971
  }
943
972
 
@@ -947,7 +976,7 @@ private static final byte _JSON_float_single_lengths[] = init__JSON_float_single
947
976
  private static byte[] init__JSON_float_range_lengths_0()
948
977
  {
949
978
  return new byte [] {
950
- 0, 1, 1, 0, 1, 2, 1, 1, 2, 1, 0
979
+ 0, 1, 1, 0, 1, 1, 1, 1, 2, 0, 2
951
980
  };
952
981
  }
953
982
 
@@ -957,7 +986,7 @@ private static final byte _JSON_float_range_lengths[] = init__JSON_float_range_l
957
986
  private static byte[] init__JSON_float_index_offsets_0()
958
987
  {
959
988
  return new byte [] {
960
- 0, 0, 4, 7, 11, 13, 18, 22, 24, 29, 34
989
+ 0, 0, 4, 7, 11, 13, 17, 19, 24, 29, 30
961
990
  };
962
991
  }
963
992
 
@@ -968,8 +997,8 @@ private static byte[] init__JSON_float_indicies_0()
968
997
  {
969
998
  return new byte [] {
970
999
  0, 2, 3, 1, 2, 3, 1, 4, 5, 5, 1, 6,
971
- 1, 5, 5, 1, 6, 7, 8, 8, 9, 1, 9, 1,
972
- 1, 1, 1, 9, 7, 4, 5, 5, 3, 1, 1, 0
1000
+ 1, 7, 7, 8, 1, 8, 1, 4, 5, 5, 3, 1,
1001
+ 5, 5, 1, 6, 9, 1, 1, 1, 1, 8, 9, 0
973
1002
  };
974
1003
  }
975
1004
 
@@ -979,7 +1008,7 @@ private static final byte _JSON_float_indicies[] = init__JSON_float_indicies_0()
979
1008
  private static byte[] init__JSON_float_trans_targs_0()
980
1009
  {
981
1010
  return new byte [] {
982
- 2, 0, 3, 9, 4, 6, 5, 10, 7, 8
1011
+ 2, 0, 3, 7, 4, 5, 8, 6, 10, 9
983
1012
  };
984
1013
  }
985
1014
 
@@ -989,7 +1018,7 @@ private static final byte _JSON_float_trans_targs[] = init__JSON_float_trans_tar
989
1018
  private static byte[] init__JSON_float_trans_actions_0()
990
1019
  {
991
1020
  return new byte [] {
992
- 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
1021
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
993
1022
  };
994
1023
  }
995
1024
 
@@ -997,28 +1026,28 @@ private static final byte _JSON_float_trans_actions[] = init__JSON_float_trans_a
997
1026
 
998
1027
 
999
1028
  static final int JSON_float_start = 1;
1000
- static final int JSON_float_first_final = 10;
1029
+ static final int JSON_float_first_final = 8;
1001
1030
  static final int JSON_float_error = 0;
1002
1031
 
1003
1032
  static final int JSON_float_en_main = 1;
1004
1033
 
1005
1034
 
1006
- // line 493 "Parser.rl"
1035
+ // line 522 "Parser.rl"
1007
1036
 
1008
1037
 
1009
1038
  ParserResult parseFloat(int p, int pe) {
1010
1039
  int cs = EVIL;
1011
1040
 
1012
1041
 
1013
- // line 1014 "Parser.java"
1042
+ // line 1043 "Parser.java"
1014
1043
  {
1015
1044
  cs = JSON_float_start;
1016
1045
  }
1017
1046
 
1018
- // line 499 "Parser.rl"
1047
+ // line 528 "Parser.rl"
1019
1048
  int memo = p;
1020
1049
 
1021
- // line 1022 "Parser.java"
1050
+ // line 1051 "Parser.java"
1022
1051
  {
1023
1052
  int _klen;
1024
1053
  int _trans = 0;
@@ -1099,13 +1128,13 @@ case 1:
1099
1128
  switch ( _JSON_float_actions[_acts++] )
1100
1129
  {
1101
1130
  case 0:
1102
- // line 484 "Parser.rl"
1131
+ // line 513 "Parser.rl"
1103
1132
  {
1104
1133
  p--;
1105
1134
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
1106
1135
  }
1107
1136
  break;
1108
- // line 1109 "Parser.java"
1137
+ // line 1138 "Parser.java"
1109
1138
  }
1110
1139
  }
1111
1140
  }
@@ -1125,7 +1154,7 @@ case 5:
1125
1154
  break; }
1126
1155
  }
1127
1156
 
1128
- // line 501 "Parser.rl"
1157
+ // line 530 "Parser.rl"
1129
1158
 
1130
1159
  if (cs < JSON_float_first_final) {
1131
1160
  return null;
@@ -1140,7 +1169,7 @@ case 5:
1140
1169
  }
1141
1170
 
1142
1171
 
1143
- // line 1144 "Parser.java"
1172
+ // line 1173 "Parser.java"
1144
1173
  private static byte[] init__JSON_string_actions_0()
1145
1174
  {
1146
1175
  return new byte [] {
@@ -1242,7 +1271,7 @@ static final int JSON_string_error = 0;
1242
1271
  static final int JSON_string_en_main = 1;
1243
1272
 
1244
1273
 
1245
- // line 545 "Parser.rl"
1274
+ // line 574 "Parser.rl"
1246
1275
 
1247
1276
 
1248
1277
  ParserResult parseString(int p, int pe) {
@@ -1250,15 +1279,15 @@ static final int JSON_string_en_main = 1;
1250
1279
  IRubyObject result = null;
1251
1280
 
1252
1281
 
1253
- // line 1254 "Parser.java"
1282
+ // line 1283 "Parser.java"
1254
1283
  {
1255
1284
  cs = JSON_string_start;
1256
1285
  }
1257
1286
 
1258
- // line 552 "Parser.rl"
1287
+ // line 581 "Parser.rl"
1259
1288
  int memo = p;
1260
1289
 
1261
- // line 1262 "Parser.java"
1290
+ // line 1291 "Parser.java"
1262
1291
  {
1263
1292
  int _klen;
1264
1293
  int _trans = 0;
@@ -1339,7 +1368,7 @@ case 1:
1339
1368
  switch ( _JSON_string_actions[_acts++] )
1340
1369
  {
1341
1370
  case 0:
1342
- // line 520 "Parser.rl"
1371
+ // line 549 "Parser.rl"
1343
1372
  {
1344
1373
  int offset = byteList.begin();
1345
1374
  ByteList decoded = decoder.decode(byteList, memo + 1 - offset,
@@ -1354,13 +1383,13 @@ case 1:
1354
1383
  }
1355
1384
  break;
1356
1385
  case 1:
1357
- // line 533 "Parser.rl"
1386
+ // line 562 "Parser.rl"
1358
1387
  {
1359
1388
  p--;
1360
1389
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
1361
1390
  }
1362
1391
  break;
1363
- // line 1364 "Parser.java"
1392
+ // line 1393 "Parser.java"
1364
1393
  }
1365
1394
  }
1366
1395
  }
@@ -1380,7 +1409,7 @@ case 5:
1380
1409
  break; }
1381
1410
  }
1382
1411
 
1383
- // line 554 "Parser.rl"
1412
+ // line 583 "Parser.rl"
1384
1413
 
1385
1414
  if (parser.createAdditions) {
1386
1415
  RubyHash match_string = parser.match_string;
@@ -1397,7 +1426,7 @@ case 5:
1397
1426
  }
1398
1427
  });
1399
1428
  } catch (JumpException e) { }
1400
- if (memoArray[1] != null) {
1429
+ if (memoArray[1] != null) {
1401
1430
  RubyClass klass = (RubyClass) memoArray[1];
1402
1431
  if (klass.respondsTo("json_creatable?") &&
1403
1432
  klass.callMethod(context, "json_creatable?").isTrue()) {
@@ -1415,7 +1444,7 @@ case 5:
1415
1444
  }
1416
1445
 
1417
1446
 
1418
- // line 1419 "Parser.java"
1447
+ // line 1448 "Parser.java"
1419
1448
  private static byte[] init__JSON_array_actions_0()
1420
1449
  {
1421
1450
  return new byte [] {
@@ -1528,7 +1557,7 @@ static final int JSON_array_error = 0;
1528
1557
  static final int JSON_array_en_main = 1;
1529
1558
 
1530
1559
 
1531
- // line 624 "Parser.rl"
1560
+ // line 653 "Parser.rl"
1532
1561
 
1533
1562
 
1534
1563
  ParserResult parseArray(int p, int pe) {
@@ -1546,14 +1575,14 @@ static final int JSON_array_en_main = 1;
1546
1575
  IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
1547
1576
 
1548
1577
 
1549
- // line 1550 "Parser.java"
1578
+ // line 1579 "Parser.java"
1550
1579
  {
1551
1580
  cs = JSON_array_start;
1552
1581
  }
1553
1582
 
1554
- // line 641 "Parser.rl"
1583
+ // line 670 "Parser.rl"
1555
1584
 
1556
- // line 1557 "Parser.java"
1585
+ // line 1586 "Parser.java"
1557
1586
  {
1558
1587
  int _klen;
1559
1588
  int _trans = 0;
@@ -1634,7 +1663,7 @@ case 1:
1634
1663
  switch ( _JSON_array_actions[_acts++] )
1635
1664
  {
1636
1665
  case 0:
1637
- // line 593 "Parser.rl"
1666
+ // line 622 "Parser.rl"
1638
1667
  {
1639
1668
  ParserResult res = parseValue(p, pe);
1640
1669
  if (res == null) {
@@ -1651,13 +1680,13 @@ case 1:
1651
1680
  }
1652
1681
  break;
1653
1682
  case 1:
1654
- // line 608 "Parser.rl"
1683
+ // line 637 "Parser.rl"
1655
1684
  {
1656
1685
  p--;
1657
1686
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
1658
1687
  }
1659
1688
  break;
1660
- // line 1661 "Parser.java"
1689
+ // line 1690 "Parser.java"
1661
1690
  }
1662
1691
  }
1663
1692
  }
@@ -1677,7 +1706,7 @@ case 5:
1677
1706
  break; }
1678
1707
  }
1679
1708
 
1680
- // line 642 "Parser.rl"
1709
+ // line 671 "Parser.rl"
1681
1710
 
1682
1711
  if (cs >= JSON_array_first_final) {
1683
1712
  return new ParserResult(result, p + 1);
@@ -1687,7 +1716,7 @@ case 5:
1687
1716
  }
1688
1717
 
1689
1718
 
1690
- // line 1691 "Parser.java"
1719
+ // line 1720 "Parser.java"
1691
1720
  private static byte[] init__JSON_object_actions_0()
1692
1721
  {
1693
1722
  return new byte [] {
@@ -1810,7 +1839,7 @@ static final int JSON_object_error = 0;
1810
1839
  static final int JSON_object_en_main = 1;
1811
1840
 
1812
1841
 
1813
- // line 702 "Parser.rl"
1842
+ // line 730 "Parser.rl"
1814
1843
 
1815
1844
 
1816
1845
  ParserResult parseObject(int p, int pe) {
@@ -1829,14 +1858,14 @@ static final int JSON_object_en_main = 1;
1829
1858
  IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
1830
1859
 
1831
1860
 
1832
- // line 1833 "Parser.java"
1861
+ // line 1862 "Parser.java"
1833
1862
  {
1834
1863
  cs = JSON_object_start;
1835
1864
  }
1836
1865
 
1837
- // line 720 "Parser.rl"
1866
+ // line 748 "Parser.rl"
1838
1867
 
1839
- // line 1840 "Parser.java"
1868
+ // line 1869 "Parser.java"
1840
1869
  {
1841
1870
  int _klen;
1842
1871
  int _trans = 0;
@@ -1917,7 +1946,7 @@ case 1:
1917
1946
  switch ( _JSON_object_actions[_acts++] )
1918
1947
  {
1919
1948
  case 0:
1920
- // line 656 "Parser.rl"
1949
+ // line 685 "Parser.rl"
1921
1950
  {
1922
1951
  ParserResult res = parseValue(p, pe);
1923
1952
  if (res == null) {
@@ -1934,7 +1963,7 @@ case 1:
1934
1963
  }
1935
1964
  break;
1936
1965
  case 1:
1937
- // line 671 "Parser.rl"
1966
+ // line 700 "Parser.rl"
1938
1967
  {
1939
1968
  ParserResult res = parseString(p, pe);
1940
1969
  if (res == null) {
@@ -1954,13 +1983,13 @@ case 1:
1954
1983
  }
1955
1984
  break;
1956
1985
  case 2:
1957
- // line 689 "Parser.rl"
1986
+ // line 718 "Parser.rl"
1958
1987
  {
1959
1988
  p--;
1960
1989
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
1961
1990
  }
1962
1991
  break;
1963
- // line 1964 "Parser.java"
1992
+ // line 1993 "Parser.java"
1964
1993
  }
1965
1994
  }
1966
1995
  }
@@ -1980,7 +2009,7 @@ case 5:
1980
2009
  break; }
1981
2010
  }
1982
2011
 
1983
- // line 721 "Parser.rl"
2012
+ // line 749 "Parser.rl"
1984
2013
 
1985
2014
  if (cs < JSON_object_first_final) {
1986
2015
  return null;
@@ -1993,7 +2022,7 @@ case 5:
1993
2022
  IRubyObject vKlassName = result.op_aref(context, parser.createId);
1994
2023
  if (!vKlassName.isNil()) {
1995
2024
  // might throw ArgumentError, we let it propagate
1996
- IRubyObject klass = parser.info.jsonModule.
2025
+ IRubyObject klass = parser.info.jsonModule.get().
1997
2026
  callMethod(context, "deep_const_get", vKlassName);
1998
2027
  if (klass.respondsTo("json_creatable?") &&
1999
2028
  klass.callMethod(context, "json_creatable?").isTrue()) {
@@ -2006,7 +2035,7 @@ case 5:
2006
2035
  }
2007
2036
 
2008
2037
 
2009
- // line 2010 "Parser.java"
2038
+ // line 2039 "Parser.java"
2010
2039
  private static byte[] init__JSON_actions_0()
2011
2040
  {
2012
2041
  return new byte [] {
@@ -2110,25 +2139,25 @@ static final int JSON_error = 0;
2110
2139
  static final int JSON_en_main = 1;
2111
2140
 
2112
2141
 
2113
- // line 779 "Parser.rl"
2142
+ // line 807 "Parser.rl"
2114
2143
 
2115
2144
 
2116
- public IRubyObject parse() {
2145
+ public IRubyObject parseStrict() {
2117
2146
  int cs = EVIL;
2118
2147
  int p, pe;
2119
2148
  IRubyObject result = null;
2120
2149
 
2121
2150
 
2122
- // line 2123 "Parser.java"
2151
+ // line 2152 "Parser.java"
2123
2152
  {
2124
2153
  cs = JSON_start;
2125
2154
  }
2126
2155
 
2127
- // line 787 "Parser.rl"
2156
+ // line 815 "Parser.rl"
2128
2157
  p = byteList.begin();
2129
2158
  pe = p + byteList.length();
2130
2159
 
2131
- // line 2132 "Parser.java"
2160
+ // line 2161 "Parser.java"
2132
2161
  {
2133
2162
  int _klen;
2134
2163
  int _trans = 0;
@@ -2209,7 +2238,7 @@ case 1:
2209
2238
  switch ( _JSON_actions[_acts++] )
2210
2239
  {
2211
2240
  case 0:
2212
- // line 751 "Parser.rl"
2241
+ // line 779 "Parser.rl"
2213
2242
  {
2214
2243
  currentNesting = 1;
2215
2244
  ParserResult res = parseObject(p, pe);
@@ -2223,7 +2252,7 @@ case 1:
2223
2252
  }
2224
2253
  break;
2225
2254
  case 1:
2226
- // line 763 "Parser.rl"
2255
+ // line 791 "Parser.rl"
2227
2256
  {
2228
2257
  currentNesting = 1;
2229
2258
  ParserResult res = parseArray(p, pe);
@@ -2236,7 +2265,7 @@ case 1:
2236
2265
  }
2237
2266
  }
2238
2267
  break;
2239
- // line 2240 "Parser.java"
2268
+ // line 2269 "Parser.java"
2240
2269
  }
2241
2270
  }
2242
2271
  }
@@ -2256,7 +2285,7 @@ case 5:
2256
2285
  break; }
2257
2286
  }
2258
2287
 
2259
- // line 790 "Parser.rl"
2288
+ // line 818 "Parser.rl"
2260
2289
 
2261
2290
  if (cs >= JSON_first_final && p == pe) {
2262
2291
  return result;
@@ -2265,6 +2294,259 @@ case 5:
2265
2294
  }
2266
2295
  }
2267
2296
 
2297
+
2298
+ // line 2299 "Parser.java"
2299
+ private static byte[] init__JSON_quirks_mode_actions_0()
2300
+ {
2301
+ return new byte [] {
2302
+ 0, 1, 0
2303
+ };
2304
+ }
2305
+
2306
+ private static final byte _JSON_quirks_mode_actions[] = init__JSON_quirks_mode_actions_0();
2307
+
2308
+
2309
+ private static byte[] init__JSON_quirks_mode_key_offsets_0()
2310
+ {
2311
+ return new byte [] {
2312
+ 0, 0, 16, 18, 19, 21, 22, 24, 25, 27, 28
2313
+ };
2314
+ }
2315
+
2316
+ private static final byte _JSON_quirks_mode_key_offsets[] = init__JSON_quirks_mode_key_offsets_0();
2317
+
2318
+
2319
+ private static char[] init__JSON_quirks_mode_trans_keys_0()
2320
+ {
2321
+ return new char [] {
2322
+ 13, 32, 34, 45, 47, 73, 78, 91, 102, 110, 116, 123,
2323
+ 9, 10, 48, 57, 42, 47, 42, 42, 47, 10, 42, 47,
2324
+ 42, 42, 47, 10, 13, 32, 47, 9, 10, 0
2325
+ };
2326
+ }
2327
+
2328
+ private static final char _JSON_quirks_mode_trans_keys[] = init__JSON_quirks_mode_trans_keys_0();
2329
+
2330
+
2331
+ private static byte[] init__JSON_quirks_mode_single_lengths_0()
2332
+ {
2333
+ return new byte [] {
2334
+ 0, 12, 2, 1, 2, 1, 2, 1, 2, 1, 3
2335
+ };
2336
+ }
2337
+
2338
+ private static final byte _JSON_quirks_mode_single_lengths[] = init__JSON_quirks_mode_single_lengths_0();
2339
+
2340
+
2341
+ private static byte[] init__JSON_quirks_mode_range_lengths_0()
2342
+ {
2343
+ return new byte [] {
2344
+ 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1
2345
+ };
2346
+ }
2347
+
2348
+ private static final byte _JSON_quirks_mode_range_lengths[] = init__JSON_quirks_mode_range_lengths_0();
2349
+
2350
+
2351
+ private static byte[] init__JSON_quirks_mode_index_offsets_0()
2352
+ {
2353
+ return new byte [] {
2354
+ 0, 0, 15, 18, 20, 23, 25, 28, 30, 33, 35
2355
+ };
2356
+ }
2357
+
2358
+ private static final byte _JSON_quirks_mode_index_offsets[] = init__JSON_quirks_mode_index_offsets_0();
2359
+
2360
+
2361
+ private static byte[] init__JSON_quirks_mode_indicies_0()
2362
+ {
2363
+ return new byte [] {
2364
+ 0, 0, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2,
2365
+ 0, 2, 1, 4, 5, 1, 6, 4, 6, 7, 4, 7,
2366
+ 5, 8, 9, 1, 10, 8, 10, 0, 8, 0, 9, 7,
2367
+ 7, 11, 7, 1, 0
2368
+ };
2369
+ }
2370
+
2371
+ private static final byte _JSON_quirks_mode_indicies[] = init__JSON_quirks_mode_indicies_0();
2372
+
2373
+
2374
+ private static byte[] init__JSON_quirks_mode_trans_targs_0()
2375
+ {
2376
+ return new byte [] {
2377
+ 1, 0, 10, 6, 3, 5, 4, 10, 7, 9, 8, 2
2378
+ };
2379
+ }
2380
+
2381
+ private static final byte _JSON_quirks_mode_trans_targs[] = init__JSON_quirks_mode_trans_targs_0();
2382
+
2383
+
2384
+ private static byte[] init__JSON_quirks_mode_trans_actions_0()
2385
+ {
2386
+ return new byte [] {
2387
+ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
2388
+ };
2389
+ }
2390
+
2391
+ private static final byte _JSON_quirks_mode_trans_actions[] = init__JSON_quirks_mode_trans_actions_0();
2392
+
2393
+
2394
+ static final int JSON_quirks_mode_start = 1;
2395
+ static final int JSON_quirks_mode_first_final = 10;
2396
+ static final int JSON_quirks_mode_error = 0;
2397
+
2398
+ static final int JSON_quirks_mode_en_main = 1;
2399
+
2400
+
2401
+ // line 846 "Parser.rl"
2402
+
2403
+
2404
+ public IRubyObject parseQuirksMode() {
2405
+ int cs = EVIL;
2406
+ int p, pe;
2407
+ IRubyObject result = null;
2408
+
2409
+
2410
+ // line 2411 "Parser.java"
2411
+ {
2412
+ cs = JSON_quirks_mode_start;
2413
+ }
2414
+
2415
+ // line 854 "Parser.rl"
2416
+ p = byteList.begin();
2417
+ pe = p + byteList.length();
2418
+
2419
+ // line 2420 "Parser.java"
2420
+ {
2421
+ int _klen;
2422
+ int _trans = 0;
2423
+ int _acts;
2424
+ int _nacts;
2425
+ int _keys;
2426
+ int _goto_targ = 0;
2427
+
2428
+ _goto: while (true) {
2429
+ switch ( _goto_targ ) {
2430
+ case 0:
2431
+ if ( p == pe ) {
2432
+ _goto_targ = 4;
2433
+ continue _goto;
2434
+ }
2435
+ if ( cs == 0 ) {
2436
+ _goto_targ = 5;
2437
+ continue _goto;
2438
+ }
2439
+ case 1:
2440
+ _match: do {
2441
+ _keys = _JSON_quirks_mode_key_offsets[cs];
2442
+ _trans = _JSON_quirks_mode_index_offsets[cs];
2443
+ _klen = _JSON_quirks_mode_single_lengths[cs];
2444
+ if ( _klen > 0 ) {
2445
+ int _lower = _keys;
2446
+ int _mid;
2447
+ int _upper = _keys + _klen - 1;
2448
+ while (true) {
2449
+ if ( _upper < _lower )
2450
+ break;
2451
+
2452
+ _mid = _lower + ((_upper-_lower) >> 1);
2453
+ if ( data[p] < _JSON_quirks_mode_trans_keys[_mid] )
2454
+ _upper = _mid - 1;
2455
+ else if ( data[p] > _JSON_quirks_mode_trans_keys[_mid] )
2456
+ _lower = _mid + 1;
2457
+ else {
2458
+ _trans += (_mid - _keys);
2459
+ break _match;
2460
+ }
2461
+ }
2462
+ _keys += _klen;
2463
+ _trans += _klen;
2464
+ }
2465
+
2466
+ _klen = _JSON_quirks_mode_range_lengths[cs];
2467
+ if ( _klen > 0 ) {
2468
+ int _lower = _keys;
2469
+ int _mid;
2470
+ int _upper = _keys + (_klen<<1) - 2;
2471
+ while (true) {
2472
+ if ( _upper < _lower )
2473
+ break;
2474
+
2475
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1);
2476
+ if ( data[p] < _JSON_quirks_mode_trans_keys[_mid] )
2477
+ _upper = _mid - 2;
2478
+ else if ( data[p] > _JSON_quirks_mode_trans_keys[_mid+1] )
2479
+ _lower = _mid + 2;
2480
+ else {
2481
+ _trans += ((_mid - _keys)>>1);
2482
+ break _match;
2483
+ }
2484
+ }
2485
+ _trans += _klen;
2486
+ }
2487
+ } while (false);
2488
+
2489
+ _trans = _JSON_quirks_mode_indicies[_trans];
2490
+ cs = _JSON_quirks_mode_trans_targs[_trans];
2491
+
2492
+ if ( _JSON_quirks_mode_trans_actions[_trans] != 0 ) {
2493
+ _acts = _JSON_quirks_mode_trans_actions[_trans];
2494
+ _nacts = (int) _JSON_quirks_mode_actions[_acts++];
2495
+ while ( _nacts-- > 0 )
2496
+ {
2497
+ switch ( _JSON_quirks_mode_actions[_acts++] )
2498
+ {
2499
+ case 0:
2500
+ // line 832 "Parser.rl"
2501
+ {
2502
+ ParserResult res = parseValue(p, pe);
2503
+ if (res == null) {
2504
+ p--;
2505
+ { p += 1; _goto_targ = 5; if (true) continue _goto;}
2506
+ } else {
2507
+ result = res.result;
2508
+ {p = (( res.p))-1;}
2509
+ }
2510
+ }
2511
+ break;
2512
+ // line 2513 "Parser.java"
2513
+ }
2514
+ }
2515
+ }
2516
+
2517
+ case 2:
2518
+ if ( cs == 0 ) {
2519
+ _goto_targ = 5;
2520
+ continue _goto;
2521
+ }
2522
+ if ( ++p != pe ) {
2523
+ _goto_targ = 1;
2524
+ continue _goto;
2525
+ }
2526
+ case 4:
2527
+ case 5:
2528
+ }
2529
+ break; }
2530
+ }
2531
+
2532
+ // line 857 "Parser.rl"
2533
+
2534
+ if (cs >= JSON_quirks_mode_first_final && p == pe) {
2535
+ return result;
2536
+ } else {
2537
+ throw unexpectedToken(p, pe);
2538
+ }
2539
+ }
2540
+
2541
+ public IRubyObject parse() {
2542
+ if (parser.quirksMode) {
2543
+ return parseQuirksMode();
2544
+ } else {
2545
+ return parseStrict();
2546
+ }
2547
+
2548
+ }
2549
+
2268
2550
  /**
2269
2551
  * Returns a subsequence of the source ByteList, based on source
2270
2552
  * array byte offsets (i.e., the ByteList's own begin offset is not
@@ -2283,7 +2565,7 @@ case 5:
2283
2565
  * @param name The constant name
2284
2566
  */
2285
2567
  private IRubyObject getConstant(String name) {
2286
- return parser.info.jsonModule.getConstant(name);
2568
+ return parser.info.jsonModule.get().getConstant(name);
2287
2569
  }
2288
2570
 
2289
2571
  private RaiseException newException(String className, String message) {