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