jiffy 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +18 -0
  4. data/LICENSE +20 -0
  5. data/README.md +144 -0
  6. data/bin/jiffy +46 -0
  7. data/jiffy.gemspec +104 -0
  8. data/lib/jiffy/json_outputter.rb +62 -0
  9. data/lib/jiffy/parsers/json.rb +293 -0
  10. data/lib/jiffy/parsers/json.rl +56 -0
  11. data/lib/jiffy/parsers/json_array.rb +306 -0
  12. data/lib/jiffy/parsers/json_array.rl +45 -0
  13. data/lib/jiffy/parsers/json_common.rl +24 -0
  14. data/lib/jiffy/parsers/json_float.rb +269 -0
  15. data/lib/jiffy/parsers/json_float.rl +37 -0
  16. data/lib/jiffy/parsers/json_object.rb +348 -0
  17. data/lib/jiffy/parsers/json_object.rl +58 -0
  18. data/lib/jiffy/parsers/json_string.rb +267 -0
  19. data/lib/jiffy/parsers/json_string.rl +41 -0
  20. data/lib/jiffy/parsers/json_value.rb +346 -0
  21. data/lib/jiffy/parsers/json_value.rl +78 -0
  22. data/lib/jiffy/version.rb +3 -0
  23. data/lib/jiffy.rb +50 -0
  24. data/test/jiffy_test.rb +47 -0
  25. data/test/negative-examples/hexadecimal.json +3 -0
  26. data/test/negative-examples/infinity-value.json +3 -0
  27. data/test/negative-examples/leading-comma.json +3 -0
  28. data/test/negative-examples/leading-zero.json +3 -0
  29. data/test/negative-examples/line-break.json +4 -0
  30. data/test/negative-examples/missing-colon.json +3 -0
  31. data/test/negative-examples/nan-value,json +3 -0
  32. data/test/negative-examples/positive-float.json +3 -0
  33. data/test/negative-examples/positive-integer.json +3 -0
  34. data/test/negative-examples/single-quote.json +3 -0
  35. data/test/negative-examples/string-as-root.json +1 -0
  36. data/test/negative-examples/tab-character.json +3 -0
  37. data/test/negative-examples/trailing-array-seperator.json +3 -0
  38. data/test/negative-examples/trailing-object-seperator.json +3 -0
  39. data/test/negative-examples/true-as-root.json +1 -0
  40. data/test/negative-examples/unclosed-array.json +2 -0
  41. data/test/negative-examples/unclosed-object.json +2 -0
  42. data/test/positive-examples/array-as-root.json +3 -0
  43. data/test/positive-examples/array-nested-inside-array.json +5 -0
  44. data/test/positive-examples/array-nested-inside-object.json +5 -0
  45. data/test/positive-examples/false-value.json +3 -0
  46. data/test/positive-examples/null-value.json +3 -0
  47. data/test/positive-examples/number-1.json +3 -0
  48. data/test/positive-examples/number-10.json +3 -0
  49. data/test/positive-examples/number-11.json +3 -0
  50. data/test/positive-examples/number-12.json +3 -0
  51. data/test/positive-examples/number-13.json +3 -0
  52. data/test/positive-examples/number-14.json +3 -0
  53. data/test/positive-examples/number-15.json +3 -0
  54. data/test/positive-examples/number-16.json +3 -0
  55. data/test/positive-examples/number-17.json +3 -0
  56. data/test/positive-examples/number-18.json +3 -0
  57. data/test/positive-examples/number-19.json +3 -0
  58. data/test/positive-examples/number-2.json +3 -0
  59. data/test/positive-examples/number-20.json +3 -0
  60. data/test/positive-examples/number-3.json +3 -0
  61. data/test/positive-examples/number-4.json +3 -0
  62. data/test/positive-examples/number-5.json +3 -0
  63. data/test/positive-examples/number-6.json +3 -0
  64. data/test/positive-examples/number-7.json +3 -0
  65. data/test/positive-examples/number-8.json +3 -0
  66. data/test/positive-examples/number-9.json +3 -0
  67. data/test/positive-examples/object-as-root.json +3 -0
  68. data/test/positive-examples/object-nested-inside-array.json +5 -0
  69. data/test/positive-examples/object-nested-inside-object.json +5 -0
  70. data/test/positive-examples/seperated-array-values.json +4 -0
  71. data/test/positive-examples/seperated-object-properties.json +4 -0
  72. data/test/positive-examples/string-backspace.json +3 -0
  73. data/test/positive-examples/string-carriage-return.json +3 -0
  74. data/test/positive-examples/string-formfeed.json +3 -0
  75. data/test/positive-examples/string-horizontal-tab.json +3 -0
  76. data/test/positive-examples/string-newline.json +3 -0
  77. data/test/positive-examples/string-quotation.json +3 -0
  78. data/test/positive-examples/string-reverse-solidus.json +3 -0
  79. data/test/positive-examples/string-solidus.json +3 -0
  80. data/test/positive-examples/string-trivial.json +3 -0
  81. data/test/positive-examples/string-unicode.json +3 -0
  82. data/test/positive-examples/true-value.json +3 -0
  83. metadata +155 -0
