jiffy 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,56 @@
1
+ %%{
2
+ machine json;
3
+ include json_common "json_common.rl";
4
+
5
+ action parse_object {
6
+ if np = parse_json_object(fpc, pe)
7
+ fexec np;
8
+ else
9
+ fhold;
10
+ fbreak;
11
+ end
12
+ }
13
+
14
+ action parse_array {
15
+ if np = parse_json_array(fpc, pe)
16
+ fexec np;
17
+ else
18
+ fhold;
19
+ fbreak;
20
+ end
21
+ }
22
+
23
+ main := ignore* (
24
+ begin_object >parse_object |
25
+ begin_array >parse_array
26
+ ) ignore*;
27
+ }%%
28
+
29
+ class Jiffy
30
+ module Parsers
31
+ module Json
32
+ def initialize(*args)
33
+ %% write data;
34
+ super
35
+ end
36
+
37
+ def parse_json
38
+ pe = :ignored
39
+ eof = :ignored
40
+ leftover = []
41
+
42
+ %% write init;
43
+
44
+ while chunk = io.read(1_000_000)
45
+ self.data = leftover + chunk.unpack("c*")
46
+ p ||= 0
47
+ pe = data.length
48
+
49
+ %% write exec;
50
+ end
51
+
52
+ raise_unparseable p unless p == pe
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,306 @@
1
+
2
+ # line 1 "json_array.rl"
3
+
4
+ # line 23 "json_array.rl"
5
+
6
+
7
+ class Jiffy
8
+ module Parsers
9
+ module JsonArray
10
+ def initialize(*args)
11
+
12
+ # line 13 "json_array.rb"
13
+ class << self
14
+ attr_accessor :_json_array_actions
15
+ private :_json_array_actions, :_json_array_actions=
16
+ end
17
+ self._json_array_actions = [
18
+ 0, 1, 0, 1, 2, 1, 3, 2,
19
+ 4, 1
20
+ ]
21
+
22
+ class << self
23
+ attr_accessor :_json_array_key_offsets
24
+ private :_json_array_key_offsets, :_json_array_key_offsets=
25
+ end
26
+ self._json_array_key_offsets = [
27
+ 0, 0, 1, 18, 25, 41, 43, 44,
28
+ 46, 47, 49, 50, 52, 53, 55, 56,
29
+ 58, 59
30
+ ]
31
+
32
+ class << self
33
+ attr_accessor :_json_array_trans_keys
34
+ private :_json_array_trans_keys, :_json_array_trans_keys=
35
+ end
36
+ self._json_array_trans_keys = [
37
+ 91, 13, 32, 34, 45, 47, 73, 78,
38
+ 91, 93, 102, 110, 116, 123, 9, 10,
39
+ 48, 57, 13, 32, 44, 47, 93, 9,
40
+ 10, 13, 32, 34, 45, 47, 73, 78,
41
+ 91, 102, 110, 116, 123, 9, 10, 48,
42
+ 57, 42, 47, 42, 42, 47, 10, 42,
43
+ 47, 42, 42, 47, 10, 42, 47, 42,
44
+ 42, 47, 10, 0
45
+ ]
46
+
47
+ class << self
48
+ attr_accessor :_json_array_single_lengths
49
+ private :_json_array_single_lengths, :_json_array_single_lengths=
50
+ end
51
+ self._json_array_single_lengths = [
52
+ 0, 1, 13, 5, 12, 2, 1, 2,
53
+ 1, 2, 1, 2, 1, 2, 1, 2,
54
+ 1, 0
55
+ ]
56
+
57
+ class << self
58
+ attr_accessor :_json_array_range_lengths
59
+ private :_json_array_range_lengths, :_json_array_range_lengths=
60
+ end
61
+ self._json_array_range_lengths = [
62
+ 0, 0, 2, 1, 2, 0, 0, 0,
63
+ 0, 0, 0, 0, 0, 0, 0, 0,
64
+ 0, 0
65
+ ]
66
+
67
+ class << self
68
+ attr_accessor :_json_array_index_offsets
69
+ private :_json_array_index_offsets, :_json_array_index_offsets=
70
+ end
71
+ self._json_array_index_offsets = [
72
+ 0, 0, 2, 18, 25, 40, 43, 45,
73
+ 48, 50, 53, 55, 58, 60, 63, 65,
74
+ 68, 70
75
+ ]
76
+
77
+ class << self
78
+ attr_accessor :_json_array_indicies
79
+ private :_json_array_indicies, :_json_array_indicies=
80
+ end
81
+ self._json_array_indicies = [
82
+ 0, 1, 2, 2, 3, 3, 4, 3,
83
+ 3, 3, 5, 3, 3, 3, 3, 2,
84
+ 3, 1, 6, 6, 7, 8, 5, 6,
85
+ 1, 9, 9, 3, 3, 10, 3, 3,
86
+ 3, 3, 3, 3, 3, 9, 3, 1,
87
+ 11, 12, 1, 13, 11, 13, 9, 11,
88
+ 9, 12, 14, 15, 1, 16, 14, 16,
89
+ 6, 14, 6, 15, 17, 18, 1, 19,
90
+ 17, 19, 2, 17, 2, 18, 1, 0
91
+ ]
92
+
93
+ class << self
94
+ attr_accessor :_json_array_trans_targs
95
+ private :_json_array_trans_targs, :_json_array_trans_targs=
96
+ end
97
+ self._json_array_trans_targs = [
98
+ 2, 0, 2, 3, 13, 17, 3, 4,
99
+ 9, 4, 5, 6, 8, 7, 10, 12,
100
+ 11, 14, 16, 15
101
+ ]
102
+
103
+ class << self
104
+ attr_accessor :_json_array_trans_actions
105
+ private :_json_array_trans_actions, :_json_array_trans_actions=
106
+ end
107
+ self._json_array_trans_actions = [
108
+ 5, 0, 0, 1, 0, 7, 0, 3,
109
+ 0, 0, 0, 0, 0, 0, 0, 0,
110
+ 0, 0, 0, 0
111
+ ]
112
+
113
+ class << self
114
+ attr_accessor :json_array_start
115
+ end
116
+ self.json_array_start = 1;
117
+ class << self
118
+ attr_accessor :json_array_first_final
119
+ end
120
+ self.json_array_first_final = 17;
121
+ class << self
122
+ attr_accessor :json_array_error
123
+ end
124
+ self.json_array_error = 0;
125
+
126
+ class << self
127
+ attr_accessor :json_array_en_main
128
+ end
129
+ self.json_array_en_main = 1;
130
+
131
+
132
+ # line 30 "json_array.rl"
133
+ super
134
+ end
135
+
136
+ def parse_json_array(p, pe)
137
+
138
+ # line 139 "json_array.rb"
139
+ begin
140
+ p ||= 0
141
+ pe ||= data.length
142
+ cs = json_array_start
143
+ end
144
+
145
+ # line 35 "json_array.rl"
146
+
147
+ # line 148 "json_array.rb"
148
+ begin
149
+ _klen, _trans, _keys, _acts, _nacts = nil
150
+ _goto_level = 0
151
+ _resume = 10
152
+ _eof_trans = 15
153
+ _again = 20
154
+ _test_eof = 30
155
+ _out = 40
156
+ while true
157
+ _trigger_goto = false
158
+ if _goto_level <= 0
159
+ if p == pe
160
+ _goto_level = _test_eof
161
+ next
162
+ end
163
+ if cs == 0
164
+ _goto_level = _out
165
+ next
166
+ end
167
+ end
168
+ if _goto_level <= _resume
169
+ _keys = _json_array_key_offsets[cs]
170
+ _trans = _json_array_index_offsets[cs]
171
+ _klen = _json_array_single_lengths[cs]
172
+ _break_match = false
173
+
174
+ begin
175
+ if _klen > 0
176
+ _lower = _keys
177
+ _upper = _keys + _klen - 1
178
+
179
+ loop do
180
+ break if _upper < _lower
181
+ _mid = _lower + ( (_upper - _lower) >> 1 )
182
+
183
+ if data[p].ord < _json_array_trans_keys[_mid]
184
+ _upper = _mid - 1
185
+ elsif data[p].ord > _json_array_trans_keys[_mid]
186
+ _lower = _mid + 1
187
+ else
188
+ _trans += (_mid - _keys)
189
+ _break_match = true
190
+ break
191
+ end
192
+ end # loop
193
+ break if _break_match
194
+ _keys += _klen
195
+ _trans += _klen
196
+ end
197
+ _klen = _json_array_range_lengths[cs]
198
+ if _klen > 0
199
+ _lower = _keys
200
+ _upper = _keys + (_klen << 1) - 2
201
+ loop do
202
+ break if _upper < _lower
203
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1)
204
+ if data[p].ord < _json_array_trans_keys[_mid]
205
+ _upper = _mid - 2
206
+ elsif data[p].ord > _json_array_trans_keys[_mid+1]
207
+ _lower = _mid + 2
208
+ else
209
+ _trans += ((_mid - _keys) >> 1)
210
+ _break_match = true
211
+ break
212
+ end
213
+ end # loop
214
+ break if _break_match
215
+ _trans += _klen
216
+ end
217
+ end while false
218
+ _trans = _json_array_indicies[_trans]
219
+ cs = _json_array_trans_targs[_trans]
220
+ if _json_array_trans_actions[_trans] != 0
221
+ _acts = _json_array_trans_actions[_trans]
222
+ _nacts = _json_array_actions[_acts]
223
+ _acts += 1
224
+ while _nacts > 0
225
+ _nacts -= 1
226
+ _acts += 1
227
+ case _json_array_actions[_acts - 1]
228
+ when 0 then
229
+ # line 5 "json_array.rl"
230
+ begin
231
+
232
+ np = parse_json_value(p, pe)
233
+
234
+ if np
235
+ begin p = (( np))-1; end
236
+
237
+ else
238
+ p = p - 1; begin
239
+ p += 1
240
+ _trigger_goto = true
241
+ _goto_level = _out
242
+ break
243
+ end
244
+
245
+ end
246
+ end
247
+ when 1 then
248
+ # line 15 "json_array.rl"
249
+ begin
250
+ p = p - 1; begin
251
+ p += 1
252
+ _trigger_goto = true
253
+ _goto_level = _out
254
+ break
255
+ end
256
+ end
257
+ when 2 then
258
+ # line 17 "json_array.rl"
259
+ begin
260
+ o.t :value_separator end
261
+ when 3 then
262
+ # line 19 "json_array.rl"
263
+ begin
264
+ o.t :begin_array end
265
+ when 4 then
266
+ # line 22 "json_array.rl"
267
+ begin
268
+ o.t :end_array end
269
+ # line 270 "json_array.rb"
270
+ end # action switch
271
+ end
272
+ end
273
+ if _trigger_goto
274
+ next
275
+ end
276
+ end
277
+ if _goto_level <= _again
278
+ if cs == 0
279
+ _goto_level = _out
280
+ next
281
+ end
282
+ p += 1
283
+ if p != pe
284
+ _goto_level = _resume
285
+ next
286
+ end
287
+ end
288
+ if _goto_level <= _test_eof
289
+ end
290
+ if _goto_level <= _out
291
+ break
292
+ end
293
+ end
294
+ end
295
+
296
+ # line 36 "json_array.rl"
297
+
298
+ if cs >= json_array_first_final
299
+ p + 1
300
+ else
301
+ raise_unparseable p
302
+ end
303
+ end
304
+ end
305
+ end
306
+ end
@@ -0,0 +1,45 @@
1
+ %%{
2
+ machine json_array;
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 exit { fhold; fbreak; }
16
+
17
+ next_element = value_separator >{ o.t :value_separator } ignore* begin_value >parse_value;
18
+
19
+ main := begin_array >{ o.t :begin_array } ignore*
20
+ ((begin_value >parse_value ignore*)
21
+ (ignore* next_element ignore*)*)?
22
+ end_array >{ o.t :end_array } @exit;
23
+ }%%
24
+
25
+ class Jiffy
26
+ module Parsers
27
+ module JsonArray
28
+ def initialize(*args)
29
+ %% write data;
30
+ super
31
+ end
32
+
33
+ def parse_json_array(p, pe)
34
+ %% write init;
35
+ %% write exec;
36
+
37
+ if cs >= json_array_first_final
38
+ p + 1
39
+ else
40
+ raise_unparseable p
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,24 @@
1
+ %%{
2
+ machine json_common;
3
+
4
+ cr = '\n';
5
+ cr_neg = [^\n];
6
+ ws = [ \t\r\n];
7
+ c_comment = '/*' ( any* - (any* '*/' any* ) ) '*/';
8
+ cpp_comment = '//' cr_neg* cr;
9
+ comment = c_comment | cpp_comment;
10
+ ignore = ws | comment;
11
+ name_separator = ':';
12
+ value_separator = ',';
13
+ Vnull = 'null';
14
+ Vfalse = 'false';
15
+ Vtrue = 'true';
16
+ begin_value = [nft\"\-\[\{NI] | digit;
17
+ begin_object = '{';
18
+ end_object = '}';
19
+ begin_array = '[';
20
+ end_array = ']';
21
+ begin_string = '"';
22
+ begin_name = begin_string;
23
+ begin_number = digit | '-';
24
+ }%%
@@ -0,0 +1,269 @@
1
+
2
+ # line 1 "json_float.rl"
3
+
4
+ # line 15 "json_float.rl"
5
+
6
+
7
+ class Jiffy
8
+ module Parsers
9
+ module JsonFloat
10
+ def initialize(*args)
11
+
12
+ # line 13 "json_float.rb"
13
+ class << self
14
+ attr_accessor :_json_float_actions
15
+ private :_json_float_actions, :_json_float_actions=
16
+ end
17
+ self._json_float_actions = [
18
+ 0, 1, 0, 1, 1, 1, 2
19
+ ]
20
+
21
+ class << self
22
+ attr_accessor :_json_float_key_offsets
23
+ private :_json_float_key_offsets, :_json_float_key_offsets=
24
+ end
25
+ self._json_float_key_offsets = [
26
+ 0, 0, 4, 7, 9, 13, 15, 21,
27
+ 21, 27, 33
28
+ ]
29
+
30
+ class << self
31
+ attr_accessor :_json_float_trans_keys
32
+ private :_json_float_trans_keys, :_json_float_trans_keys=
33
+ end
34
+ self._json_float_trans_keys = [
35
+ 45, 48, 49, 57, 48, 49, 57, 48,
36
+ 57, 43, 45, 48, 57, 48, 57, 45,
37
+ 46, 69, 101, 48, 57, 69, 101, 45,
38
+ 46, 48, 57, 69, 101, 45, 46, 48,
39
+ 57, 45, 46, 69, 101, 48, 57, 0
40
+ ]
41
+
42
+ class << self
43
+ attr_accessor :_json_float_single_lengths
44
+ private :_json_float_single_lengths, :_json_float_single_lengths=
45
+ end
46
+ self._json_float_single_lengths = [
47
+ 0, 2, 1, 0, 2, 0, 4, 0,
48
+ 2, 2, 4
49
+ ]
50
+
51
+ class << self
52
+ attr_accessor :_json_float_range_lengths
53
+ private :_json_float_range_lengths, :_json_float_range_lengths=
54
+ end
55
+ self._json_float_range_lengths = [
56
+ 0, 1, 1, 1, 1, 1, 1, 0,
57
+ 2, 2, 1
58
+ ]
59
+
60
+ class << self
61
+ attr_accessor :_json_float_index_offsets
62
+ private :_json_float_index_offsets, :_json_float_index_offsets=
63
+ end
64
+ self._json_float_index_offsets = [
65
+ 0, 0, 4, 7, 9, 13, 15, 21,
66
+ 22, 27, 32
67
+ ]
68
+
69
+ class << self
70
+ attr_accessor :_json_float_indicies
71
+ private :_json_float_indicies, :_json_float_indicies=
72
+ end
73
+ self._json_float_indicies = [
74
+ 0, 2, 3, 1, 2, 3, 1, 4,
75
+ 1, 5, 5, 6, 1, 6, 1, 1,
76
+ 8, 9, 9, 1, 7, 1, 9, 9,
77
+ 1, 4, 7, 1, 1, 1, 6, 7,
78
+ 1, 8, 9, 9, 10, 7, 0
79
+ ]
80
+
81
+ class << self
82
+ attr_accessor :_json_float_trans_targs
83
+ private :_json_float_trans_targs, :_json_float_trans_targs=
84
+ end
85
+ self._json_float_trans_targs = [
86
+ 2, 0, 6, 10, 8, 5, 9, 7,
87
+ 3, 4, 10
88
+ ]
89
+
90
+ class << self
91
+ attr_accessor :_json_float_trans_actions
92
+ private :_json_float_trans_actions, :_json_float_trans_actions=
93
+ end
94
+ self._json_float_trans_actions = [
95
+ 3, 0, 5, 3, 5, 3, 5, 1,
96
+ 3, 3, 5
97
+ ]
98
+
99
+ class << self
100
+ attr_accessor :json_float_start
101
+ end
102
+ self.json_float_start = 1;
103
+ class << self
104
+ attr_accessor :json_float_first_final
105
+ end
106
+ self.json_float_first_final = 6;
107
+ class << self
108
+ attr_accessor :json_float_error
109
+ end
110
+ self.json_float_error = 0;
111
+
112
+ class << self
113
+ attr_accessor :json_float_en_main
114
+ end
115
+ self.json_float_en_main = 1;
116
+
117
+
118
+ # line 22 "json_float.rl"
119
+ super
120
+ end
121
+
122
+ def parse_json_float(p, pe)
123
+ t_p = p
124
+
125
+
126
+ # line 127 "json_float.rb"
127
+ begin
128
+ p ||= 0
129
+ pe ||= data.length
130
+ cs = json_float_start
131
+ end
132
+
133
+ # line 29 "json_float.rl"
134
+
135
+ # line 136 "json_float.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_float_key_offsets[cs]
158
+ _trans = _json_float_index_offsets[cs]
159
+ _klen = _json_float_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_float_trans_keys[_mid]
172
+ _upper = _mid - 1
173
+ elsif data[p].ord > _json_float_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_float_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_float_trans_keys[_mid]
193
+ _upper = _mid - 2
194
+ elsif data[p].ord > _json_float_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_float_indicies[_trans]
207
+ cs = _json_float_trans_targs[_trans]
208
+ if _json_float_trans_actions[_trans] != 0
209
+ _acts = _json_float_trans_actions[_trans]
210
+ _nacts = _json_float_actions[_acts]
211
+ _acts += 1
212
+ while _nacts > 0
213
+ _nacts -= 1
214
+ _acts += 1
215
+ case _json_float_actions[_acts - 1]
216
+ when 0 then
217
+ # line 5 "json_float.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_float.rl"
228
+ begin
229
+ o.t :char, [data[p]].pack("c*") end
230
+ when 2 then
231
+ # line 8 "json_float.rl"
232
+ begin
233
+ o.t :number, [data[p]].pack("c*").to_i end
234
+ # line 235 "json_float.rb"
235
+ end # action switch
236
+ end
237
+ end
238
+ if _trigger_goto
239
+ next
240
+ end
241
+ end
242
+ if _goto_level <= _again
243
+ if cs == 0
244
+ _goto_level = _out
245
+ next
246
+ end
247
+ p += 1
248
+ if p != pe
249
+ _goto_level = _resume
250
+ next
251
+ end
252
+ end
253
+ if _goto_level <= _test_eof
254
+ end
255
+ if _goto_level <= _out
256
+ break
257
+ end
258
+ end
259
+ end
260
+
261
+ # line 30 "json_float.rl"
262
+
263
+ if cs >= json_float_first_final
264
+ p
265
+ end
266
+ end
267
+ end
268
+ end
269
+ end