json 1.8.3 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +5 -5
  2. data/{CHANGES → CHANGES.md} +241 -90
  3. data/Gemfile +10 -6
  4. data/{COPYING-json-jruby → LICENSE} +5 -6
  5. data/{README.rdoc → README.md} +201 -134
  6. data/VERSION +1 -1
  7. data/ext/json/ext/fbuffer/fbuffer.h +0 -3
  8. data/ext/json/ext/generator/generator.c +264 -104
  9. data/ext/json/ext/generator/generator.h +12 -4
  10. data/ext/json/ext/parser/extconf.rb +28 -0
  11. data/ext/json/ext/parser/parser.c +425 -462
  12. data/ext/json/ext/parser/parser.h +5 -5
  13. data/ext/json/ext/parser/parser.rl +181 -181
  14. data/ext/json/extconf.rb +1 -1
  15. data/json.gemspec +0 -0
  16. data/lib/json.rb +550 -29
  17. data/lib/json/add/bigdecimal.rb +3 -2
  18. data/lib/json/add/complex.rb +4 -4
  19. data/lib/json/add/core.rb +1 -0
  20. data/lib/json/add/date.rb +1 -1
  21. data/lib/json/add/date_time.rb +1 -1
  22. data/lib/json/add/exception.rb +1 -1
  23. data/lib/json/add/ostruct.rb +3 -3
  24. data/lib/json/add/range.rb +1 -1
  25. data/lib/json/add/rational.rb +3 -3
  26. data/lib/json/add/regexp.rb +3 -3
  27. data/lib/json/add/set.rb +29 -0
  28. data/lib/json/add/struct.rb +1 -1
  29. data/lib/json/add/symbol.rb +1 -1
  30. data/lib/json/add/time.rb +1 -1
  31. data/lib/json/common.rb +381 -162
  32. data/lib/json/ext.rb +0 -6
  33. data/lib/json/generic_object.rb +5 -4
  34. data/lib/json/pure.rb +2 -8
  35. data/lib/json/pure/generator.rb +83 -126
  36. data/lib/json/pure/parser.rb +62 -84
  37. data/lib/json/version.rb +2 -1
  38. data/tests/fixtures/fail29.json +1 -0
  39. data/tests/fixtures/fail30.json +1 -0
  40. data/tests/fixtures/fail31.json +1 -0
  41. data/tests/fixtures/fail32.json +1 -0
  42. data/tests/fixtures/obsolete_fail1.json +1 -0
  43. data/tests/{test_json_addition.rb → json_addition_test.rb} +28 -25
  44. data/tests/json_common_interface_test.rb +169 -0
  45. data/tests/json_encoding_test.rb +107 -0
  46. data/tests/json_ext_parser_test.rb +15 -0
  47. data/tests/{test_json_fixtures.rb → json_fixtures_test.rb} +13 -8
  48. data/tests/{test_json_generate.rb → json_generator_test.rb} +109 -47
  49. data/tests/{test_json_generic_object.rb → json_generic_object_test.rb} +15 -8
  50. data/tests/json_parser_test.rb +497 -0
  51. data/tests/json_string_matching_test.rb +38 -0
  52. data/tests/lib/core_assertions.rb +763 -0
  53. data/tests/lib/envutil.rb +365 -0
  54. data/tests/lib/find_executable.rb +22 -0
  55. data/tests/lib/helper.rb +4 -0
  56. data/tests/ractor_test.rb +30 -0
  57. data/tests/test_helper.rb +17 -0
  58. metadata +48 -76
  59. data/.gitignore +0 -16
  60. data/.travis.yml +0 -26
  61. data/COPYING +0 -58
  62. data/GPL +0 -340
  63. data/README-json-jruby.markdown +0 -33
  64. data/Rakefile +0 -412
  65. data/TODO +0 -1
  66. data/data/example.json +0 -1
  67. data/data/index.html +0 -38
  68. data/data/prototype.js +0 -4184
  69. data/diagrams/.keep +0 -0
  70. data/install.rb +0 -23
  71. data/java/src/json/ext/ByteListTranscoder.java +0 -167
  72. data/java/src/json/ext/Generator.java +0 -444
  73. data/java/src/json/ext/GeneratorMethods.java +0 -232
  74. data/java/src/json/ext/GeneratorService.java +0 -43
  75. data/java/src/json/ext/GeneratorState.java +0 -543
  76. data/java/src/json/ext/OptionsReader.java +0 -114
  77. data/java/src/json/ext/Parser.java +0 -2645
  78. data/java/src/json/ext/Parser.rl +0 -969
  79. data/java/src/json/ext/ParserService.java +0 -35
  80. data/java/src/json/ext/RuntimeInfo.java +0 -121
  81. data/java/src/json/ext/StringDecoder.java +0 -167
  82. data/java/src/json/ext/StringEncoder.java +0 -106
  83. data/java/src/json/ext/Utils.java +0 -89
  84. data/json-java.gemspec +0 -23
  85. data/json_pure.gemspec +0 -40
  86. data/tests/fixtures/fail1.json +0 -1
  87. data/tests/setup_variant.rb +0 -11
  88. data/tests/test_json.rb +0 -553
  89. data/tests/test_json_encoding.rb +0 -65
  90. data/tests/test_json_string_matching.rb +0 -39
  91. data/tests/test_json_unicode.rb +0 -72
  92. data/tools/fuzz.rb +0 -139
  93. data/tools/server.rb +0 -62