@@ -0,0 +1,37 @@
1
+ %%{
2
+ machine json_float;
3
+ include json_common "json_common.rl";
4
+
5
+ action exit { fhold; fbreak; }
6
+
7
+ action char { o.t :char, [data[p]].pack("c*") }
8
+ action number { o.t :number, [data[p]].pack("c*").to_i }
9
+
10
+ significand = '-'? @char ('0' >number | [1-9] >char [0-9]* $number) ('.' >char [0-9]+ $number)?;
11
+
12
+ exponent = [Ee] >char [+\-]? @char [0-9]+ $number;
13
+
14
+ main := (significand exponent?) (^[0-9Ee.\-]? @exit );
15
+ }%%
16
+
17
+ class Jiffy
18
+ module Parsers
19
+ module JsonFloat
20
+ def initialize(*args)
21
+ %% write data;
22
+ super
23
+ end
24
+
25
+ def parse_json_float(p, pe)
26
+ t_p = p
27
+
28
+ %% write init;
29
+ %% write exec;
30
+
31
+ if cs >= json_float_first_final
32
+ p
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,348 @@
1
+
2
+ # line 1 "json_object.rl"
3
+
4
+ # line 36 "json_object.rl"
5
+
6
+
7
+ class Jiffy
8
+ module Parsers
9
+ module JsonObject
10
+ def initialize(*args)
11
+
12
+ # line 13 "json_object.rb"
13
+ class << self
14
+ attr_accessor :_json_object_actions
15
+ private :_json_object_actions, :_json_object_actions=
16
+ end
17
+ self._json_object_actions = [
18
+ 0, 1, 0, 1, 5, 1, 6, 1,
19
+ 7, 2, 8, 2, 3, 3, 1, 4
20
+ ]
21
+
22
+ class << self
23
+ attr_accessor :_json_object_key_offsets
24
+ private :_json_object_key_offsets, :_json_object_key_offsets=
25
+ end
26
+ self._json_object_key_offsets = [
27
+ 0, 0, 1, 8, 14, 16, 17, 19,
28
+ 20, 36, 43, 49, 51, 52, 54, 55,
29
+ 57, 58, 60, 61, 63, 64, 66, 67,
30
+ 69, 70, 72, 73
31
+ ]
32
+
33
+ class << self
34
+ attr_accessor :_json_object_trans_keys
35
+ private :_json_object_trans_keys, :_json_object_trans_keys=
36
+ end
37
+ self._json_object_trans_keys = [
38
+ 123, 13, 32, 34, 47, 125, 9, 10,
39
+ 13, 32, 47, 58, 9, 10, 42, 47,
40
+ 42, 42, 47, 10, 13, 32, 34, 45,
41
+ 47, 73, 78, 91, 102, 110, 116, 123,
42
+ 9, 10, 48, 57, 13, 32, 44, 47,
43
+ 125, 9, 10, 13, 32, 34, 47, 9,
44
+ 10, 42, 47, 42, 42, 47, 10, 42,
45
+ 47, 42, 42, 47, 10, 42, 47, 42,
46
+ 42, 47, 10, 42, 47, 42, 42, 47,
47
+ 10, 0
48
+ ]
49
+
50
+ class << self
51
+ attr_accessor :_json_object_single_lengths
52
+ private :_json_object_single_lengths, :_json_object_single_lengths=
53
+ end
54
+ self._json_object_single_lengths = [
55
+ 0, 1, 5, 4, 2, 1, 2, 1,
56
+ 12, 5, 4, 2, 1, 2, 1, 2,
57
+ 1, 2, 1, 2, 1, 2, 1, 2,
58
+ 1, 2, 1, 0
59
+ ]
60
+
61
+ class << self
62
+ attr_accessor :_json_object_range_lengths
63
+ private :_json_object_range_lengths, :_json_object_range_lengths=
64
+ end
65
+ self._json_object_range_lengths = [
66
+ 0, 0, 1, 1, 0, 0, 0, 0,
67
+ 2, 1, 1, 0, 0, 0, 0, 0,
68
+ 0, 0, 0, 0, 0, 0, 0, 0,
69
+ 0, 0, 0, 0
70
+ ]
71
+
72
+ class << self
73
+ attr_accessor :_json_object_index_offsets
74
+ private :_json_object_index_offsets, :_json_object_index_offsets=
75
+ end
76
+ self._json_object_index_offsets = [
77
+ 0, 0, 2, 9, 15, 18, 20, 23,
78
+ 25, 40, 47, 53, 56, 58, 61, 63,
79
+ 66, 68, 71, 73, 76, 78, 81, 83,
80
+ 86, 88, 91, 93
81
+ ]
82
+
83
+ class << self
84
+ attr_accessor :_json_object_indicies
85
+ private :_json_object_indicies, :_json_object_indicies=
86
+ end
87
+ self._json_object_indicies = [
88
+ 0, 1, 2, 2, 3, 4, 5, 2,
89
+ 1, 6, 6, 7, 8, 6, 1, 9,
90
+ 10, 1, 11, 9, 11, 6, 9, 6,
91
+ 10, 12, 12, 13, 13, 14, 13, 13,
92
+ 13, 13, 13, 13, 13, 12, 13, 1,
93
+ 15, 15, 16, 17, 5, 15, 1, 18,
94
+ 18, 3, 19, 18, 1, 20, 21, 1,
95
+ 22, 20, 22, 18, 20, 18, 21, 23,
96
+ 24, 1, 25, 23, 25, 15, 23, 15,
97
+ 24, 26, 27, 1, 28, 26, 28, 12,
98
+ 26, 12, 27, 29, 30, 1, 31, 29,
99
+ 31, 2, 29, 2, 30, 1, 0
100
+ ]
101
+
102
+ class << self
103
+ attr_accessor :_json_object_trans_targs
104
+ private :_json_object_trans_targs, :_json_object_trans_targs=
105
+ end
106
+ self._json_object_trans_targs = [
107
+ 2, 0, 2, 3, 23, 27, 3, 4,
108
+ 8, 5, 7, 6, 8, 9, 19, 9,
109
+ 10, 15, 10, 11, 12, 14, 13, 16,
110
+ 18, 17, 20, 22, 21, 24, 26, 25
111
+ ]
112
+
113
+ class << self
114
+ attr_accessor :_json_object_trans_actions
115
+ private :_json_object_trans_actions, :_json_object_trans_actions=
116
+ end
117
+ self._json_object_trans_actions = [
118
+ 7, 0, 0, 12, 0, 9, 0, 0,
119
+ 3, 0, 0, 0, 0, 1, 0, 0,
120
+ 5, 0, 0, 0, 0, 0, 0, 0,
121
+ 0, 0, 0, 0, 0, 0, 0, 0
122
+ ]
123
+
124
+ class << self
125
+ attr_accessor :json_object_start
126
+ end
127
+ self.json_object_start = 1;
128
+ class << self
129
+ attr_accessor :json_object_first_final
130
+ end
131
+ self.json_object_first_final = 27;
132
+ class << self
133
+ attr_accessor :json_object_error
134
+ end
135
+ self.json_object_error = 0;
136
+
137
+ class << self
138
+ attr_accessor :json_object_en_main
139
+ end
140
+ self.json_object_en_main = 1;
141
+
142
+
143
+ # line 43 "json_object.rl"
144
+ super
145
+ end
146
+
147
+ def parse_json_object(p, pe)
148
+
149
+ # line 150 "json_object.rb"
150
+ begin
151
+ p ||= 0
152
+ pe ||= data.length
153
+ cs = json_object_start
154
+ end
155
+
156
+ # line 48 "json_object.rl"
157
+
158
+ # line 159 "json_object.rb"
159
+ begin
160
+ _klen, _trans, _keys, _acts, _nacts = nil
161
+ _goto_level = 0
162
+ _resume = 10
163
+ _eof_trans = 15
164
+ _again = 20
165
+ _test_eof = 30
166
+ _out = 40
167
+ while true
168
+ _trigger_goto = false
169
+ if _goto_level <= 0
170
+ if p == pe
171
+ _goto_level = _test_eof
172
+ next
173
+ end
174
+ if cs == 0
175
+ _goto_level = _out
176
+ next
177
+ end
178
+ end
179
+ if _goto_level <= _resume
180
+ _keys = _json_object_key_offsets[cs]
181
+ _trans = _json_object_index_offsets[cs]
182
+ _klen = _json_object_single_lengths[cs]
183
+ _break_match = false
184
+
185
+ begin
186
+ if _klen > 0
187
+ _lower = _keys
188
+ _upper = _keys + _klen - 1
189
+
190
+ loop do
191
+ break if _upper < _lower
192
+ _mid = _lower + ( (_upper - _lower) >> 1 )
193
+
194
+ if data[p].ord < _json_object_trans_keys[_mid]
195
+ _upper = _mid - 1
196
+ elsif data[p].ord > _json_object_trans_keys[_mid]
197
+ _lower = _mid + 1
198
+ else
199
+ _trans += (_mid - _keys)
200
+ _break_match = true
201
+ break
202
+ end
203
+ end # loop
204
+ break if _break_match
205
+ _keys += _klen
206
+ _trans += _klen
207
+ end
208
+ _klen = _json_object_range_lengths[cs]
209
+ if _klen > 0
210
+ _lower = _keys
211
+ _upper = _keys + (_klen << 1) - 2
212
+ loop do
213
+ break if _upper < _lower
214
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1)
215
+ if data[p].ord < _json_object_trans_keys[_mid]
216
+ _upper = _mid - 2
217
+ elsif data[p].ord > _json_object_trans_keys[_mid+1]
218
+ _lower = _mid + 2
219
+ else
220
+ _trans += ((_mid - _keys) >> 1)
221
+ _break_match = true
222
+ break
223
+ end
224
+ end # loop
225
+ break if _break_match
226
+ _trans += _klen
227
+ end
228
+ end while false
229
+ _trans = _json_object_indicies[_trans]
230
+ cs = _json_object_trans_targs[_trans]
231
+ if _json_object_trans_actions[_trans] != 0
232
+ _acts = _json_object_trans_actions[_trans]
233
+ _nacts = _json_object_actions[_acts]
234
+ _acts += 1
235
+ while _nacts > 0
236
+ _nacts -= 1
237
+ _acts += 1
238
+ case _json_object_actions[_acts - 1]
239
+ when 0 then
240
+ # line 5 "json_object.rl"
241
+ begin
242
+
243
+ np = parse_json_value(p, pe)
244
+
245
+ if np
246
+ begin p = (( np))-1; end
247
+
248
+ else
249
+ p = p - 1; begin
250
+ p += 1
251
+ _trigger_goto = true
252
+ _goto_level = _out
253
+ break
254
+ end
255
+
256
+ end
257
+ end
258
+ when 1 then
259
+ # line 15 "json_object.rl"
260
+ begin
261
+
262
+ np = parse_json_string(p, pe)
263
+
264
+ if np
265
+ begin p = (( np))-1; end
266
+
267
+ else
268
+ p = p - 1; begin
269
+ p += 1
270
+ _trigger_goto = true
271
+ _goto_level = _out
272
+ break
273
+ end
274
+
275
+ end
276
+ end
277
+ when 2 then
278
+ # line 25 "json_object.rl"
279
+ begin
280
+ p = p - 1; begin
281
+ p += 1
282
+ _trigger_goto = true
283
+ _goto_level = _out
284
+ break
285
+ end
286
+ end
287
+ when 3 then
288
+ # line 27 "json_object.rl"
289
+ begin
290
+ o.t :begin_string end
291
+ when 4 then
292
+ # line 27 "json_object.rl"
293
+ begin
294
+ o.t :end_string end
295
+ when 5 then
296
+ # line 27 "json_object.rl"
297
+ begin
298
+ o.t :name_separator end
299
+ when 6 then
300
+ # line 29 "json_object.rl"
301
+ begin
302
+ o.t :value_separator end
303
+ when 7 then
304
+ # line 32 "json_object.rl"
305
+ begin
306
+ o.t :begin_object end
307
+ when 8 then
308
+ # line 34 "json_object.rl"
309
+ begin
310
+ o.t :end_object end
311
+ # line 312 "json_object.rb"
312
+ end # action switch
313
+ end
314
+ end
315
+ if _trigger_goto
316
+ next
317
+ end
318
+ end
319
+ if _goto_level <= _again
320
+ if cs == 0
321
+ _goto_level = _out
322
+ next
323
+ end
324
+ p += 1
325
+ if p != pe
326
+ _goto_level = _resume
327
+ next
328
+ end
329
+ end
330
+ if _goto_level <= _test_eof
331
+ end
332
+ if _goto_level <= _out
333
+ break
334
+ end
335
+ end
336
+ end
337
+
338
+ # line 49 "json_object.rl"
339
+
340
+ if cs >= json_object_first_final
341
+ p + 1
342
+ else
343
+ raise_unparseable p
344
+ end
345
+ end
346
+ end
347
+ end
348
+ end
@@ -0,0 +1,58 @@
1
+ %%{
2
+ machine json_object;
3
+ include json_common "json_common.rl";
4
+
5
+ action parse_value {
6
+ np = parse_json_value(fpc, pe)
7
+
8
+ if np
9
+ fexec np;
10
+ else
11
+ fhold; fbreak;
12
+ end
13
+ }
14
+
15
+ action parse_name {
16
+ np = parse_json_string(fpc, pe)
17
+
18
+ if np
19
+ fexec np;
20
+ else
21
+ fhold; fbreak;
22
+ end
23
+ }
24
+
25
+ action exit { fhold; fbreak; }
26
+
27
+ pair = ignore* begin_name >{ o.t :begin_string } >parse_name @{ o.t :end_string } ignore* name_separator >{ o.t :name_separator } ignore* begin_value >parse_value;
28
+
29
+ next_pair = ignore* value_separator >{ o.t :value_separator } pair;
30
+
31
+ main := (
32
+ begin_object >{ o.t :begin_object }
33
+ (pair (next_pair)*)? ignore*
34
+ end_object >{ o.t :end_object }
35
+ ) @exit;
36
+ }%%
37
+
38
+ class Jiffy
39
+ module Parsers
40
+ module JsonObject
41
+ def initialize(*args)
42
+ %% write data;
43
+ super
44
+ end
45
+
46
+ def parse_json_object(p, pe)
47
+ %% write init;
48
+ %% write exec;
49
+
50
+ if cs >= json_object_first_final
51
+ p + 1
52
+ else
53
+ raise_unparseable p
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,267 @@
1
+
2
+ # line 1 "json_string.rl"
3
+
4
+ # line 17 "json_string.rl"
5
+
6
+
7
+ class Jiffy
8
+ module Parsers
9
+ module JsonString
10
+ def initialize(*args)
11
+
12
+ # line 13 "json_string.rb"
13
+ class << self
14
+ attr_accessor :_json_string_actions
15
+ private :_json_string_actions, :_json_string_actions=
16
+ end
17
+ self._json_string_actions = [
18
+ 0, 1, 0, 1, 1
19
+ ]
20
+
21
+ class << self
22
+ attr_accessor :_json_string_key_offsets
23
+ private :_json_string_key_offsets, :_json_string_key_offsets=
24
+ end
25
+ self._json_string_key_offsets = [
26
+ 0, 0, 1, 5, 14, 20, 26, 32,
27
+ 38
28
+ ]
29
+
30
+ class << self
31
+ attr_accessor :_json_string_trans_keys
32
+ private :_json_string_trans_keys, :_json_string_trans_keys=
33
+ end
34
+ self._json_string_trans_keys = [
35
+ 34, 34, 92, 0, 31, 34, 47, 92,
36
+ 98, 102, 110, 114, 116, 117, 48, 57,
37
+ 65, 70, 97, 102, 48, 57, 65, 70,
38
+ 97, 102, 48, 57, 65, 70, 97, 102,
39
+ 48, 57, 65, 70, 97, 102, 0
40
+ ]
41
+
42
+ class << self
43
+ attr_accessor :_json_string_single_lengths
44
+ private :_json_string_single_lengths, :_json_string_single_lengths=
45
+ end
46
+ self._json_string_single_lengths = [
47
+ 0, 1, 2, 9, 0, 0, 0, 0,
48
+ 0
49
+ ]
50
+
51
+ class << self
52
+ attr_accessor :_json_string_range_lengths
53
+ private :_json_string_range_lengths, :_json_string_range_lengths=
54
+ end
55
+ self._json_string_range_lengths = [
56
+ 0, 0, 1, 0, 3, 3, 3, 3,
57
+ 0
58
+ ]
59
+
60
+ class << self
61
+ attr_accessor :_json_string_index_offsets
62
+ private :_json_string_index_offsets, :_json_string_index_offsets=
63
+ end
64
+ self._json_string_index_offsets = [
65
+ 0, 0, 2, 6, 16, 20, 24, 28,
66
+ 32
67
+ ]
68
+
69
+ class << self
70
+ attr_accessor :_json_string_indicies
71
+ private :_json_string_indicies, :_json_string_indicies=
72
+ end
73
+ self._json_string_indicies = [
74
+ 0, 1, 3, 4, 1, 2, 2, 2,
75
+ 2, 2, 2, 2, 2, 2, 5, 1,
76
+ 6, 6, 6, 1, 7, 7, 7, 1,
77
+ 8, 8, 8, 1, 2, 2, 2, 1,
78
+ 1, 0
79
+ ]
80
+
81
+ class << self
82
+ attr_accessor :_json_string_trans_targs
83
+ private :_json_string_trans_targs, :_json_string_trans_targs=
84
+ end
85
+ self._json_string_trans_targs = [
86
+ 2, 0, 2, 8, 3, 4, 5, 6,
87
+ 7
88
+ ]
89
+
90
+ class << self
91
+ attr_accessor :_json_string_trans_actions
92
+ private :_json_string_trans_actions, :_json_string_trans_actions=
93
+ end
94
+ self._json_string_trans_actions = [
95
+ 0, 0, 3, 1, 3, 3, 3, 3,
96
+ 3
97
+ ]
98
+
99
+ class << self
100
+ attr_accessor :json_string_start
101
+ end
102
+ self.json_string_start = 1;
103
+ class << self
104
+ attr_accessor :json_string_first_final
105
+ end
106
+ self.json_string_first_final = 8;
107
+ class << self
108
+ attr_accessor :json_string_error
109
+ end
110
+ self.json_string_error = 0;
111
+
112
+ class << self
113
+ attr_accessor :json_string_en_main
114
+ end
115
+ self.json_string_en_main = 1;
116
+
117
+
118
+ # line 24 "json_string.rl"
119
+ super
120
+ end
121
+
122
+ def parse_json_string(p, pe)
123
+ t_p = p + 1
124
+
125
+
126
+ # line 127 "json_string.rb"
127
+ begin
128
+ p ||= 0
129
+ pe ||= data.length
130
+ cs = json_string_start
131
+ end
132
+
133
+ # line 31 "json_string.rl"
134
+
135
+ # line 136 "json_string.rb"
136
+ begin
137
+ _klen, _trans, _keys, _acts, _nacts = nil
138
+ _goto_level = 0
139
+ _resume = 10
140
+ _eof_trans = 15
141
+ _again = 20
142
+ _test_eof = 30
143
+ _out = 40
144
+ while true
145
+ _trigger_goto = false
146
+ if _goto_level <= 0
147
+ if p == pe
148
+ _goto_level = _test_eof
149
+ next
150
+ end
151
+ if cs == 0
152
+ _goto_level = _out
153
+ next
154
+ end
155
+ end
156
+ if _goto_level <= _resume
157
+ _keys = _json_string_key_offsets[cs]
158
+ _trans = _json_string_index_offsets[cs]
159
+ _klen = _json_string_single_lengths[cs]
160
+ _break_match = false
161
+
162
+ begin
163
+ if _klen > 0
164
+ _lower = _keys
165
+ _upper = _keys + _klen - 1
166
+
167
+ loop do
168
+ break if _upper < _lower
169
+ _mid = _lower + ( (_upper - _lower) >> 1 )
170
+
171
+ if data[p].ord < _json_string_trans_keys[_mid]
172
+ _upper = _mid - 1
173
+ elsif data[p].ord > _json_string_trans_keys[_mid]
174
+ _lower = _mid + 1
175
+ else
176
+ _trans += (_mid - _keys)
177
+ _break_match = true
178
+ break
179
+ end
180
+ end # loop
181
+ break if _break_match
182
+ _keys += _klen
183
+ _trans += _klen
184
+ end
185
+ _klen = _json_string_range_lengths[cs]
186
+ if _klen > 0
187
+ _lower = _keys
188
+ _upper = _keys + (_klen << 1) - 2
189
+ loop do
190
+ break if _upper < _lower
191
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1)
192
+ if data[p].ord < _json_string_trans_keys[_mid]
193
+ _upper = _mid - 2
194
+ elsif data[p].ord > _json_string_trans_keys[_mid+1]
195
+ _lower = _mid + 2
196
+ else
197
+ _trans += ((_mid - _keys) >> 1)
198
+ _break_match = true
199
+ break
200
+ end
201
+ end # loop
202
+ break if _break_match
203
+ _trans += _klen
204
+ end
205
+ end while false
206
+ _trans = _json_string_indicies[_trans]
207
+ cs = _json_string_trans_targs[_trans]
208
+ if _json_string_trans_actions[_trans] != 0
209
+ _acts = _json_string_trans_actions[_trans]
210
+ _nacts = _json_string_actions[_acts]
211
+ _acts += 1
212
+ while _nacts > 0
213
+ _nacts -= 1
214
+ _acts += 1
215
+ case _json_string_actions[_acts - 1]
216
+ when 0 then
217
+ # line 5 "json_string.rl"
218
+ begin
219
+ p = p - 1; begin
220
+ p += 1
221
+ _trigger_goto = true
222
+ _goto_level = _out
223
+ break
224
+ end
225
+ end
226
+ when 1 then
227
+ # line 7 "json_string.rl"
228
+ begin
229
+ o.t :char, [data[p]].pack("c*") end
230
+ # line 231 "json_string.rb"
231
+ end # action switch
232
+ end
233
+ end
234
+ if _trigger_goto
235
+ next
236
+ end
237
+ end
238
+ if _goto_level <= _again
239
+ if cs == 0
240
+ _goto_level = _out
241
+ next
242
+ end
243
+ p += 1
244
+ if p != pe
245
+ _goto_level = _resume
246
+ next
247
+ end
248
+ end
249
+ if _goto_level <= _test_eof
250
+ end
251
+ if _goto_level <= _out
252
+ break
253
+ end
254
+ end
255
+ end
256
+
257
+ # line 32 "json_string.rl"
258
+
259
+ if cs >= json_string_first_final
260
+ p + 1
261
+ else
262
+ raise_unparseable p
263
+ end
264
+ end
265
+ end
266
+ end
267
+ end