trenni 3.8.0 → 3.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -199,14 +199,14 @@
199
199
  action cdata_error {
200
200
  raise ParseError.new("could not parse cdata", buffer, p)
201
201
  }
202
-
202
+
203
203
  # This magic ensures that we process bytes.
204
204
  getkey bytes[p];
205
205
 
206
206
  include markup "trenni/markup.rl";
207
207
  }%%
208
208
 
209
- require_relative '../parse_error'
209
+ require_relative '../error'
210
210
 
211
211
  module Trenni
212
212
  module Fallback
@@ -0,0 +1,565 @@
1
+
2
+ # line 1 "query.rl"
3
+ # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+
24
+ # line 74 "query.rl"
25
+
26
+
27
+ require_relative '../error'
28
+
29
+ module Trenni
30
+ module Fallback
31
+
32
+ # line 33 "query.rb"
33
+ class << self
34
+ attr_accessor :_query_trans_keys
35
+ private :_query_trans_keys, :_query_trans_keys=
36
+ end
37
+ self._query_trans_keys = [
38
+ 0, 0, 48, 102, 48, 102,
39
+ 37, 93, 37, 93, 48,
40
+ 102, 48, 102, 37, 93,
41
+ 37, 93, 48, 102, 48, 102,
42
+ 37, 93, 37, 93, 37,
43
+ 93, 37, 93, 37, 93,
44
+ 38, 91, 38, 61, 0
45
+ ]
46
+
47
+ class << self
48
+ attr_accessor :_query_key_spans
49
+ private :_query_key_spans, :_query_key_spans=
50
+ end
51
+ self._query_key_spans = [
52
+ 0, 55, 55, 57, 57, 55, 55, 57,
53
+ 57, 55, 55, 57, 57, 57, 57, 57,
54
+ 54, 24
55
+ ]
56
+
57
+ class << self
58
+ attr_accessor :_query_index_offsets
59
+ private :_query_index_offsets, :_query_index_offsets=
60
+ end
61
+ self._query_index_offsets = [
62
+ 0, 0, 56, 112, 170, 228, 284, 340,
63
+ 398, 456, 512, 568, 626, 684, 742, 800,
64
+ 858, 913
65
+ ]
66
+
67
+ class << self
68
+ attr_accessor :_query_indicies
69
+ private :_query_indicies, :_query_indicies=
70
+ end
71
+ self._query_indicies = [
72
+ 0, 0, 0, 0, 0, 0, 0, 0,
73
+ 0, 0, 1, 1, 1, 1, 1, 1,
74
+ 1, 0, 0, 0, 0, 0, 0, 1,
75
+ 1, 1, 1, 1, 1, 1, 1, 1,
76
+ 1, 1, 1, 1, 1, 1, 1, 1,
77
+ 1, 1, 1, 1, 1, 1, 1, 1,
78
+ 1, 0, 0, 0, 0, 0, 0, 1,
79
+ 2, 2, 2, 2, 2, 2, 2, 2,
80
+ 2, 2, 1, 1, 1, 1, 1, 1,
81
+ 1, 2, 2, 2, 2, 2, 2, 1,
82
+ 1, 1, 1, 1, 1, 1, 1, 1,
83
+ 1, 1, 1, 1, 1, 1, 1, 1,
84
+ 1, 1, 1, 1, 1, 1, 1, 1,
85
+ 1, 2, 2, 2, 2, 2, 2, 1,
86
+ 4, 1, 3, 3, 3, 3, 5, 3,
87
+ 3, 3, 3, 6, 6, 6, 6, 6,
88
+ 6, 6, 6, 6, 6, 3, 3, 3,
89
+ 1, 3, 3, 3, 3, 3, 3, 3,
90
+ 3, 3, 3, 3, 3, 3, 3, 3,
91
+ 3, 3, 3, 3, 3, 3, 3, 3,
92
+ 3, 3, 3, 3, 3, 3, 1, 3,
93
+ 1, 3, 7, 1, 2, 2, 2, 2,
94
+ 8, 2, 2, 2, 2, 9, 9, 9,
95
+ 9, 9, 9, 9, 9, 9, 9, 2,
96
+ 2, 2, 1, 2, 2, 2, 2, 2,
97
+ 2, 2, 2, 2, 2, 2, 2, 2,
98
+ 2, 2, 2, 2, 2, 2, 2, 2,
99
+ 2, 2, 2, 2, 2, 2, 2, 2,
100
+ 1, 2, 1, 2, 10, 10, 10, 10,
101
+ 10, 10, 10, 10, 10, 10, 1, 1,
102
+ 1, 1, 1, 1, 1, 10, 10, 10,
103
+ 10, 10, 10, 1, 1, 1, 1, 1,
104
+ 1, 1, 1, 1, 1, 1, 1, 1,
105
+ 1, 1, 1, 1, 1, 1, 1, 1,
106
+ 1, 1, 1, 1, 1, 10, 10, 10,
107
+ 10, 10, 10, 1, 11, 11, 11, 11,
108
+ 11, 11, 11, 11, 11, 11, 1, 1,
109
+ 1, 1, 1, 1, 1, 11, 11, 11,
110
+ 11, 11, 11, 1, 1, 1, 1, 1,
111
+ 1, 1, 1, 1, 1, 1, 1, 1,
112
+ 1, 1, 1, 1, 1, 1, 1, 1,
113
+ 1, 1, 1, 1, 1, 11, 11, 11,
114
+ 11, 11, 11, 1, 13, 1, 12, 12,
115
+ 12, 12, 14, 12, 12, 12, 12, 15,
116
+ 15, 15, 15, 15, 15, 15, 15, 15,
117
+ 15, 12, 12, 12, 1, 12, 12, 12,
118
+ 12, 12, 12, 12, 12, 12, 12, 12,
119
+ 12, 12, 12, 12, 12, 12, 12, 12,
120
+ 12, 12, 12, 12, 12, 12, 12, 12,
121
+ 12, 12, 1, 12, 16, 12, 18, 1,
122
+ 17, 17, 17, 17, 19, 17, 17, 17,
123
+ 17, 17, 17, 17, 17, 17, 17, 17,
124
+ 17, 17, 17, 17, 17, 17, 1, 17,
125
+ 17, 17, 17, 17, 17, 17, 17, 17,
126
+ 17, 17, 17, 17, 17, 17, 17, 17,
127
+ 17, 17, 17, 17, 17, 17, 17, 17,
128
+ 17, 17, 17, 17, 1, 17, 20, 17,
129
+ 21, 21, 21, 21, 21, 21, 21, 21,
130
+ 21, 21, 1, 1, 1, 1, 1, 1,
131
+ 1, 21, 21, 21, 21, 21, 21, 1,
132
+ 1, 1, 1, 1, 1, 1, 1, 1,
133
+ 1, 1, 1, 1, 1, 1, 1, 1,
134
+ 1, 1, 1, 1, 1, 1, 1, 1,
135
+ 1, 21, 21, 21, 21, 21, 21, 1,
136
+ 17, 17, 17, 17, 17, 17, 17, 17,
137
+ 17, 17, 1, 1, 1, 1, 1, 1,
138
+ 1, 17, 17, 17, 17, 17, 17, 1,
139
+ 1, 1, 1, 1, 1, 1, 1, 1,
140
+ 1, 1, 1, 1, 1, 1, 1, 1,
141
+ 1, 1, 1, 1, 1, 1, 1, 1,
142
+ 1, 17, 17, 17, 17, 17, 17, 1,
143
+ 18, 1, 17, 17, 17, 17, 19, 17,
144
+ 17, 17, 17, 22, 22, 22, 22, 22,
145
+ 22, 22, 22, 22, 22, 17, 17, 17,
146
+ 1, 17, 17, 17, 17, 17, 17, 17,
147
+ 17, 17, 17, 17, 17, 17, 17, 17,
148
+ 17, 17, 17, 17, 17, 17, 17, 17,
149
+ 17, 17, 17, 17, 17, 17, 1, 17,
150
+ 23, 17, 4, 1, 3, 3, 3, 3,
151
+ 5, 3, 3, 3, 3, 6, 6, 6,
152
+ 6, 6, 6, 6, 6, 6, 6, 3,
153
+ 3, 3, 1, 3, 3, 3, 3, 3,
154
+ 3, 3, 3, 3, 3, 3, 3, 3,
155
+ 3, 3, 3, 3, 3, 3, 3, 3,
156
+ 3, 3, 3, 3, 3, 3, 3, 3,
157
+ 1, 3, 1, 3, 7, 24, 2, 2,
158
+ 2, 2, 8, 2, 2, 2, 2, 2,
159
+ 2, 2, 2, 2, 2, 2, 2, 2,
160
+ 2, 2, 2, 2, 25, 2, 2, 2,
161
+ 2, 2, 2, 2, 2, 2, 2, 2,
162
+ 2, 2, 2, 2, 2, 2, 2, 2,
163
+ 2, 2, 2, 2, 2, 2, 2, 2,
164
+ 2, 2, 26, 2, 1, 2, 28, 29,
165
+ 27, 27, 27, 27, 30, 27, 27, 27,
166
+ 27, 27, 27, 27, 27, 27, 27, 27,
167
+ 27, 27, 27, 27, 27, 27, 1, 27,
168
+ 27, 27, 27, 27, 27, 27, 27, 27,
169
+ 27, 27, 27, 27, 27, 27, 27, 27,
170
+ 27, 27, 27, 27, 27, 27, 27, 27,
171
+ 27, 27, 27, 27, 1, 27, 1, 27,
172
+ 31, 32, 11, 11, 11, 11, 33, 11,
173
+ 11, 11, 11, 11, 11, 11, 11, 11,
174
+ 11, 11, 11, 11, 11, 11, 11, 11,
175
+ 1, 11, 11, 11, 11, 11, 11, 11,
176
+ 11, 11, 11, 11, 11, 11, 11, 11,
177
+ 11, 11, 11, 11, 11, 11, 11, 11,
178
+ 11, 11, 11, 11, 11, 11, 1, 11,
179
+ 1, 11, 34, 1, 1, 1, 1, 1,
180
+ 1, 1, 1, 1, 1, 1, 1, 1,
181
+ 1, 1, 1, 1, 1, 1, 1, 1,
182
+ 1, 35, 1, 1, 1, 1, 1, 1,
183
+ 1, 1, 1, 1, 1, 1, 1, 1,
184
+ 1, 1, 1, 1, 1, 1, 1, 1,
185
+ 1, 1, 1, 1, 1, 1, 1, 36,
186
+ 1, 37, 1, 1, 1, 1, 1, 1,
187
+ 1, 1, 1, 1, 1, 1, 1, 1,
188
+ 1, 1, 1, 1, 1, 1, 1, 1,
189
+ 38, 1, 0
190
+ ]
191
+
192
+ class << self
193
+ attr_accessor :_query_trans_targs
194
+ private :_query_trans_targs, :_query_trans_targs=
195
+ end
196
+ self._query_trans_targs = [
197
+ 2, 0, 13, 13, 1, 13, 4, 1,
198
+ 13, 4, 6, 15, 8, 9, 8, 11,
199
+ 17, 8, 9, 8, 16, 10, 11, 16,
200
+ 3, 14, 7, 15, 5, 3, 15, 5,
201
+ 3, 15, 3, 14, 7, 3, 14
202
+ ]
203
+
204
+ class << self
205
+ attr_accessor :_query_trans_actions
206
+ private :_query_trans_actions, :_query_trans_actions=
207
+ end
208
+ self._query_trans_actions = [
209
+ 0, 0, 0, 1, 2, 2, 3, 4,
210
+ 4, 0, 0, 0, 1, 2, 2, 5,
211
+ 0, 0, 4, 4, 6, 0, 0, 7,
212
+ 8, 6, 6, 10, 11, 9, 11, 4,
213
+ 12, 4, 13, 0, 0, 14, 15
214
+ ]
215
+
216
+ class << self
217
+ attr_accessor :_query_eof_actions
218
+ private :_query_eof_actions, :_query_eof_actions=
219
+ end
220
+ self._query_eof_actions = [
221
+ 0, 0, 0, 0, 0, 0, 0, 0,
222
+ 0, 0, 0, 0, 0, 8, 9, 12,
223
+ 13, 14
224
+ ]
225
+
226
+ class << self
227
+ attr_accessor :query_start
228
+ end
229
+ self.query_start = 12;
230
+ class << self
231
+ attr_accessor :query_first_final
232
+ end
233
+ self.query_first_final = 12;
234
+ class << self
235
+ attr_accessor :query_error
236
+ end
237
+ self.query_error = 0;
238
+
239
+ class << self
240
+ attr_accessor :query_en_main
241
+ end
242
+ self.query_en_main = 12;
243
+
244
+
245
+ # line 81 "query.rl"
246
+
247
+ def self.parse_query(buffer, delegate)
248
+ data = buffer.read
249
+ bytes = data.bytes
250
+
251
+ p = 0
252
+ pe = eof = data.bytesize
253
+ stack = []
254
+
255
+ string_begin = string_end = nil
256
+ integer_begin = integer_end = nil
257
+ value_begin = value_end = nil
258
+ encoded = false
259
+
260
+
261
+ # line 262 "query.rb"
262
+ begin
263
+ p ||= 0
264
+ pe ||= data.length
265
+ cs = query_start
266
+ end
267
+
268
+ # line 96 "query.rl"
269
+
270
+ # line 271 "query.rb"
271
+ begin
272
+ testEof = false
273
+ _slen, _trans, _keys, _inds, _acts, _nacts = nil
274
+ _goto_level = 0
275
+ _resume = 10
276
+ _eof_trans = 15
277
+ _again = 20
278
+ _test_eof = 30
279
+ _out = 40
280
+ while true
281
+ if _goto_level <= 0
282
+ if p == pe
283
+ _goto_level = _test_eof
284
+ next
285
+ end
286
+ if cs == 0
287
+ _goto_level = _out
288
+ next
289
+ end
290
+ end
291
+ if _goto_level <= _resume
292
+ _keys = cs << 1
293
+ _inds = _query_index_offsets[cs]
294
+ _slen = _query_key_spans[cs]
295
+ _wide = ( bytes[p])
296
+ _trans = if ( _slen > 0 &&
297
+ _query_trans_keys[_keys] <= _wide &&
298
+ _wide <= _query_trans_keys[_keys + 1]
299
+ ) then
300
+ _query_indicies[ _inds + _wide - _query_trans_keys[_keys] ]
301
+ else
302
+ _query_indicies[ _inds + _slen ]
303
+ end
304
+ cs = _query_trans_targs[_trans]
305
+ if _query_trans_actions[_trans] != 0
306
+ case _query_trans_actions[_trans]
307
+ when 1 then
308
+ # line 24 "query.rl"
309
+ begin
310
+
311
+ string_begin = p
312
+ end
313
+ when 6 then
314
+ # line 28 "query.rl"
315
+ begin
316
+
317
+ string_end = p
318
+
319
+ delegate.string(data.byteslice(string_begin...string_end), encoded)
320
+
321
+ encoded = false
322
+ end
323
+ when 7 then
324
+ # line 40 "query.rl"
325
+ begin
326
+
327
+ integer_end = p
328
+
329
+ delegate.integer(data.byteslice(integer_begin...integer_end))
330
+ end
331
+ when 15 then
332
+ # line 46 "query.rl"
333
+ begin
334
+
335
+ delegate.append
336
+ end
337
+ when 10 then
338
+ # line 50 "query.rl"
339
+ begin
340
+
341
+ value_begin = p
342
+ end
343
+ when 13 then
344
+ # line 62 "query.rl"
345
+ begin
346
+
347
+ delegate.pair
348
+ end
349
+ when 4 then
350
+ # line 66 "query.rl"
351
+ begin
352
+
353
+ encoded = 1;
354
+ end
355
+ when 3 then
356
+ # line 24 "query.rl"
357
+ begin
358
+
359
+ string_begin = p
360
+ end
361
+ # line 36 "query.rl"
362
+ begin
363
+
364
+ integer_begin = p
365
+ end
366
+ when 2 then
367
+ # line 24 "query.rl"
368
+ begin
369
+
370
+ string_begin = p
371
+ end
372
+ # line 66 "query.rl"
373
+ begin
374
+
375
+ encoded = 1;
376
+ end
377
+ when 8 then
378
+ # line 28 "query.rl"
379
+ begin
380
+
381
+ string_end = p
382
+
383
+ delegate.string(data.byteslice(string_begin...string_end), encoded)
384
+
385
+ encoded = false
386
+ end
387
+ # line 62 "query.rl"
388
+ begin
389
+
390
+ delegate.pair
391
+ end
392
+ when 5 then
393
+ # line 36 "query.rl"
394
+ begin
395
+
396
+ integer_begin = p
397
+ end
398
+ # line 24 "query.rl"
399
+ begin
400
+
401
+ string_begin = p
402
+ end
403
+ when 14 then
404
+ # line 46 "query.rl"
405
+ begin
406
+
407
+ delegate.append
408
+ end
409
+ # line 62 "query.rl"
410
+ begin
411
+
412
+ delegate.pair
413
+ end
414
+ when 11 then
415
+ # line 50 "query.rl"
416
+ begin
417
+
418
+ value_begin = p
419
+ end
420
+ # line 66 "query.rl"
421
+ begin
422
+
423
+ encoded = 1;
424
+ end
425
+ when 12 then
426
+ # line 54 "query.rl"
427
+ begin
428
+
429
+ value_end = p
430
+
431
+ delegate.assign(data.byteslice(value_begin...value_end), encoded)
432
+
433
+ encoded = false
434
+ end
435
+ # line 62 "query.rl"
436
+ begin
437
+
438
+ delegate.pair
439
+ end
440
+ when 9 then
441
+ # line 50 "query.rl"
442
+ begin
443
+
444
+ value_begin = p
445
+ end
446
+ # line 54 "query.rl"
447
+ begin
448
+
449
+ value_end = p
450
+
451
+ delegate.assign(data.byteslice(value_begin...value_end), encoded)
452
+
453
+ encoded = false
454
+ end
455
+ # line 62 "query.rl"
456
+ begin
457
+
458
+ delegate.pair
459
+ end
460
+ # line 461 "query.rb"
461
+ end
462
+ end
463
+ end
464
+ if _goto_level <= _again
465
+ if cs == 0
466
+ _goto_level = _out
467
+ next
468
+ end
469
+ p += 1
470
+ if p != pe
471
+ _goto_level = _resume
472
+ next
473
+ end
474
+ end
475
+ if _goto_level <= _test_eof
476
+ if p == eof
477
+ case _query_eof_actions[cs]
478
+ when 13 then
479
+ # line 62 "query.rl"
480
+ begin
481
+
482
+ delegate.pair
483
+ end
484
+ when 8 then
485
+ # line 28 "query.rl"
486
+ begin
487
+
488
+ string_end = p
489
+
490
+ delegate.string(data.byteslice(string_begin...string_end), encoded)
491
+
492
+ encoded = false
493
+ end
494
+ # line 62 "query.rl"
495
+ begin
496
+
497
+ delegate.pair
498
+ end
499
+ when 14 then
500
+ # line 46 "query.rl"
501
+ begin
502
+
503
+ delegate.append
504
+ end
505
+ # line 62 "query.rl"
506
+ begin
507
+
508
+ delegate.pair
509
+ end
510
+ when 12 then
511
+ # line 54 "query.rl"
512
+ begin
513
+
514
+ value_end = p
515
+
516
+ delegate.assign(data.byteslice(value_begin...value_end), encoded)
517
+
518
+ encoded = false
519
+ end
520
+ # line 62 "query.rl"
521
+ begin
522
+
523
+ delegate.pair
524
+ end
525
+ when 9 then
526
+ # line 50 "query.rl"
527
+ begin
528
+
529
+ value_begin = p
530
+ end
531
+ # line 54 "query.rl"
532
+ begin
533
+
534
+ value_end = p
535
+
536
+ delegate.assign(data.byteslice(value_begin...value_end), encoded)
537
+
538
+ encoded = false
539
+ end
540
+ # line 62 "query.rl"
541
+ begin
542
+
543
+ delegate.pair
544
+ end
545
+ # line 546 "query.rb"
546
+ end
547
+ end
548
+
549
+ end
550
+ if _goto_level <= _out
551
+ break
552
+ end
553
+ end
554
+ end
555
+
556
+ # line 97 "query.rl"
557
+
558
+ if p != eof
559
+ raise ParseError.new("could not consume all input", buffer, p)
560
+ end
561
+
562
+ return nil
563
+ end
564
+ end
565
+ end