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