@@ -1,114 +0,0 @@
1
- /*
2
- * This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
3
- *
4
- * Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
5
- * for details.
6
- */
7
- package json.ext;
8
-
9
- import org.jruby.Ruby;
10
- import org.jruby.RubyClass;
11
- import org.jruby.RubyHash;
12
- import org.jruby.RubyNumeric;
13
- import org.jruby.RubyString;
14
- import org.jruby.runtime.ThreadContext;
15
- import org.jruby.runtime.builtin.IRubyObject;
16
- import org.jruby.util.ByteList;
17
-
18
- final class OptionsReader {
19
- private final ThreadContext context;
20
- private final Ruby runtime;
21
- private final RubyHash opts;
22
- private RuntimeInfo info;
23
-
24
- OptionsReader(ThreadContext context, IRubyObject vOpts) {
25
- this.context = context;
26
- this.runtime = context.getRuntime();
27
- if (vOpts == null || vOpts.isNil()) {
28
- opts = null;
29
- } else if (vOpts.respondsTo("to_hash")) {
30
- opts = vOpts.convertToHash();
31
- } else if (vOpts.respondsTo("to_h")) {
32
- opts = vOpts.callMethod(context, "to_h").convertToHash();
33
- } else {
34
- opts = vOpts.convertToHash(); /* Should just raise the correct TypeError */
35
- }
36
- }
37
-
38
- private RuntimeInfo getRuntimeInfo() {
39
- if (info != null) return info;
40
- info = RuntimeInfo.forRuntime(runtime);
41
- return info;
42
- }
43
-
44
- /**
45
- * Efficiently looks up items with a {@link RubySymbol Symbol} key
46
- * @param key The Symbol name to look up for
47
- * @return The item in the {@link RubyHash Hash}, or <code>null</code>
48
- * if not found
49
- */
50
- IRubyObject get(String key) {
51
- return opts == null ? null : opts.fastARef(runtime.newSymbol(key));
52
- }
53
-
54
- boolean getBool(String key, boolean defaultValue) {
55
- IRubyObject value = get(key);
56
- return value == null ? defaultValue : value.isTrue();
57
- }
58
-
59
- int getInt(String key, int defaultValue) {
60
- IRubyObject value = get(key);
61
- if (value == null) return defaultValue;
62
- if (!value.isTrue()) return 0;
63
- return RubyNumeric.fix2int(value);
64
- }
65
-
66
- /**
67
- * Reads the setting from the options hash. If no entry is set for this
68
- * key or if it evaluates to <code>false</code>, returns null; attempts to
69
- * coerce the value to {@link RubyString String} otherwise.
70
- * @param key The Symbol name to look up for
71
- * @return <code>null</code> if the key is not in the Hash or if
72
- * its value evaluates to <code>false</code>
73
- * @throws RaiseException <code>TypeError</code> if the value does not
74
- * evaluate to <code>false</code> and can't be
75
- * converted to string
76
- */
77
- ByteList getString(String key) {
78
- RubyString str = getString(key, null);
79
- return str == null ? null : str.getByteList().dup();
80
- }
81
-
82
- RubyString getString(String key, RubyString defaultValue) {
83
- IRubyObject value = get(key);
84
- if (value == null || !value.isTrue()) return defaultValue;
85
-
86
- RubyString str = value.convertToString();
87
- RuntimeInfo info = getRuntimeInfo();
88
- if (info.encodingsSupported() && str.encoding(context) != info.utf8.get()) {
89
- str = (RubyString)str.encode(context, info.utf8.get());
90
- }
91
- return str;
92
- }
93
-
94
- /**
95
- * Reads the setting from the options hash. If it is <code>nil</code> or
96
- * undefined, returns the default value given.
97
- * If not, ensures it is a RubyClass instance and shares the same
98
- * allocator as the default value (i.e. for the basic types which have
99
- * their specific allocators, this ensures the passed value is
100
- * a subclass of them).
101
- */
102
- RubyClass getClass(String key, RubyClass defaultValue) {
103
- IRubyObject value = get(key);
104
-
105
- if (value == null || value.isNil()) return defaultValue;
106
- return (RubyClass)value;
107
- }
108
-
109
- public RubyHash getHash(String key) {
110
- IRubyObject value = get(key);
111
- if (value == null || value.isNil()) return new RubyHash(runtime);
112
- return (RubyHash) value;
113
- }
114
- }
@@ -1,2645 +0,0 @@
1
-
2
- // line 1 "Parser.rl"
3
- /*
4
- * This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
5
- *
6
- * Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
7
- * for details.
8
- */
9
- package json.ext;
10
-
11
- import org.jruby.Ruby;
12
- import org.jruby.RubyArray;
13
- import org.jruby.RubyClass;
14
- import org.jruby.RubyEncoding;
15
- import org.jruby.RubyFloat;
16
- import org.jruby.RubyHash;
17
- import org.jruby.RubyInteger;
18
- import org.jruby.RubyModule;
19
- import org.jruby.RubyNumeric;
20
- import org.jruby.RubyObject;
21
- import org.jruby.RubyString;
22
- import org.jruby.anno.JRubyMethod;
23
- import org.jruby.exceptions.JumpException;
24
- import org.jruby.exceptions.RaiseException;
25
- import org.jruby.runtime.Block;
26
- import org.jruby.runtime.ObjectAllocator;
27
- import org.jruby.runtime.ThreadContext;
28
- import org.jruby.runtime.Visibility;
29
- import org.jruby.runtime.builtin.IRubyObject;
30
- import org.jruby.util.ByteList;
31
- import org.jruby.util.ConvertBytes;
32
- import static org.jruby.util.ConvertDouble.DoubleConverter;
33
-
34
- /**
35
- * The <code>JSON::Ext::Parser</code> class.
36
- *
37
- * <p>This is the JSON parser implemented as a Java class. To use it as the
38
- * standard parser, set
39
- * <pre>JSON.parser = JSON::Ext::Parser</pre>
40
- * This is performed for you when you <code>include "json/ext"</code>.
41
- *
42
- * <p>This class does not perform the actual parsing, just acts as an interface
43
- * to Ruby code. When the {@link #parse()} method is invoked, a
44
- * Parser.ParserSession object is instantiated, which handles the process.
45
- *
46
- * @author mernen
47
- */
48
- public class Parser extends RubyObject {
49
- private final RuntimeInfo info;
50
- private RubyString vSource;
51
- private RubyString createId;
52
- private boolean createAdditions;
53
- private int maxNesting;
54
- private boolean allowNaN;
55
- private boolean symbolizeNames;
56
- private boolean quirksMode;
57
- private RubyClass objectClass;
58
- private RubyClass arrayClass;
59
- private RubyHash match_string;
60
-
61
- private static final int DEFAULT_MAX_NESTING = 100;
62
-
63
- private static final ByteList JSON_MINUS_INFINITY = new ByteList(ByteList.plain("-Infinity"));
64
- // constant names in the JSON module containing those values
65
- private static final String CONST_NAN = "NaN";
66
- private static final String CONST_INFINITY = "Infinity";
67
- private static final String CONST_MINUS_INFINITY = "MinusInfinity";
68
-
69
- static final ObjectAllocator ALLOCATOR = new ObjectAllocator() {
70
- public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
71
- return new Parser(runtime, klazz);
72
- }
73
- };
74
-
75
- /**
76
- * Multiple-value return for internal parser methods.
77
- *
78
- * <p>All the <code>parse<var>Stuff</var></code> methods return instances of
79
- * <code>ParserResult</code> when successful, or <code>null</code> when
80
- * there's a problem with the input data.
81
- */
82
- static final class ParserResult {
83
- /**
84
- * The result of the successful parsing. Should never be
85
- * <code>null</code>.
86
- */
87
- IRubyObject result;
88
- /**
89
- * The point where the parser returned.
90
- */
91
- int p;
92
-
93
- void update(IRubyObject result, int p) {
94
- this.result = result;
95
- this.p = p;
96
- }
97
- }
98
-
99
- public Parser(Ruby runtime, RubyClass metaClass) {
100
- super(runtime, metaClass);
101
- info = RuntimeInfo.forRuntime(runtime);
102
- }
103
-
104
- /**
105
- * <code>Parser.new(source, opts = {})</code>
106
- *
107
- * <p>Creates a new <code>JSON::Ext::Parser</code> instance for the string
108
- * <code>source</code>.
109
- * It will be configured by the <code>opts</code> Hash.
110
- * <code>opts</code> can have the following keys:
111
- *
112
- * <dl>
113
- * <dt><code>:max_nesting</code>
114
- * <dd>The maximum depth of nesting allowed in the parsed data
115
- * structures. Disable depth checking with <code>:max_nesting => false|nil|0</code>,
116
- * it defaults to 100.
117
- *
118
- * <dt><code>:allow_nan</code>
119
- * <dd>If set to <code>true</code>, allow <code>NaN</code>,
120
- * <code>Infinity</code> and <code>-Infinity</code> in defiance of RFC 4627
121
- * to be parsed by the Parser. This option defaults to <code>false</code>.
122
- *
123
- * <dt><code>:symbolize_names</code>
124
- * <dd>If set to <code>true</code>, returns symbols for the names (keys) in
125
- * a JSON object. Otherwise strings are returned, which is also the default.
126
- *
127
- * <dt><code>:quirks_mode?</code>
128
- * <dd>If set to <code>true</code>, if the parse is in quirks_mode, false
129
- * otherwise.
130
- *
131
- * <dt><code>:create_additions</code>
132
- * <dd>If set to <code>false</code>, the Parser doesn't create additions
133
- * even if a matching class and <code>create_id</code> was found. This option
134
- * defaults to <code>true</code>.
135
- *
136
- * <dt><code>:object_class</code>
137
- * <dd>Defaults to Hash.
138
- *
139
- * <dt><code>:array_class</code>
140
- * <dd>Defaults to Array.
141
- *
142
- * <dt><code>:quirks_mode</code>
143
- * <dd>Enables quirks_mode for parser, that is for example parsing single
144
- * JSON values instead of documents is possible.
145
- * </dl>
146
- */
147
- @JRubyMethod(name = "new", required = 1, optional = 1, meta = true)
148
- public static IRubyObject newInstance(IRubyObject clazz, IRubyObject[] args, Block block) {
149
- Parser parser = (Parser)((RubyClass)clazz).allocate();
150
-
151
- parser.callInit(args, block);
152
-
153
- return parser;
154
- }
155
-
156
- @JRubyMethod(required = 1, optional = 1, visibility = Visibility.PRIVATE)
157
- public IRubyObject initialize(ThreadContext context, IRubyObject[] args) {
158
- Ruby runtime = context.getRuntime();
159
- if (this.vSource != null) {
160
- throw runtime.newTypeError("already initialized instance");
161
- }
162
-
163
- OptionsReader opts = new OptionsReader(context, args.length > 1 ? args[1] : null);
164
- this.maxNesting = opts.getInt("max_nesting", DEFAULT_MAX_NESTING);
165
- this.allowNaN = opts.getBool("allow_nan", false);
166
- this.symbolizeNames = opts.getBool("symbolize_names", false);
167
- this.quirksMode = opts.getBool("quirks_mode", false);
168
- this.createId = opts.getString("create_id", getCreateId(context));
169
- this.createAdditions = opts.getBool("create_additions", false);
170
- this.objectClass = opts.getClass("object_class", runtime.getHash());
171
- this.arrayClass = opts.getClass("array_class", runtime.getArray());
172
- this.match_string = opts.getHash("match_string");
173
-
174
- this.vSource = args[0].convertToString();
175
- if (!quirksMode) this.vSource = convertEncoding(context, vSource);
176
-
177
- return this;
178
- }
179
-
180
- /**
181
- * Checks the given string's encoding. If a non-UTF-8 encoding is detected,
182
- * a converted copy is returned.
183
- * Returns the source string if no conversion is needed.
184
- */
185
- private RubyString convertEncoding(ThreadContext context, RubyString source) {
186
- ByteList bl = source.getByteList();
187
- int len = bl.length();
188
- if (len < 2) {
189
- throw Utils.newException(context, Utils.M_PARSER_ERROR,
190
- "A JSON text must at least contain two octets!");
191
- }
192
-
193
- if (info.encodingsSupported()) {
194
- RubyEncoding encoding = (RubyEncoding)source.encoding(context);
195
- if (encoding != info.ascii8bit.get()) {
196
- return (RubyString)source.encode(context, info.utf8.get());
197
- }
198
-
199
- String sniffedEncoding = sniffByteList(bl);
200
- if (sniffedEncoding == null) return source; // assume UTF-8
201
- return reinterpretEncoding(context, source, sniffedEncoding);
202
- }
203
-
204
- String sniffedEncoding = sniffByteList(bl);
205
- if (sniffedEncoding == null) return source; // assume UTF-8
206
- Ruby runtime = context.getRuntime();
207
- return (RubyString)info.jsonModule.get().
208
- callMethod(context, "iconv",
209
- new IRubyObject[] {
210
- runtime.newString("utf-8"),
211
- runtime.newString(sniffedEncoding),
212
- source});
213
- }
214
-
215
- /**
216
- * Checks the first four bytes of the given ByteList to infer its encoding,
217
- * using the principle demonstrated on section 3 of RFC 4627 (JSON).
218
- */
219
- private static String sniffByteList(ByteList bl) {
220
- if (bl.length() < 4) return null;
221
- if (bl.get(0) == 0 && bl.get(2) == 0) {
222
- return bl.get(1) == 0 ? "utf-32be" : "utf-16be";
223
- }
224
- if (bl.get(1) == 0 && bl.get(3) == 0) {
225
- return bl.get(2) == 0 ? "utf-32le" : "utf-16le";
226
- }
227
- return null;
228
- }
229
-
230
- /**
231
- * Assumes the given (binary) RubyString to be in the given encoding, then
232
- * converts it to UTF-8.
233
- */
234
- private RubyString reinterpretEncoding(ThreadContext context,
235
- RubyString str, String sniffedEncoding) {
236
- RubyEncoding actualEncoding = info.getEncoding(context, sniffedEncoding);
237
- RubyEncoding targetEncoding = info.utf8.get();
238
- RubyString dup = (RubyString)str.dup();
239
- dup.force_encoding(context, actualEncoding);
240
- return (RubyString)dup.encode_bang(context, targetEncoding);
241
- }
242
-
243
- /**
244
- * <code>Parser#parse()</code>
245
- *
246
- * <p>Parses the current JSON text <code>source</code> and returns the
247
- * complete data structure as a result.
248
- */
249
- @JRubyMethod
250
- public IRubyObject parse(ThreadContext context) {
251
- return new ParserSession(this, context, info).parse();
252
- }
253
-
254
- /**
255
- * <code>Parser#source()</code>
256
- *
257
- * <p>Returns a copy of the current <code>source</code> string, that was
258
- * used to construct this Parser.
259
- */
260
- @JRubyMethod(name = "source")
261
- public IRubyObject source_get() {
262
- return checkAndGetSource().dup();
263
- }
264
-
265
- /**
266
- * <code>Parser#quirks_mode?()</code>
267
- *
268
- * <p>If set to <code>true</code>, if the parse is in quirks_mode, false
269
- * otherwise.
270
- */
271
- @JRubyMethod(name = "quirks_mode?")
272
- public IRubyObject quirks_mode_p(ThreadContext context) {
273
- return context.getRuntime().newBoolean(quirksMode);
274
- }
275
-
276
- public RubyString checkAndGetSource() {
277
- if (vSource != null) {
278
- return vSource;
279
- } else {
280
- throw getRuntime().newTypeError("uninitialized instance");
281
- }
282
- }
283
-
284
- /**
285
- * Queries <code>JSON.create_id</code>. Returns <code>null</code> if it is
286
- * set to <code>nil</code> or <code>false</code>, and a String if not.
287
- */
288
- private RubyString getCreateId(ThreadContext context) {
289
- IRubyObject v = info.jsonModule.get().callMethod(context, "create_id");
290
- return v.isTrue() ? v.convertToString() : null;
291
- }
292
-
293
- /**
294
- * A string parsing session.
295
- *
296
- * <p>Once a ParserSession is instantiated, the source string should not
297
- * change until the parsing is complete. The ParserSession object assumes
298
- * the source {@link RubyString} is still associated to its original
299
- * {@link ByteList}, which in turn must still be bound to the same
300
- * <code>byte[]</code> value (and on the same offset).
301
- */
302
- // Ragel uses lots of fall-through
303
- @SuppressWarnings("fallthrough")
304
- private static class ParserSession {
305
- private final Parser parser;
306
- private final ThreadContext context;
307
- private final RuntimeInfo info;
308
- private final ByteList byteList;
309
- private final ByteList view;
310
- private final byte[] data;
311
- private final StringDecoder decoder;
312
- private int currentNesting = 0;
313
- private final DoubleConverter dc;
314
-
315
- // initialization value for all state variables.
316
- // no idea about the origins of this value, ask Flori ;)
317
- private static final int EVIL = 0x666;
318
-
319
- private ParserSession(Parser parser, ThreadContext context, RuntimeInfo info) {
320
- this.parser = parser;
321
- this.context = context;
322
- this.info = info;
323
- this.byteList = parser.checkAndGetSource().getByteList();
324
- this.data = byteList.unsafeBytes();
325
- this.view = new ByteList(data, false);
326
- this.decoder = new StringDecoder(context);
327
- this.dc = new DoubleConverter();
328
- }
329
-
330
- private RaiseException unexpectedToken(int absStart, int absEnd) {
331
- RubyString msg = getRuntime().newString("unexpected token at '")
332
- .cat(data, absStart, absEnd - absStart)
333
- .cat((byte)'\'');
334
- return newException(Utils.M_PARSER_ERROR, msg);
335
- }
336
-
337
- private Ruby getRuntime() {
338
- return context.getRuntime();
339
- }
340
-
341
-
342
- // line 365 "Parser.rl"
343
-
344
-
345
-
346
- // line 347 "Parser.java"
347
- private static byte[] init__JSON_value_actions_0()
348
- {
349
- return new byte [] {
350
- 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1,
351
- 5, 1, 6, 1, 7, 1, 8, 1, 9
352
- };
353
- }
354
-
355
- private static final byte _JSON_value_actions[] = init__JSON_value_actions_0();
356
-
357
-
358
- private static byte[] init__JSON_value_key_offsets_0()
359
- {
360
- return new byte [] {
361
- 0, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
362
- 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
363
- };
364
- }
365
-
366
- private static final byte _JSON_value_key_offsets[] = init__JSON_value_key_offsets_0();
367
-
368
-
369
- private static char[] init__JSON_value_trans_keys_0()
370
- {
371
- return new char [] {
372
- 34, 45, 73, 78, 91, 102, 110, 116, 123, 48, 57, 110,
373
- 102, 105, 110, 105, 116, 121, 97, 78, 97, 108, 115, 101,
374
- 117, 108, 108, 114, 117, 101, 0
375
- };
376
- }
377
-
378
- private static final char _JSON_value_trans_keys[] = init__JSON_value_trans_keys_0();
379
-
380
-
381
- private static byte[] init__JSON_value_single_lengths_0()
382
- {
383
- return new byte [] {
384
- 0, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
385
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
386
- };
387
- }
388
-
389
- private static final byte _JSON_value_single_lengths[] = init__JSON_value_single_lengths_0();
390
-
391
-
392
- private static byte[] init__JSON_value_range_lengths_0()
393
- {
394
- return new byte [] {
395
- 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
396
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
397
- };
398
- }
399
-
400
- private static final byte _JSON_value_range_lengths[] = init__JSON_value_range_lengths_0();
401
-
402
-
403
- private static byte[] init__JSON_value_index_offsets_0()
404
- {
405
- return new byte [] {
406
- 0, 0, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29,
407
- 31, 33, 35, 37, 39, 41, 43, 45, 47, 49
408
- };
409
- }
410
-
411
- private static final byte _JSON_value_index_offsets[] = init__JSON_value_index_offsets_0();
412
-
413
-
414
- private static byte[] init__JSON_value_trans_targs_0()
415
- {
416
- return new byte [] {
417
- 21, 21, 2, 9, 21, 11, 15, 18, 21, 21, 0, 3,
418
- 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 21,
419
- 0, 10, 0, 21, 0, 12, 0, 13, 0, 14, 0, 21,
420
- 0, 16, 0, 17, 0, 21, 0, 19, 0, 20, 0, 21,
421
- 0, 0, 0
422
- };
423
- }
424
-
425
- private static final byte _JSON_value_trans_targs[] = init__JSON_value_trans_targs_0();
426
-
427
-
428
- private static byte[] init__JSON_value_trans_actions_0()
429
- {
430
- return new byte [] {
431
- 13, 11, 0, 0, 15, 0, 0, 0, 17, 11, 0, 0,
432
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
433
- 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 3,
434
- 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 5,
435
- 0, 0, 0
436
- };
437
- }
438
-
439
- private static final byte _JSON_value_trans_actions[] = init__JSON_value_trans_actions_0();
440
-
441
-
442
- private static byte[] init__JSON_value_from_state_actions_0()
443
- {
444
- return new byte [] {
445
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
446
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 19
447
- };
448
- }
449
-
450
- private static final byte _JSON_value_from_state_actions[] = init__JSON_value_from_state_actions_0();
451
-
452
-
453
- static final int JSON_value_start = 1;
454
- static final int JSON_value_first_final = 21;
455
- static final int JSON_value_error = 0;
456
-
457
- static final int JSON_value_en_main = 1;
458
-
459
-
460
- // line 471 "Parser.rl"
461
-
462
-
463
- void parseValue(ParserResult res, int p, int pe) {
464
- int cs = EVIL;
465
- IRubyObject result = null;
466
-
467
-
468
- // line 469 "Parser.java"
469
- {
470
- cs = JSON_value_start;
471
- }
472
-
473
- // line 478 "Parser.rl"
474
-
475
- // line 476 "Parser.java"
476
- {
477
- int _klen;
478
- int _trans = 0;
479
- int _acts;
480
- int _nacts;
481
- int _keys;
482
- int _goto_targ = 0;
483
-
484
- _goto: while (true) {
485
- switch ( _goto_targ ) {
486
- case 0:
487
- if ( p == pe ) {
488
- _goto_targ = 4;
489
- continue _goto;
490
- }
491
- if ( cs == 0 ) {
492
- _goto_targ = 5;
493
- continue _goto;
494
- }
495
- case 1:
496
- _acts = _JSON_value_from_state_actions[cs];
497
- _nacts = (int) _JSON_value_actions[_acts++];
498
- while ( _nacts-- > 0 ) {
499
- switch ( _JSON_value_actions[_acts++] ) {
500
- case 9:
501
- // line 456 "Parser.rl"
502
- {
503
- p--;
504
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
505
- }
506
- break;
507
- // line 508 "Parser.java"
508
- }
509
- }
510
-
511
- _match: do {
512
- _keys = _JSON_value_key_offsets[cs];
513
- _trans = _JSON_value_index_offsets[cs];
514
- _klen = _JSON_value_single_lengths[cs];
515
- if ( _klen > 0 ) {
516
- int _lower = _keys;
517
- int _mid;
518
- int _upper = _keys + _klen - 1;
519
- while (true) {
520
- if ( _upper < _lower )
521
- break;
522
-
523
- _mid = _lower + ((_upper-_lower) >> 1);
524
- if ( data[p] < _JSON_value_trans_keys[_mid] )
525
- _upper = _mid - 1;
526
- else if ( data[p] > _JSON_value_trans_keys[_mid] )
527
- _lower = _mid + 1;
528
- else {
529
- _trans += (_mid - _keys);
530
- break _match;
531
- }
532
- }
533
- _keys += _klen;
534
- _trans += _klen;
535
- }
536
-
537
- _klen = _JSON_value_range_lengths[cs];
538
- if ( _klen > 0 ) {
539
- int _lower = _keys;
540
- int _mid;
541
- int _upper = _keys + (_klen<<1) - 2;
542
- while (true) {
543
- if ( _upper < _lower )
544
- break;
545
-
546
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
547
- if ( data[p] < _JSON_value_trans_keys[_mid] )
548
- _upper = _mid - 2;
549
- else if ( data[p] > _JSON_value_trans_keys[_mid+1] )
550
- _lower = _mid + 2;
551
- else {
552
- _trans += ((_mid - _keys)>>1);
553
- break _match;
554
- }
555
- }
556
- _trans += _klen;
557
- }
558
- } while (false);
559
-
560
- cs = _JSON_value_trans_targs[_trans];
561
-
562
- if ( _JSON_value_trans_actions[_trans] != 0 ) {
563
- _acts = _JSON_value_trans_actions[_trans];
564
- _nacts = (int) _JSON_value_actions[_acts++];
565
- while ( _nacts-- > 0 )
566
- {
567
- switch ( _JSON_value_actions[_acts++] )
568
- {
569
- case 0:
570
- // line 373 "Parser.rl"
571
- {
572
- result = getRuntime().getNil();
573
- }
574
- break;
575
- case 1:
576
- // line 376 "Parser.rl"
577
- {
578
- result = getRuntime().getFalse();
579
- }
580
- break;
581
- case 2:
582
- // line 379 "Parser.rl"
583
- {
584
- result = getRuntime().getTrue();
585
- }
586
- break;
587
- case 3:
588
- // line 382 "Parser.rl"
589
- {
590
- if (parser.allowNaN) {
591
- result = getConstant(CONST_NAN);
592
- } else {
593
- throw unexpectedToken(p - 2, pe);
594
- }
595
- }
596
- break;
597
- case 4:
598
- // line 389 "Parser.rl"
599
- {
600
- if (parser.allowNaN) {
601
- result = getConstant(CONST_INFINITY);
602
- } else {
603
- throw unexpectedToken(p - 7, pe);
604
- }
605
- }
606
- break;
607
- case 5:
608
- // line 396 "Parser.rl"
609
- {
610
- if (pe > p + 9 - (parser.quirksMode ? 1 : 0) &&
611
- absSubSequence(p, p + 9).equals(JSON_MINUS_INFINITY)) {
612
-
613
- if (parser.allowNaN) {
614
- result = getConstant(CONST_MINUS_INFINITY);
615
- {p = (( p + 10))-1;}
616
- p--;
617
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
618
- } else {
619
- throw unexpectedToken(p, pe);
620
- }
621
- }
622
- parseFloat(res, p, pe);
623
- if (res.result != null) {
624
- result = res.result;
625
- {p = (( res.p))-1;}
626
- }
627
- parseInteger(res, p, pe);
628
- if (res.result != null) {
629
- result = res.result;
630
- {p = (( res.p))-1;}
631
- }
632
- p--;
633
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
634
- }
635
- break;
636
- case 6:
637
- // line 422 "Parser.rl"
638
- {
639
- parseString(res, p, pe);
640
- if (res.result == null) {
641
- p--;
642
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
643
- } else {
644
- result = res.result;
645
- {p = (( res.p))-1;}
646
- }
647
- }
648
- break;
649
- case 7:
650
- // line 432 "Parser.rl"
651
- {
652
- currentNesting++;
653
- parseArray(res, p, pe);
654
- currentNesting--;
655
- if (res.result == null) {
656
- p--;
657
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
658
- } else {
659
- result = res.result;
660
- {p = (( res.p))-1;}
661
- }
662
- }
663
- break;
664
- case 8:
665
- // line 444 "Parser.rl"
666
- {
667
- currentNesting++;
668
- parseObject(res, p, pe);
669
- currentNesting--;
670
- if (res.result == null) {
671
- p--;
672
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
673
- } else {
674
- result = res.result;
675
- {p = (( res.p))-1;}
676
- }
677
- }
678
- break;
679
- // line 680 "Parser.java"
680
- }
681
- }
682
- }
683
-
684
- case 2:
685
- if ( cs == 0 ) {
686
- _goto_targ = 5;
687
- continue _goto;
688
- }
689
- if ( ++p != pe ) {
690
- _goto_targ = 1;
691
- continue _goto;
692
- }
693
- case 4:
694
- case 5:
695
- }
696
- break; }
697
- }
698
-
699
- // line 479 "Parser.rl"
700
-
701
- if (cs >= JSON_value_first_final && result != null) {
702
- res.update(result, p);
703
- } else {
704
- res.update(null, p);
705
- }
706
- }
707
-
708
-
709
- // line 710 "Parser.java"
710
- private static byte[] init__JSON_integer_actions_0()
711
- {
712
- return new byte [] {
713
- 0, 1, 0
714
- };
715
- }
716
-
717
- private static final byte _JSON_integer_actions[] = init__JSON_integer_actions_0();
718
-
719
-
720
- private static byte[] init__JSON_integer_key_offsets_0()
721
- {
722
- return new byte [] {
723
- 0, 0, 4, 7, 9, 9
724
- };
725
- }
726
-
727
- private static final byte _JSON_integer_key_offsets[] = init__JSON_integer_key_offsets_0();
728
-
729
-
730
- private static char[] init__JSON_integer_trans_keys_0()
731
- {
732
- return new char [] {
733
- 45, 48, 49, 57, 48, 49, 57, 48, 57, 48, 57, 0
734
- };
735
- }
736
-
737
- private static final char _JSON_integer_trans_keys[] = init__JSON_integer_trans_keys_0();
738
-
739
-
740
- private static byte[] init__JSON_integer_single_lengths_0()
741
- {
742
- return new byte [] {
743
- 0, 2, 1, 0, 0, 0
744
- };
745
- }
746
-
747
- private static final byte _JSON_integer_single_lengths[] = init__JSON_integer_single_lengths_0();
748
-
749
-
750
- private static byte[] init__JSON_integer_range_lengths_0()
751
- {
752
- return new byte [] {
753
- 0, 1, 1, 1, 0, 1
754
- };
755
- }
756
-
757
- private static final byte _JSON_integer_range_lengths[] = init__JSON_integer_range_lengths_0();
758
-
759
-
760
- private static byte[] init__JSON_integer_index_offsets_0()
761
- {
762
- return new byte [] {
763
- 0, 0, 4, 7, 9, 10
764
- };
765
- }
766
-
767
- private static final byte _JSON_integer_index_offsets[] = init__JSON_integer_index_offsets_0();
768
-
769
-
770
- private static byte[] init__JSON_integer_indicies_0()
771
- {
772
- return new byte [] {
773
- 0, 2, 3, 1, 2, 3, 1, 1, 4, 1, 3, 4,
774
- 0
775
- };
776
- }
777
-
778
- private static final byte _JSON_integer_indicies[] = init__JSON_integer_indicies_0();
779
-
780
-
781
- private static byte[] init__JSON_integer_trans_targs_0()
782
- {
783
- return new byte [] {
784
- 2, 0, 3, 5, 4
785
- };
786
- }
787
-
788
- private static final byte _JSON_integer_trans_targs[] = init__JSON_integer_trans_targs_0();
789
-
790
-
791
- private static byte[] init__JSON_integer_trans_actions_0()
792
- {
793
- return new byte [] {
794
- 0, 0, 0, 0, 1
795
- };
796
- }
797
-
798
- private static final byte _JSON_integer_trans_actions[] = init__JSON_integer_trans_actions_0();
799
-
800
-
801
- static final int JSON_integer_start = 1;
802
- static final int JSON_integer_first_final = 3;
803
- static final int JSON_integer_error = 0;
804
-
805
- static final int JSON_integer_en_main = 1;
806
-
807
-
808
- // line 498 "Parser.rl"
809
-
810
-
811
- void parseInteger(ParserResult res, int p, int pe) {
812
- int new_p = parseIntegerInternal(p, pe);
813
- if (new_p == -1) {
814
- res.update(null, p);
815
- return;
816
- }
817
- RubyInteger number = createInteger(p, new_p);
818
- res.update(number, new_p + 1);
819
- return;
820
- }
821
-
822
- int parseIntegerInternal(int p, int pe) {
823
- int cs = EVIL;
824
-
825
-
826
- // line 827 "Parser.java"
827
- {
828
- cs = JSON_integer_start;
829
- }
830
-
831
- // line 515 "Parser.rl"
832
- int memo = p;
833
-
834
- // line 835 "Parser.java"
835
- {
836
- int _klen;
837
- int _trans = 0;
838
- int _acts;
839
- int _nacts;
840
- int _keys;
841
- int _goto_targ = 0;
842
-
843
- _goto: while (true) {
844
- switch ( _goto_targ ) {
845
- case 0:
846
- if ( p == pe ) {
847
- _goto_targ = 4;
848
- continue _goto;
849
- }
850
- if ( cs == 0 ) {
851
- _goto_targ = 5;
852
- continue _goto;
853
- }
854
- case 1:
855
- _match: do {
856
- _keys = _JSON_integer_key_offsets[cs];
857
- _trans = _JSON_integer_index_offsets[cs];
858
- _klen = _JSON_integer_single_lengths[cs];
859
- if ( _klen > 0 ) {
860
- int _lower = _keys;
861
- int _mid;
862
- int _upper = _keys + _klen - 1;
863
- while (true) {
864
- if ( _upper < _lower )
865
- break;
866
-
867
- _mid = _lower + ((_upper-_lower) >> 1);
868
- if ( data[p] < _JSON_integer_trans_keys[_mid] )
869
- _upper = _mid - 1;
870
- else if ( data[p] > _JSON_integer_trans_keys[_mid] )
871
- _lower = _mid + 1;
872
- else {
873
- _trans += (_mid - _keys);
874
- break _match;
875
- }
876
- }
877
- _keys += _klen;
878
- _trans += _klen;
879
- }
880
-
881
- _klen = _JSON_integer_range_lengths[cs];
882
- if ( _klen > 0 ) {
883
- int _lower = _keys;
884
- int _mid;
885
- int _upper = _keys + (_klen<<1) - 2;
886
- while (true) {
887
- if ( _upper < _lower )
888
- break;
889
-
890
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
891
- if ( data[p] < _JSON_integer_trans_keys[_mid] )
892
- _upper = _mid - 2;
893
- else if ( data[p] > _JSON_integer_trans_keys[_mid+1] )
894
- _lower = _mid + 2;
895
- else {
896
- _trans += ((_mid - _keys)>>1);
897
- break _match;
898
- }
899
- }
900
- _trans += _klen;
901
- }
902
- } while (false);
903
-
904
- _trans = _JSON_integer_indicies[_trans];
905
- cs = _JSON_integer_trans_targs[_trans];
906
-
907
- if ( _JSON_integer_trans_actions[_trans] != 0 ) {
908
- _acts = _JSON_integer_trans_actions[_trans];
909
- _nacts = (int) _JSON_integer_actions[_acts++];
910
- while ( _nacts-- > 0 )
911
- {
912
- switch ( _JSON_integer_actions[_acts++] )
913
- {
914
- case 0:
915
- // line 492 "Parser.rl"
916
- {
917
- p--;
918
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
919
- }
920
- break;
921
- // line 922 "Parser.java"
922
- }
923
- }
924
- }
925
-
926
- case 2:
927
- if ( cs == 0 ) {
928
- _goto_targ = 5;
929
- continue _goto;
930
- }
931
- if ( ++p != pe ) {
932
- _goto_targ = 1;
933
- continue _goto;
934
- }
935
- case 4:
936
- case 5:
937
- }
938
- break; }
939
- }
940
-
941
- // line 517 "Parser.rl"
942
-
943
- if (cs < JSON_integer_first_final) {
944
- return -1;
945
- }
946
-
947
- return p;
948
- }
949
-
950
- RubyInteger createInteger(int p, int new_p) {
951
- Ruby runtime = getRuntime();
952
- ByteList num = absSubSequence(p, new_p);
953
- return bytesToInum(runtime, num);
954
- }
955
-
956
- RubyInteger bytesToInum(Ruby runtime, ByteList num) {
957
- return runtime.is1_9() ?
958
- ConvertBytes.byteListToInum19(runtime, num, 10, true) :
959
- ConvertBytes.byteListToInum(runtime, num, 10, true);
960
- }
961
-
962
-
963
- // line 964 "Parser.java"
964
- private static byte[] init__JSON_float_actions_0()
965
- {
966
- return new byte [] {
967
- 0, 1, 0
968
- };
969
- }
970
-
971
- private static final byte _JSON_float_actions[] = init__JSON_float_actions_0();
972
-
973
-
974
- private static byte[] init__JSON_float_key_offsets_0()
975
- {
976
- return new byte [] {
977
- 0, 0, 4, 7, 10, 12, 16, 18, 23, 29, 29
978
- };
979
- }
980
-
981
- private static final byte _JSON_float_key_offsets[] = init__JSON_float_key_offsets_0();
982
-
983
-
984
- private static char[] init__JSON_float_trans_keys_0()
985
- {
986
- return new char [] {
987
- 45, 48, 49, 57, 48, 49, 57, 46, 69, 101, 48, 57,
988
- 43, 45, 48, 57, 48, 57, 46, 69, 101, 48, 57, 69,
989
- 101, 45, 46, 48, 57, 69, 101, 45, 46, 48, 57, 0
990
- };
991
- }
992
-
993
- private static final char _JSON_float_trans_keys[] = init__JSON_float_trans_keys_0();
994
-
995
-
996
- private static byte[] init__JSON_float_single_lengths_0()
997
- {
998
- return new byte [] {
999
- 0, 2, 1, 3, 0, 2, 0, 3, 2, 0, 2
1000
- };
1001
- }
1002
-
1003
- private static final byte _JSON_float_single_lengths[] = init__JSON_float_single_lengths_0();
1004
-
1005
-
1006
- private static byte[] init__JSON_float_range_lengths_0()
1007
- {
1008
- return new byte [] {
1009
- 0, 1, 1, 0, 1, 1, 1, 1, 2, 0, 2
1010
- };
1011
- }
1012
-
1013
- private static final byte _JSON_float_range_lengths[] = init__JSON_float_range_lengths_0();
1014
-
1015
-
1016
- private static byte[] init__JSON_float_index_offsets_0()
1017
- {
1018
- return new byte [] {
1019
- 0, 0, 4, 7, 11, 13, 17, 19, 24, 29, 30
1020
- };
1021
- }
1022
-
1023
- private static final byte _JSON_float_index_offsets[] = init__JSON_float_index_offsets_0();
1024
-
1025
-
1026
- private static byte[] init__JSON_float_indicies_0()
1027
- {
1028
- return new byte [] {
1029
- 0, 2, 3, 1, 2, 3, 1, 4, 5, 5, 1, 6,
1030
- 1, 7, 7, 8, 1, 8, 1, 4, 5, 5, 3, 1,
1031
- 5, 5, 1, 6, 9, 1, 1, 1, 1, 8, 9, 0
1032
- };
1033
- }
1034
-
1035
- private static final byte _JSON_float_indicies[] = init__JSON_float_indicies_0();
1036
-
1037
-
1038
- private static byte[] init__JSON_float_trans_targs_0()
1039
- {
1040
- return new byte [] {
1041
- 2, 0, 3, 7, 4, 5, 8, 6, 10, 9
1042
- };
1043
- }
1044
-
1045
- private static final byte _JSON_float_trans_targs[] = init__JSON_float_trans_targs_0();
1046
-
1047
-
1048
- private static byte[] init__JSON_float_trans_actions_0()
1049
- {
1050
- return new byte [] {
1051
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
1052
- };
1053
- }
1054
-
1055
- private static final byte _JSON_float_trans_actions[] = init__JSON_float_trans_actions_0();
1056
-
1057
-
1058
- static final int JSON_float_start = 1;
1059
- static final int JSON_float_first_final = 8;
1060
- static final int JSON_float_error = 0;
1061
-
1062
- static final int JSON_float_en_main = 1;
1063
-
1064
-
1065
- // line 552 "Parser.rl"
1066
-
1067
-
1068
- void parseFloat(ParserResult res, int p, int pe) {
1069
- int new_p = parseFloatInternal(p, pe);
1070
- if (new_p == -1) {
1071
- res.update(null, p);
1072
- return;
1073
- }
1074
- RubyFloat number = createFloat(p, new_p);
1075
- res.update(number, new_p + 1);
1076
- return;
1077
- }
1078
-
1079
- int parseFloatInternal(int p, int pe) {
1080
- int cs = EVIL;
1081
-
1082
-
1083
- // line 1084 "Parser.java"
1084
- {
1085
- cs = JSON_float_start;
1086
- }
1087
-
1088
- // line 569 "Parser.rl"
1089
- int memo = p;
1090
-
1091
- // line 1092 "Parser.java"
1092
- {
1093
- int _klen;
1094
- int _trans = 0;
1095
- int _acts;
1096
- int _nacts;
1097
- int _keys;
1098
- int _goto_targ = 0;
1099
-
1100
- _goto: while (true) {
1101
- switch ( _goto_targ ) {
1102
- case 0:
1103
- if ( p == pe ) {
1104
- _goto_targ = 4;
1105
- continue _goto;
1106
- }
1107
- if ( cs == 0 ) {
1108
- _goto_targ = 5;
1109
- continue _goto;
1110
- }
1111
- case 1:
1112
- _match: do {
1113
- _keys = _JSON_float_key_offsets[cs];
1114
- _trans = _JSON_float_index_offsets[cs];
1115
- _klen = _JSON_float_single_lengths[cs];
1116
- if ( _klen > 0 ) {
1117
- int _lower = _keys;
1118
- int _mid;
1119
- int _upper = _keys + _klen - 1;
1120
- while (true) {
1121
- if ( _upper < _lower )
1122
- break;
1123
-
1124
- _mid = _lower + ((_upper-_lower) >> 1);
1125
- if ( data[p] < _JSON_float_trans_keys[_mid] )
1126
- _upper = _mid - 1;
1127
- else if ( data[p] > _JSON_float_trans_keys[_mid] )
1128
- _lower = _mid + 1;
1129
- else {
1130
- _trans += (_mid - _keys);
1131
- break _match;
1132
- }
1133
- }
1134
- _keys += _klen;
1135
- _trans += _klen;
1136
- }
1137
-
1138
- _klen = _JSON_float_range_lengths[cs];
1139
- if ( _klen > 0 ) {
1140
- int _lower = _keys;
1141
- int _mid;
1142
- int _upper = _keys + (_klen<<1) - 2;
1143
- while (true) {
1144
- if ( _upper < _lower )
1145
- break;
1146
-
1147
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
1148
- if ( data[p] < _JSON_float_trans_keys[_mid] )
1149
- _upper = _mid - 2;
1150
- else if ( data[p] > _JSON_float_trans_keys[_mid+1] )
1151
- _lower = _mid + 2;
1152
- else {
1153
- _trans += ((_mid - _keys)>>1);
1154
- break _match;
1155
- }
1156
- }
1157
- _trans += _klen;
1158
- }
1159
- } while (false);
1160
-
1161
- _trans = _JSON_float_indicies[_trans];
1162
- cs = _JSON_float_trans_targs[_trans];
1163
-
1164
- if ( _JSON_float_trans_actions[_trans] != 0 ) {
1165
- _acts = _JSON_float_trans_actions[_trans];
1166
- _nacts = (int) _JSON_float_actions[_acts++];
1167
- while ( _nacts-- > 0 )
1168
- {
1169
- switch ( _JSON_float_actions[_acts++] )
1170
- {
1171
- case 0:
1172
- // line 543 "Parser.rl"
1173
- {
1174
- p--;
1175
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
1176
- }
1177
- break;
1178
- // line 1179 "Parser.java"
1179
- }
1180
- }
1181
- }
1182
-
1183
- case 2:
1184
- if ( cs == 0 ) {
1185
- _goto_targ = 5;
1186
- continue _goto;
1187
- }
1188
- if ( ++p != pe ) {
1189
- _goto_targ = 1;
1190
- continue _goto;
1191
- }
1192
- case 4:
1193
- case 5:
1194
- }
1195
- break; }
1196
- }
1197
-
1198
- // line 571 "Parser.rl"
1199
-
1200
- if (cs < JSON_float_first_final) {
1201
- return -1;
1202
- }
1203
-
1204
- return p;
1205
- }
1206
-
1207
- RubyFloat createFloat(int p, int new_p) {
1208
- Ruby runtime = getRuntime();
1209
- ByteList num = absSubSequence(p, new_p);
1210
- return RubyFloat.newFloat(runtime, dc.parse(num, true, runtime.is1_9()));
1211
- }
1212
-
1213
-
1214
- // line 1215 "Parser.java"
1215
- private static byte[] init__JSON_string_actions_0()
1216
- {
1217
- return new byte [] {
1218
- 0, 2, 0, 1
1219
- };
1220
- }
1221
-
1222
- private static final byte _JSON_string_actions[] = init__JSON_string_actions_0();
1223
-
1224
-
1225
- private static byte[] init__JSON_string_key_offsets_0()
1226
- {
1227
- return new byte [] {
1228
- 0, 0, 1, 5, 8, 14, 20, 26, 32
1229
- };
1230
- }
1231
-
1232
- private static final byte _JSON_string_key_offsets[] = init__JSON_string_key_offsets_0();
1233
-
1234
-
1235
- private static char[] init__JSON_string_trans_keys_0()
1236
- {
1237
- return new char [] {
1238
- 34, 34, 92, 0, 31, 117, 0, 31, 48, 57, 65, 70,
1239
- 97, 102, 48, 57, 65, 70, 97, 102, 48, 57, 65, 70,
1240
- 97, 102, 48, 57, 65, 70, 97, 102, 0
1241
- };
1242
- }
1243
-
1244
- private static final char _JSON_string_trans_keys[] = init__JSON_string_trans_keys_0();
1245
-
1246
-
1247
- private static byte[] init__JSON_string_single_lengths_0()
1248
- {
1249
- return new byte [] {
1250
- 0, 1, 2, 1, 0, 0, 0, 0, 0
1251
- };
1252
- }
1253
-
1254
- private static final byte _JSON_string_single_lengths[] = init__JSON_string_single_lengths_0();
1255
-
1256
-
1257
- private static byte[] init__JSON_string_range_lengths_0()
1258
- {
1259
- return new byte [] {
1260
- 0, 0, 1, 1, 3, 3, 3, 3, 0
1261
- };
1262
- }
1263
-
1264
- private static final byte _JSON_string_range_lengths[] = init__JSON_string_range_lengths_0();
1265
-
1266
-
1267
- private static byte[] init__JSON_string_index_offsets_0()
1268
- {
1269
- return new byte [] {
1270
- 0, 0, 2, 6, 9, 13, 17, 21, 25
1271
- };
1272
- }
1273
-
1274
- private static final byte _JSON_string_index_offsets[] = init__JSON_string_index_offsets_0();
1275
-
1276
-
1277
- private static byte[] init__JSON_string_indicies_0()
1278
- {
1279
- return new byte [] {
1280
- 0, 1, 2, 3, 1, 0, 4, 1, 0, 5, 5, 5,
1281
- 1, 6, 6, 6, 1, 7, 7, 7, 1, 0, 0, 0,
1282
- 1, 1, 0
1283
- };
1284
- }
1285
-
1286
- private static final byte _JSON_string_indicies[] = init__JSON_string_indicies_0();
1287
-
1288
-
1289
- private static byte[] init__JSON_string_trans_targs_0()
1290
- {
1291
- return new byte [] {
1292
- 2, 0, 8, 3, 4, 5, 6, 7
1293
- };
1294
- }
1295
-
1296
- private static final byte _JSON_string_trans_targs[] = init__JSON_string_trans_targs_0();
1297
-
1298
-
1299
- private static byte[] init__JSON_string_trans_actions_0()
1300
- {
1301
- return new byte [] {
1302
- 0, 0, 1, 0, 0, 0, 0, 0
1303
- };
1304
- }
1305
-
1306
- private static final byte _JSON_string_trans_actions[] = init__JSON_string_trans_actions_0();
1307
-
1308
-
1309
- static final int JSON_string_start = 1;
1310
- static final int JSON_string_first_final = 8;
1311
- static final int JSON_string_error = 0;
1312
-
1313
- static final int JSON_string_en_main = 1;
1314
-
1315
-
1316
- // line 616 "Parser.rl"
1317
-
1318
-
1319
- void parseString(ParserResult res, int p, int pe) {
1320
- int cs = EVIL;
1321
- IRubyObject result = null;
1322
-
1323
-
1324
- // line 1325 "Parser.java"
1325
- {
1326
- cs = JSON_string_start;
1327
- }
1328
-
1329
- // line 623 "Parser.rl"
1330
- int memo = p;
1331
-
1332
- // line 1333 "Parser.java"
1333
- {
1334
- int _klen;
1335
- int _trans = 0;
1336
- int _acts;
1337
- int _nacts;
1338
- int _keys;
1339
- int _goto_targ = 0;
1340
-
1341
- _goto: while (true) {
1342
- switch ( _goto_targ ) {
1343
- case 0:
1344
- if ( p == pe ) {
1345
- _goto_targ = 4;
1346
- continue _goto;
1347
- }
1348
- if ( cs == 0 ) {
1349
- _goto_targ = 5;
1350
- continue _goto;
1351
- }
1352
- case 1:
1353
- _match: do {
1354
- _keys = _JSON_string_key_offsets[cs];
1355
- _trans = _JSON_string_index_offsets[cs];
1356
- _klen = _JSON_string_single_lengths[cs];
1357
- if ( _klen > 0 ) {
1358
- int _lower = _keys;
1359
- int _mid;
1360
- int _upper = _keys + _klen - 1;
1361
- while (true) {
1362
- if ( _upper < _lower )
1363
- break;
1364
-
1365
- _mid = _lower + ((_upper-_lower) >> 1);
1366
- if ( data[p] < _JSON_string_trans_keys[_mid] )
1367
- _upper = _mid - 1;
1368
- else if ( data[p] > _JSON_string_trans_keys[_mid] )
1369
- _lower = _mid + 1;
1370
- else {
1371
- _trans += (_mid - _keys);
1372
- break _match;
1373
- }
1374
- }
1375
- _keys += _klen;
1376
- _trans += _klen;
1377
- }
1378
-
1379
- _klen = _JSON_string_range_lengths[cs];
1380
- if ( _klen > 0 ) {
1381
- int _lower = _keys;
1382
- int _mid;
1383
- int _upper = _keys + (_klen<<1) - 2;
1384
- while (true) {
1385
- if ( _upper < _lower )
1386
- break;
1387
-
1388
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
1389
- if ( data[p] < _JSON_string_trans_keys[_mid] )
1390
- _upper = _mid - 2;
1391
- else if ( data[p] > _JSON_string_trans_keys[_mid+1] )
1392
- _lower = _mid + 2;
1393
- else {
1394
- _trans += ((_mid - _keys)>>1);
1395
- break _match;
1396
- }
1397
- }
1398
- _trans += _klen;
1399
- }
1400
- } while (false);
1401
-
1402
- _trans = _JSON_string_indicies[_trans];
1403
- cs = _JSON_string_trans_targs[_trans];
1404
-
1405
- if ( _JSON_string_trans_actions[_trans] != 0 ) {
1406
- _acts = _JSON_string_trans_actions[_trans];
1407
- _nacts = (int) _JSON_string_actions[_acts++];
1408
- while ( _nacts-- > 0 )
1409
- {
1410
- switch ( _JSON_string_actions[_acts++] )
1411
- {
1412
- case 0:
1413
- // line 591 "Parser.rl"
1414
- {
1415
- int offset = byteList.begin();
1416
- ByteList decoded = decoder.decode(byteList, memo + 1 - offset,
1417
- p - offset);
1418
- result = getRuntime().newString(decoded);
1419
- if (result == null) {
1420
- p--;
1421
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
1422
- } else {
1423
- {p = (( p + 1))-1;}
1424
- }
1425
- }
1426
- break;
1427
- case 1:
1428
- // line 604 "Parser.rl"
1429
- {
1430
- p--;
1431
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
1432
- }
1433
- break;
1434
- // line 1435 "Parser.java"
1435
- }
1436
- }
1437
- }
1438
-
1439
- case 2:
1440
- if ( cs == 0 ) {
1441
- _goto_targ = 5;
1442
- continue _goto;
1443
- }
1444
- if ( ++p != pe ) {
1445
- _goto_targ = 1;
1446
- continue _goto;
1447
- }
1448
- case 4:
1449
- case 5:
1450
- }
1451
- break; }
1452
- }
1453
-
1454
- // line 625 "Parser.rl"
1455
-
1456
- if (parser.createAdditions) {
1457
- RubyHash match_string = parser.match_string;
1458
- if (match_string != null) {
1459
- final IRubyObject[] memoArray = { result, null };
1460
- try {
1461
- match_string.visitAll(new RubyHash.Visitor() {
1462
- @Override
1463
- public void visit(IRubyObject pattern, IRubyObject klass) {
1464
- if (pattern.callMethod(context, "===", memoArray[0]).isTrue()) {
1465
- memoArray[1] = klass;
1466
- throw JumpException.SPECIAL_JUMP;
1467
- }
1468
- }
1469
- });
1470
- } catch (JumpException e) { }
1471
- if (memoArray[1] != null) {
1472
- RubyClass klass = (RubyClass) memoArray[1];
1473
- if (klass.respondsTo("json_creatable?") &&
1474
- klass.callMethod(context, "json_creatable?").isTrue()) {
1475
- result = klass.callMethod(context, "json_create", result);
1476
- }
1477
- }
1478
- }
1479
- }
1480
-
1481
- if (cs >= JSON_string_first_final && result != null) {
1482
- if (info.encodingsSupported() && result instanceof RubyString) {
1483
- ((RubyString)result).force_encoding(context, info.utf8.get());
1484
- }
1485
- res.update(result, p + 1);
1486
- } else {
1487
- res.update(null, p + 1);
1488
- }
1489
- }
1490
-
1491
-
1492
- // line 1493 "Parser.java"
1493
- private static byte[] init__JSON_array_actions_0()
1494
- {
1495
- return new byte [] {
1496
- 0, 1, 0, 1, 1
1497
- };
1498
- }
1499
-
1500
- private static final byte _JSON_array_actions[] = init__JSON_array_actions_0();
1501
-
1502
-
1503
- private static byte[] init__JSON_array_key_offsets_0()
1504
- {
1505
- return new byte [] {
1506
- 0, 0, 1, 18, 25, 41, 43, 44, 46, 47, 49, 50,
1507
- 52, 53, 55, 56, 58, 59
1508
- };
1509
- }
1510
-
1511
- private static final byte _JSON_array_key_offsets[] = init__JSON_array_key_offsets_0();
1512
-
1513
-
1514
- private static char[] init__JSON_array_trans_keys_0()
1515
- {
1516
- return new char [] {
1517
- 91, 13, 32, 34, 45, 47, 73, 78, 91, 93, 102, 110,
1518
- 116, 123, 9, 10, 48, 57, 13, 32, 44, 47, 93, 9,
1519
- 10, 13, 32, 34, 45, 47, 73, 78, 91, 102, 110, 116,
1520
- 123, 9, 10, 48, 57, 42, 47, 42, 42, 47, 10, 42,
1521
- 47, 42, 42, 47, 10, 42, 47, 42, 42, 47, 10, 0
1522
- };
1523
- }
1524
-
1525
- private static final char _JSON_array_trans_keys[] = init__JSON_array_trans_keys_0();
1526
-
1527
-
1528
- private static byte[] init__JSON_array_single_lengths_0()
1529
- {
1530
- return new byte [] {
1531
- 0, 1, 13, 5, 12, 2, 1, 2, 1, 2, 1, 2,
1532
- 1, 2, 1, 2, 1, 0
1533
- };
1534
- }
1535
-
1536
- private static final byte _JSON_array_single_lengths[] = init__JSON_array_single_lengths_0();
1537
-
1538
-
1539
- private static byte[] init__JSON_array_range_lengths_0()
1540
- {
1541
- return new byte [] {
1542
- 0, 0, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0,
1543
- 0, 0, 0, 0, 0, 0
1544
- };
1545
- }
1546
-
1547
- private static final byte _JSON_array_range_lengths[] = init__JSON_array_range_lengths_0();
1548
-
1549
-
1550
- private static byte[] init__JSON_array_index_offsets_0()
1551
- {
1552
- return new byte [] {
1553
- 0, 0, 2, 18, 25, 40, 43, 45, 48, 50, 53, 55,
1554
- 58, 60, 63, 65, 68, 70
1555
- };
1556
- }
1557
-
1558
- private static final byte _JSON_array_index_offsets[] = init__JSON_array_index_offsets_0();
1559
-
1560
-
1561
- private static byte[] init__JSON_array_indicies_0()
1562
- {
1563
- return new byte [] {
1564
- 0, 1, 0, 0, 2, 2, 3, 2, 2, 2, 4, 2,
1565
- 2, 2, 2, 0, 2, 1, 5, 5, 6, 7, 4, 5,
1566
- 1, 6, 6, 2, 2, 8, 2, 2, 2, 2, 2, 2,
1567
- 2, 6, 2, 1, 9, 10, 1, 11, 9, 11, 6, 9,
1568
- 6, 10, 12, 13, 1, 14, 12, 14, 5, 12, 5, 13,
1569
- 15, 16, 1, 17, 15, 17, 0, 15, 0, 16, 1, 0
1570
- };
1571
- }
1572
-
1573
- private static final byte _JSON_array_indicies[] = init__JSON_array_indicies_0();
1574
-
1575
-
1576
- private static byte[] init__JSON_array_trans_targs_0()
1577
- {
1578
- return new byte [] {
1579
- 2, 0, 3, 13, 17, 3, 4, 9, 5, 6, 8, 7,
1580
- 10, 12, 11, 14, 16, 15
1581
- };
1582
- }
1583
-
1584
- private static final byte _JSON_array_trans_targs[] = init__JSON_array_trans_targs_0();
1585
-
1586
-
1587
- private static byte[] init__JSON_array_trans_actions_0()
1588
- {
1589
- return new byte [] {
1590
- 0, 0, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0,
1591
- 0, 0, 0, 0, 0, 0
1592
- };
1593
- }
1594
-
1595
- private static final byte _JSON_array_trans_actions[] = init__JSON_array_trans_actions_0();
1596
-
1597
-
1598
- static final int JSON_array_start = 1;
1599
- static final int JSON_array_first_final = 17;
1600
- static final int JSON_array_error = 0;
1601
-
1602
- static final int JSON_array_en_main = 1;
1603
-
1604
-
1605
- // line 698 "Parser.rl"
1606
-
1607
-
1608
- void parseArray(ParserResult res, int p, int pe) {
1609
- int cs = EVIL;
1610
-
1611
- if (parser.maxNesting > 0 && currentNesting > parser.maxNesting) {
1612
- throw newException(Utils.M_NESTING_ERROR,
1613
- "nesting of " + currentNesting + " is too deep");
1614
- }
1615
-
1616
- IRubyObject result;
1617
- if (parser.arrayClass == getRuntime().getArray()) {
1618
- result = RubyArray.newArray(getRuntime());
1619
- } else {
1620
- result = parser.arrayClass.newInstance(context,
1621
- IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
1622
- }
1623
-
1624
-
1625
- // line 1626 "Parser.java"
1626
- {
1627
- cs = JSON_array_start;
1628
- }
1629
-
1630
- // line 717 "Parser.rl"
1631
-
1632
- // line 1633 "Parser.java"
1633
- {
1634
- int _klen;
1635
- int _trans = 0;
1636
- int _acts;
1637
- int _nacts;
1638
- int _keys;
1639
- int _goto_targ = 0;
1640
-
1641
- _goto: while (true) {
1642
- switch ( _goto_targ ) {
1643
- case 0:
1644
- if ( p == pe ) {
1645
- _goto_targ = 4;
1646
- continue _goto;
1647
- }
1648
- if ( cs == 0 ) {
1649
- _goto_targ = 5;
1650
- continue _goto;
1651
- }
1652
- case 1:
1653
- _match: do {
1654
- _keys = _JSON_array_key_offsets[cs];
1655
- _trans = _JSON_array_index_offsets[cs];
1656
- _klen = _JSON_array_single_lengths[cs];
1657
- if ( _klen > 0 ) {
1658
- int _lower = _keys;
1659
- int _mid;
1660
- int _upper = _keys + _klen - 1;
1661
- while (true) {
1662
- if ( _upper < _lower )
1663
- break;
1664
-
1665
- _mid = _lower + ((_upper-_lower) >> 1);
1666
- if ( data[p] < _JSON_array_trans_keys[_mid] )
1667
- _upper = _mid - 1;
1668
- else if ( data[p] > _JSON_array_trans_keys[_mid] )
1669
- _lower = _mid + 1;
1670
- else {
1671
- _trans += (_mid - _keys);
1672
- break _match;
1673
- }
1674
- }
1675
- _keys += _klen;
1676
- _trans += _klen;
1677
- }
1678
-
1679
- _klen = _JSON_array_range_lengths[cs];
1680
- if ( _klen > 0 ) {
1681
- int _lower = _keys;
1682
- int _mid;
1683
- int _upper = _keys + (_klen<<1) - 2;
1684
- while (true) {
1685
- if ( _upper < _lower )
1686
- break;
1687
-
1688
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
1689
- if ( data[p] < _JSON_array_trans_keys[_mid] )
1690
- _upper = _mid - 2;
1691
- else if ( data[p] > _JSON_array_trans_keys[_mid+1] )
1692
- _lower = _mid + 2;
1693
- else {
1694
- _trans += ((_mid - _keys)>>1);
1695
- break _match;
1696
- }
1697
- }
1698
- _trans += _klen;
1699
- }
1700
- } while (false);
1701
-
1702
- _trans = _JSON_array_indicies[_trans];
1703
- cs = _JSON_array_trans_targs[_trans];
1704
-
1705
- if ( _JSON_array_trans_actions[_trans] != 0 ) {
1706
- _acts = _JSON_array_trans_actions[_trans];
1707
- _nacts = (int) _JSON_array_actions[_acts++];
1708
- while ( _nacts-- > 0 )
1709
- {
1710
- switch ( _JSON_array_actions[_acts++] )
1711
- {
1712
- case 0:
1713
- // line 667 "Parser.rl"
1714
- {
1715
- parseValue(res, p, pe);
1716
- if (res.result == null) {
1717
- p--;
1718
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
1719
- } else {
1720
- if (parser.arrayClass == getRuntime().getArray()) {
1721
- ((RubyArray)result).append(res.result);
1722
- } else {
1723
- result.callMethod(context, "<<", res.result);
1724
- }
1725
- {p = (( res.p))-1;}
1726
- }
1727
- }
1728
- break;
1729
- case 1:
1730
- // line 682 "Parser.rl"
1731
- {
1732
- p--;
1733
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
1734
- }
1735
- break;
1736
- // line 1737 "Parser.java"
1737
- }
1738
- }
1739
- }
1740
-
1741
- case 2:
1742
- if ( cs == 0 ) {
1743
- _goto_targ = 5;
1744
- continue _goto;
1745
- }
1746
- if ( ++p != pe ) {
1747
- _goto_targ = 1;
1748
- continue _goto;
1749
- }
1750
- case 4:
1751
- case 5:
1752
- }
1753
- break; }
1754
- }
1755
-
1756
- // line 718 "Parser.rl"
1757
-
1758
- if (cs >= JSON_array_first_final) {
1759
- res.update(result, p + 1);
1760
- } else {
1761
- throw unexpectedToken(p, pe);
1762
- }
1763
- }
1764
-
1765
-
1766
- // line 1767 "Parser.java"
1767
- private static byte[] init__JSON_object_actions_0()
1768
- {
1769
- return new byte [] {
1770
- 0, 1, 0, 1, 1, 1, 2
1771
- };
1772
- }
1773
-
1774
- private static final byte _JSON_object_actions[] = init__JSON_object_actions_0();
1775
-
1776
-
1777
- private static byte[] init__JSON_object_key_offsets_0()
1778
- {
1779
- return new byte [] {
1780
- 0, 0, 1, 8, 14, 16, 17, 19, 20, 36, 43, 49,
1781
- 51, 52, 54, 55, 57, 58, 60, 61, 63, 64, 66, 67,
1782
- 69, 70, 72, 73
1783
- };
1784
- }
1785
-
1786
- private static final byte _JSON_object_key_offsets[] = init__JSON_object_key_offsets_0();
1787
-
1788
-
1789
- private static char[] init__JSON_object_trans_keys_0()
1790
- {
1791
- return new char [] {
1792
- 123, 13, 32, 34, 47, 125, 9, 10, 13, 32, 47, 58,
1793
- 9, 10, 42, 47, 42, 42, 47, 10, 13, 32, 34, 45,
1794
- 47, 73, 78, 91, 102, 110, 116, 123, 9, 10, 48, 57,
1795
- 13, 32, 44, 47, 125, 9, 10, 13, 32, 34, 47, 9,
1796
- 10, 42, 47, 42, 42, 47, 10, 42, 47, 42, 42, 47,
1797
- 10, 42, 47, 42, 42, 47, 10, 42, 47, 42, 42, 47,
1798
- 10, 0
1799
- };
1800
- }
1801
-
1802
- private static final char _JSON_object_trans_keys[] = init__JSON_object_trans_keys_0();
1803
-
1804
-
1805
- private static byte[] init__JSON_object_single_lengths_0()
1806
- {
1807
- return new byte [] {
1808
- 0, 1, 5, 4, 2, 1, 2, 1, 12, 5, 4, 2,
1809
- 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2,
1810
- 1, 2, 1, 0
1811
- };
1812
- }
1813
-
1814
- private static final byte _JSON_object_single_lengths[] = init__JSON_object_single_lengths_0();
1815
-
1816
-
1817
- private static byte[] init__JSON_object_range_lengths_0()
1818
- {
1819
- return new byte [] {
1820
- 0, 0, 1, 1, 0, 0, 0, 0, 2, 1, 1, 0,
1821
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1822
- 0, 0, 0, 0
1823
- };
1824
- }
1825
-
1826
- private static final byte _JSON_object_range_lengths[] = init__JSON_object_range_lengths_0();
1827
-
1828
-
1829
- private static byte[] init__JSON_object_index_offsets_0()
1830
- {
1831
- return new byte [] {
1832
- 0, 0, 2, 9, 15, 18, 20, 23, 25, 40, 47, 53,
1833
- 56, 58, 61, 63, 66, 68, 71, 73, 76, 78, 81, 83,
1834
- 86, 88, 91, 93
1835
- };
1836
- }
1837
-
1838
- private static final byte _JSON_object_index_offsets[] = init__JSON_object_index_offsets_0();
1839
-
1840
-
1841
- private static byte[] init__JSON_object_indicies_0()
1842
- {
1843
- return new byte [] {
1844
- 0, 1, 0, 0, 2, 3, 4, 0, 1, 5, 5, 6,
1845
- 7, 5, 1, 8, 9, 1, 10, 8, 10, 5, 8, 5,
1846
- 9, 7, 7, 11, 11, 12, 11, 11, 11, 11, 11, 11,
1847
- 11, 7, 11, 1, 13, 13, 14, 15, 4, 13, 1, 14,
1848
- 14, 2, 16, 14, 1, 17, 18, 1, 19, 17, 19, 14,
1849
- 17, 14, 18, 20, 21, 1, 22, 20, 22, 13, 20, 13,
1850
- 21, 23, 24, 1, 25, 23, 25, 7, 23, 7, 24, 26,
1851
- 27, 1, 28, 26, 28, 0, 26, 0, 27, 1, 0
1852
- };
1853
- }
1854
-
1855
- private static final byte _JSON_object_indicies[] = init__JSON_object_indicies_0();
1856
-
1857
-
1858
- private static byte[] init__JSON_object_trans_targs_0()
1859
- {
1860
- return new byte [] {
1861
- 2, 0, 3, 23, 27, 3, 4, 8, 5, 7, 6, 9,
1862
- 19, 9, 10, 15, 11, 12, 14, 13, 16, 18, 17, 20,
1863
- 22, 21, 24, 26, 25
1864
- };
1865
- }
1866
-
1867
- private static final byte _JSON_object_trans_targs[] = init__JSON_object_trans_targs_0();
1868
-
1869
-
1870
- private static byte[] init__JSON_object_trans_actions_0()
1871
- {
1872
- return new byte [] {
1873
- 0, 0, 3, 0, 5, 0, 0, 0, 0, 0, 0, 1,
1874
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1875
- 0, 0, 0, 0, 0
1876
- };
1877
- }
1878
-
1879
- private static final byte _JSON_object_trans_actions[] = init__JSON_object_trans_actions_0();
1880
-
1881
-
1882
- static final int JSON_object_start = 1;
1883
- static final int JSON_object_first_final = 27;
1884
- static final int JSON_object_error = 0;
1885
-
1886
- static final int JSON_object_en_main = 1;
1887
-
1888
-
1889
- // line 777 "Parser.rl"
1890
-
1891
-
1892
- void parseObject(ParserResult res, int p, int pe) {
1893
- int cs = EVIL;
1894
- IRubyObject lastName = null;
1895
- boolean objectDefault = true;
1896
-
1897
- if (parser.maxNesting > 0 && currentNesting > parser.maxNesting) {
1898
- throw newException(Utils.M_NESTING_ERROR,
1899
- "nesting of " + currentNesting + " is too deep");
1900
- }
1901
-
1902
- // this is guaranteed to be a RubyHash due to the earlier
1903
- // allocator test at OptionsReader#getClass
1904
- IRubyObject result;
1905
- if (parser.objectClass == getRuntime().getHash()) {
1906
- result = RubyHash.newHash(getRuntime());
1907
- } else {
1908
- objectDefault = false;
1909
- result = parser.objectClass.newInstance(context,
1910
- IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
1911
- }
1912
-
1913
-
1914
- // line 1915 "Parser.java"
1915
- {
1916
- cs = JSON_object_start;
1917
- }
1918
-
1919
- // line 801 "Parser.rl"
1920
-
1921
- // line 1922 "Parser.java"
1922
- {
1923
- int _klen;
1924
- int _trans = 0;
1925
- int _acts;
1926
- int _nacts;
1927
- int _keys;
1928
- int _goto_targ = 0;
1929
-
1930
- _goto: while (true) {
1931
- switch ( _goto_targ ) {
1932
- case 0:
1933
- if ( p == pe ) {
1934
- _goto_targ = 4;
1935
- continue _goto;
1936
- }
1937
- if ( cs == 0 ) {
1938
- _goto_targ = 5;
1939
- continue _goto;
1940
- }
1941
- case 1:
1942
- _match: do {
1943
- _keys = _JSON_object_key_offsets[cs];
1944
- _trans = _JSON_object_index_offsets[cs];
1945
- _klen = _JSON_object_single_lengths[cs];
1946
- if ( _klen > 0 ) {
1947
- int _lower = _keys;
1948
- int _mid;
1949
- int _upper = _keys + _klen - 1;
1950
- while (true) {
1951
- if ( _upper < _lower )
1952
- break;
1953
-
1954
- _mid = _lower + ((_upper-_lower) >> 1);
1955
- if ( data[p] < _JSON_object_trans_keys[_mid] )
1956
- _upper = _mid - 1;
1957
- else if ( data[p] > _JSON_object_trans_keys[_mid] )
1958
- _lower = _mid + 1;
1959
- else {
1960
- _trans += (_mid - _keys);
1961
- break _match;
1962
- }
1963
- }
1964
- _keys += _klen;
1965
- _trans += _klen;
1966
- }
1967
-
1968
- _klen = _JSON_object_range_lengths[cs];
1969
- if ( _klen > 0 ) {
1970
- int _lower = _keys;
1971
- int _mid;
1972
- int _upper = _keys + (_klen<<1) - 2;
1973
- while (true) {
1974
- if ( _upper < _lower )
1975
- break;
1976
-
1977
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
1978
- if ( data[p] < _JSON_object_trans_keys[_mid] )
1979
- _upper = _mid - 2;
1980
- else if ( data[p] > _JSON_object_trans_keys[_mid+1] )
1981
- _lower = _mid + 2;
1982
- else {
1983
- _trans += ((_mid - _keys)>>1);
1984
- break _match;
1985
- }
1986
- }
1987
- _trans += _klen;
1988
- }
1989
- } while (false);
1990
-
1991
- _trans = _JSON_object_indicies[_trans];
1992
- cs = _JSON_object_trans_targs[_trans];
1993
-
1994
- if ( _JSON_object_trans_actions[_trans] != 0 ) {
1995
- _acts = _JSON_object_trans_actions[_trans];
1996
- _nacts = (int) _JSON_object_actions[_acts++];
1997
- while ( _nacts-- > 0 )
1998
- {
1999
- switch ( _JSON_object_actions[_acts++] )
2000
- {
2001
- case 0:
2002
- // line 732 "Parser.rl"
2003
- {
2004
- parseValue(res, p, pe);
2005
- if (res.result == null) {
2006
- p--;
2007
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
2008
- } else {
2009
- if (parser.objectClass == getRuntime().getHash()) {
2010
- ((RubyHash)result).op_aset(context, lastName, res.result);
2011
- } else {
2012
- result.callMethod(context, "[]=", new IRubyObject[] { lastName, res.result });
2013
- }
2014
- {p = (( res.p))-1;}
2015
- }
2016
- }
2017
- break;
2018
- case 1:
2019
- // line 747 "Parser.rl"
2020
- {
2021
- parseString(res, p, pe);
2022
- if (res.result == null) {
2023
- p--;
2024
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
2025
- } else {
2026
- RubyString name = (RubyString)res.result;
2027
- if (parser.symbolizeNames) {
2028
- lastName = context.getRuntime().is1_9()
2029
- ? name.intern19()
2030
- : name.intern();
2031
- } else {
2032
- lastName = name;
2033
- }
2034
- {p = (( res.p))-1;}
2035
- }
2036
- }
2037
- break;
2038
- case 2:
2039
- // line 765 "Parser.rl"
2040
- {
2041
- p--;
2042
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
2043
- }
2044
- break;
2045
- // line 2046 "Parser.java"
2046
- }
2047
- }
2048
- }
2049
-
2050
- case 2:
2051
- if ( cs == 0 ) {
2052
- _goto_targ = 5;
2053
- continue _goto;
2054
- }
2055
- if ( ++p != pe ) {
2056
- _goto_targ = 1;
2057
- continue _goto;
2058
- }
2059
- case 4:
2060
- case 5:
2061
- }
2062
- break; }
2063
- }
2064
-
2065
- // line 802 "Parser.rl"
2066
-
2067
- if (cs < JSON_object_first_final) {
2068
- res.update(null, p + 1);
2069
- return;
2070
- }
2071
-
2072
- IRubyObject returnedResult = result;
2073
-
2074
- // attempt to de-serialize object
2075
- if (parser.createAdditions) {
2076
- IRubyObject vKlassName;
2077
- if (objectDefault) {
2078
- vKlassName = ((RubyHash)result).op_aref(context, parser.createId);
2079
- } else {
2080
- vKlassName = result.callMethod(context, "[]", parser.createId);
2081
- }
2082
-
2083
- if (!vKlassName.isNil()) {
2084
- // might throw ArgumentError, we let it propagate
2085
- IRubyObject klass = parser.info.jsonModule.get().
2086
- callMethod(context, "deep_const_get", vKlassName);
2087
- if (klass.respondsTo("json_creatable?") &&
2088
- klass.callMethod(context, "json_creatable?").isTrue()) {
2089
-
2090
- returnedResult = klass.callMethod(context, "json_create", result);
2091
- }
2092
- }
2093
- }
2094
- res.update(returnedResult, p + 1);
2095
- }
2096
-
2097
-
2098
- // line 2099 "Parser.java"
2099
- private static byte[] init__JSON_actions_0()
2100
- {
2101
- return new byte [] {
2102
- 0, 1, 0, 1, 1
2103
- };
2104
- }
2105
-
2106
- private static final byte _JSON_actions[] = init__JSON_actions_0();
2107
-
2108
-
2109
- private static byte[] init__JSON_key_offsets_0()
2110
- {
2111
- return new byte [] {
2112
- 0, 0, 7, 9, 10, 12, 13, 15, 16, 18, 19
2113
- };
2114
- }
2115
-
2116
- private static final byte _JSON_key_offsets[] = init__JSON_key_offsets_0();
2117
-
2118
-
2119
- private static char[] init__JSON_trans_keys_0()
2120
- {
2121
- return new char [] {
2122
- 13, 32, 47, 91, 123, 9, 10, 42, 47, 42, 42, 47,
2123
- 10, 42, 47, 42, 42, 47, 10, 13, 32, 47, 9, 10,
2124
- 0
2125
- };
2126
- }
2127
-
2128
- private static final char _JSON_trans_keys[] = init__JSON_trans_keys_0();
2129
-
2130
-
2131
- private static byte[] init__JSON_single_lengths_0()
2132
- {
2133
- return new byte [] {
2134
- 0, 5, 2, 1, 2, 1, 2, 1, 2, 1, 3
2135
- };
2136
- }
2137
-
2138
- private static final byte _JSON_single_lengths[] = init__JSON_single_lengths_0();
2139
-
2140
-
2141
- private static byte[] init__JSON_range_lengths_0()
2142
- {
2143
- return new byte [] {
2144
- 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
2145
- };
2146
- }
2147
-
2148
- private static final byte _JSON_range_lengths[] = init__JSON_range_lengths_0();
2149
-
2150
-
2151
- private static byte[] init__JSON_index_offsets_0()
2152
- {
2153
- return new byte [] {
2154
- 0, 0, 7, 10, 12, 15, 17, 20, 22, 25, 27
2155
- };
2156
- }
2157
-
2158
- private static final byte _JSON_index_offsets[] = init__JSON_index_offsets_0();
2159
-
2160
-
2161
- private static byte[] init__JSON_indicies_0()
2162
- {
2163
- return new byte [] {
2164
- 0, 0, 2, 3, 4, 0, 1, 5, 6, 1, 7, 5,
2165
- 7, 0, 5, 0, 6, 8, 9, 1, 10, 8, 10, 11,
2166
- 8, 11, 9, 11, 11, 12, 11, 1, 0
2167
- };
2168
- }
2169
-
2170
- private static final byte _JSON_indicies[] = init__JSON_indicies_0();
2171
-
2172
-
2173
- private static byte[] init__JSON_trans_targs_0()
2174
- {
2175
- return new byte [] {
2176
- 1, 0, 2, 10, 10, 3, 5, 4, 7, 9, 8, 10,
2177
- 6
2178
- };
2179
- }
2180
-
2181
- private static final byte _JSON_trans_targs[] = init__JSON_trans_targs_0();
2182
-
2183
-
2184
- private static byte[] init__JSON_trans_actions_0()
2185
- {
2186
- return new byte [] {
2187
- 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0,
2188
- 0
2189
- };
2190
- }
2191
-
2192
- private static final byte _JSON_trans_actions[] = init__JSON_trans_actions_0();
2193
-
2194
-
2195
- static final int JSON_start = 1;
2196
- static final int JSON_first_final = 10;
2197
- static final int JSON_error = 0;
2198
-
2199
- static final int JSON_en_main = 1;
2200
-
2201
-
2202
- // line 867 "Parser.rl"
2203
-
2204
-
2205
- public IRubyObject parseStrict() {
2206
- int cs = EVIL;
2207
- int p, pe;
2208
- IRubyObject result = null;
2209
- ParserResult res = new ParserResult();
2210
-
2211
-
2212
- // line 2213 "Parser.java"
2213
- {
2214
- cs = JSON_start;
2215
- }
2216
-
2217
- // line 876 "Parser.rl"
2218
- p = byteList.begin();
2219
- pe = p + byteList.length();
2220
-
2221
- // line 2222 "Parser.java"
2222
- {
2223
- int _klen;
2224
- int _trans = 0;
2225
- int _acts;
2226
- int _nacts;
2227
- int _keys;
2228
- int _goto_targ = 0;
2229
-
2230
- _goto: while (true) {
2231
- switch ( _goto_targ ) {
2232
- case 0:
2233
- if ( p == pe ) {
2234
- _goto_targ = 4;
2235
- continue _goto;
2236
- }
2237
- if ( cs == 0 ) {
2238
- _goto_targ = 5;
2239
- continue _goto;
2240
- }
2241
- case 1:
2242
- _match: do {
2243
- _keys = _JSON_key_offsets[cs];
2244
- _trans = _JSON_index_offsets[cs];
2245
- _klen = _JSON_single_lengths[cs];
2246
- if ( _klen > 0 ) {
2247
- int _lower = _keys;
2248
- int _mid;
2249
- int _upper = _keys + _klen - 1;
2250
- while (true) {
2251
- if ( _upper < _lower )
2252
- break;
2253
-
2254
- _mid = _lower + ((_upper-_lower) >> 1);
2255
- if ( data[p] < _JSON_trans_keys[_mid] )
2256
- _upper = _mid - 1;
2257
- else if ( data[p] > _JSON_trans_keys[_mid] )
2258
- _lower = _mid + 1;
2259
- else {
2260
- _trans += (_mid - _keys);
2261
- break _match;
2262
- }
2263
- }
2264
- _keys += _klen;
2265
- _trans += _klen;
2266
- }
2267
-
2268
- _klen = _JSON_range_lengths[cs];
2269
- if ( _klen > 0 ) {
2270
- int _lower = _keys;
2271
- int _mid;
2272
- int _upper = _keys + (_klen<<1) - 2;
2273
- while (true) {
2274
- if ( _upper < _lower )
2275
- break;
2276
-
2277
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
2278
- if ( data[p] < _JSON_trans_keys[_mid] )
2279
- _upper = _mid - 2;
2280
- else if ( data[p] > _JSON_trans_keys[_mid+1] )
2281
- _lower = _mid + 2;
2282
- else {
2283
- _trans += ((_mid - _keys)>>1);
2284
- break _match;
2285
- }
2286
- }
2287
- _trans += _klen;
2288
- }
2289
- } while (false);
2290
-
2291
- _trans = _JSON_indicies[_trans];
2292
- cs = _JSON_trans_targs[_trans];
2293
-
2294
- if ( _JSON_trans_actions[_trans] != 0 ) {
2295
- _acts = _JSON_trans_actions[_trans];
2296
- _nacts = (int) _JSON_actions[_acts++];
2297
- while ( _nacts-- > 0 )
2298
- {
2299
- switch ( _JSON_actions[_acts++] )
2300
- {
2301
- case 0:
2302
- // line 839 "Parser.rl"
2303
- {
2304
- currentNesting = 1;
2305
- parseObject(res, p, pe);
2306
- if (res.result == null) {
2307
- p--;
2308
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
2309
- } else {
2310
- result = res.result;
2311
- {p = (( res.p))-1;}
2312
- }
2313
- }
2314
- break;
2315
- case 1:
2316
- // line 851 "Parser.rl"
2317
- {
2318
- currentNesting = 1;
2319
- parseArray(res, p, pe);
2320
- if (res.result == null) {
2321
- p--;
2322
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
2323
- } else {
2324
- result = res.result;
2325
- {p = (( res.p))-1;}
2326
- }
2327
- }
2328
- break;
2329
- // line 2330 "Parser.java"
2330
- }
2331
- }
2332
- }
2333
-
2334
- case 2:
2335
- if ( cs == 0 ) {
2336
- _goto_targ = 5;
2337
- continue _goto;
2338
- }
2339
- if ( ++p != pe ) {
2340
- _goto_targ = 1;
2341
- continue _goto;
2342
- }
2343
- case 4:
2344
- case 5:
2345
- }
2346
- break; }
2347
- }
2348
-
2349
- // line 879 "Parser.rl"
2350
-
2351
- if (cs >= JSON_first_final && p == pe) {
2352
- return result;
2353
- } else {
2354
- throw unexpectedToken(p, pe);
2355
- }
2356
- }
2357
-
2358
-
2359
- // line 2360 "Parser.java"
2360
- private static byte[] init__JSON_quirks_mode_actions_0()
2361
- {
2362
- return new byte [] {
2363
- 0, 1, 0
2364
- };
2365
- }
2366
-
2367
- private static final byte _JSON_quirks_mode_actions[] = init__JSON_quirks_mode_actions_0();
2368
-
2369
-
2370
- private static byte[] init__JSON_quirks_mode_key_offsets_0()
2371
- {
2372
- return new byte [] {
2373
- 0, 0, 16, 18, 19, 21, 22, 24, 25, 27, 28
2374
- };
2375
- }
2376
-
2377
- private static final byte _JSON_quirks_mode_key_offsets[] = init__JSON_quirks_mode_key_offsets_0();
2378
-
2379
-
2380
- private static char[] init__JSON_quirks_mode_trans_keys_0()
2381
- {
2382
- return new char [] {
2383
- 13, 32, 34, 45, 47, 73, 78, 91, 102, 110, 116, 123,
2384
- 9, 10, 48, 57, 42, 47, 42, 42, 47, 10, 42, 47,
2385
- 42, 42, 47, 10, 13, 32, 47, 9, 10, 0
2386
- };
2387
- }
2388
-
2389
- private static final char _JSON_quirks_mode_trans_keys[] = init__JSON_quirks_mode_trans_keys_0();
2390
-
2391
-
2392
- private static byte[] init__JSON_quirks_mode_single_lengths_0()
2393
- {
2394
- return new byte [] {
2395
- 0, 12, 2, 1, 2, 1, 2, 1, 2, 1, 3
2396
- };
2397
- }
2398
-
2399
- private static final byte _JSON_quirks_mode_single_lengths[] = init__JSON_quirks_mode_single_lengths_0();
2400
-
2401
-
2402
- private static byte[] init__JSON_quirks_mode_range_lengths_0()
2403
- {
2404
- return new byte [] {
2405
- 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1
2406
- };
2407
- }
2408
-
2409
- private static final byte _JSON_quirks_mode_range_lengths[] = init__JSON_quirks_mode_range_lengths_0();
2410
-
2411
-
2412
- private static byte[] init__JSON_quirks_mode_index_offsets_0()
2413
- {
2414
- return new byte [] {
2415
- 0, 0, 15, 18, 20, 23, 25, 28, 30, 33, 35
2416
- };
2417
- }
2418
-
2419
- private static final byte _JSON_quirks_mode_index_offsets[] = init__JSON_quirks_mode_index_offsets_0();
2420
-
2421
-
2422
- private static byte[] init__JSON_quirks_mode_indicies_0()
2423
- {
2424
- return new byte [] {
2425
- 0, 0, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2,
2426
- 0, 2, 1, 4, 5, 1, 6, 4, 6, 7, 4, 7,
2427
- 5, 8, 9, 1, 10, 8, 10, 0, 8, 0, 9, 7,
2428
- 7, 11, 7, 1, 0
2429
- };
2430
- }
2431
-
2432
- private static final byte _JSON_quirks_mode_indicies[] = init__JSON_quirks_mode_indicies_0();
2433
-
2434
-
2435
- private static byte[] init__JSON_quirks_mode_trans_targs_0()
2436
- {
2437
- return new byte [] {
2438
- 1, 0, 10, 6, 3, 5, 4, 10, 7, 9, 8, 2
2439
- };
2440
- }
2441
-
2442
- private static final byte _JSON_quirks_mode_trans_targs[] = init__JSON_quirks_mode_trans_targs_0();
2443
-
2444
-
2445
- private static byte[] init__JSON_quirks_mode_trans_actions_0()
2446
- {
2447
- return new byte [] {
2448
- 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
2449
- };
2450
- }
2451
-
2452
- private static final byte _JSON_quirks_mode_trans_actions[] = init__JSON_quirks_mode_trans_actions_0();
2453
-
2454
-
2455
- static final int JSON_quirks_mode_start = 1;
2456
- static final int JSON_quirks_mode_first_final = 10;
2457
- static final int JSON_quirks_mode_error = 0;
2458
-
2459
- static final int JSON_quirks_mode_en_main = 1;
2460
-
2461
-
2462
- // line 907 "Parser.rl"
2463
-
2464
-
2465
- public IRubyObject parseQuirksMode() {
2466
- int cs = EVIL;
2467
- int p, pe;
2468
- IRubyObject result = null;
2469
- ParserResult res = new ParserResult();
2470
-
2471
-
2472
- // line 2473 "Parser.java"
2473
- {
2474
- cs = JSON_quirks_mode_start;
2475
- }
2476
-
2477
- // line 916 "Parser.rl"
2478
- p = byteList.begin();
2479
- pe = p + byteList.length();
2480
-
2481
- // line 2482 "Parser.java"
2482
- {
2483
- int _klen;
2484
- int _trans = 0;
2485
- int _acts;
2486
- int _nacts;
2487
- int _keys;
2488
- int _goto_targ = 0;
2489
-
2490
- _goto: while (true) {
2491
- switch ( _goto_targ ) {
2492
- case 0:
2493
- if ( p == pe ) {
2494
- _goto_targ = 4;
2495
- continue _goto;
2496
- }
2497
- if ( cs == 0 ) {
2498
- _goto_targ = 5;
2499
- continue _goto;
2500
- }
2501
- case 1:
2502
- _match: do {
2503
- _keys = _JSON_quirks_mode_key_offsets[cs];
2504
- _trans = _JSON_quirks_mode_index_offsets[cs];
2505
- _klen = _JSON_quirks_mode_single_lengths[cs];
2506
- if ( _klen > 0 ) {
2507
- int _lower = _keys;
2508
- int _mid;
2509
- int _upper = _keys + _klen - 1;
2510
- while (true) {
2511
- if ( _upper < _lower )
2512
- break;
2513
-
2514
- _mid = _lower + ((_upper-_lower) >> 1);
2515
- if ( data[p] < _JSON_quirks_mode_trans_keys[_mid] )
2516
- _upper = _mid - 1;
2517
- else if ( data[p] > _JSON_quirks_mode_trans_keys[_mid] )
2518
- _lower = _mid + 1;
2519
- else {
2520
- _trans += (_mid - _keys);
2521
- break _match;
2522
- }
2523
- }
2524
- _keys += _klen;
2525
- _trans += _klen;
2526
- }
2527
-
2528
- _klen = _JSON_quirks_mode_range_lengths[cs];
2529
- if ( _klen > 0 ) {
2530
- int _lower = _keys;
2531
- int _mid;
2532
- int _upper = _keys + (_klen<<1) - 2;
2533
- while (true) {
2534
- if ( _upper < _lower )
2535
- break;
2536
-
2537
- _mid = _lower + (((_upper-_lower) >> 1) & ~1);
2538
- if ( data[p] < _JSON_quirks_mode_trans_keys[_mid] )
2539
- _upper = _mid - 2;
2540
- else if ( data[p] > _JSON_quirks_mode_trans_keys[_mid+1] )
2541
- _lower = _mid + 2;
2542
- else {
2543
- _trans += ((_mid - _keys)>>1);
2544
- break _match;
2545
- }
2546
- }
2547
- _trans += _klen;
2548
- }
2549
- } while (false);
2550
-
2551
- _trans = _JSON_quirks_mode_indicies[_trans];
2552
- cs = _JSON_quirks_mode_trans_targs[_trans];
2553
-
2554
- if ( _JSON_quirks_mode_trans_actions[_trans] != 0 ) {
2555
- _acts = _JSON_quirks_mode_trans_actions[_trans];
2556
- _nacts = (int) _JSON_quirks_mode_actions[_acts++];
2557
- while ( _nacts-- > 0 )
2558
- {
2559
- switch ( _JSON_quirks_mode_actions[_acts++] )
2560
- {
2561
- case 0:
2562
- // line 893 "Parser.rl"
2563
- {
2564
- parseValue(res, p, pe);
2565
- if (res.result == null) {
2566
- p--;
2567
- { p += 1; _goto_targ = 5; if (true) continue _goto;}
2568
- } else {
2569
- result = res.result;
2570
- {p = (( res.p))-1;}
2571
- }
2572
- }
2573
- break;
2574
- // line 2575 "Parser.java"
2575
- }
2576
- }
2577
- }
2578
-
2579
- case 2:
2580
- if ( cs == 0 ) {
2581
- _goto_targ = 5;
2582
- continue _goto;
2583
- }
2584
- if ( ++p != pe ) {
2585
- _goto_targ = 1;
2586
- continue _goto;
2587
- }
2588
- case 4:
2589
- case 5:
2590
- }
2591
- break; }
2592
- }
2593
-
2594
- // line 919 "Parser.rl"
2595
-
2596
- if (cs >= JSON_quirks_mode_first_final && p == pe) {
2597
- return result;
2598
- } else {
2599
- throw unexpectedToken(p, pe);
2600
- }
2601
- }
2602
-
2603
- public IRubyObject parse() {
2604
- if (parser.quirksMode) {
2605
- return parseQuirksMode();
2606
- } else {
2607
- return parseStrict();
2608
- }
2609
-
2610
- }
2611
-
2612
- /**
2613
- * Updates the "view" bytelist with the new offsets and returns it.
2614
- * @param start
2615
- * @param end
2616
- */
2617
- private ByteList absSubSequence(int absStart, int absEnd) {
2618
- view.setBegin(absStart);
2619
- view.setRealSize(absEnd - absStart);
2620
- return view;
2621
- }
2622
-
2623
- /**
2624
- * Retrieves a constant directly descended from the <code>JSON</code> module.
2625
- * @param name The constant name
2626
- */
2627
- private IRubyObject getConstant(String name) {
2628
- return parser.info.jsonModule.get().getConstant(name);
2629
- }
2630
-
2631
- private RaiseException newException(String className, String message) {
2632
- return Utils.newException(context, className, message);
2633
- }
2634
-
2635
- private RaiseException newException(String className, RubyString message) {
2636
- return Utils.newException(context, className, message);
2637
- }
2638
-
2639
- private RaiseException newException(String className,
2640
- String messageBegin, ByteList messageEnd) {
2641
- return newException(className,
2642
- getRuntime().newString(messageBegin).cat(messageEnd));
2643
- }
2644
- }
2645
- }