xrb 0.1 → 0.3.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 +7 -0
- checksums.yaml.gz.sig +1 -0
- data/bake/xrb/entities.rb +60 -0
- data/bake/xrb/parsers.rb +66 -0
- data/ext/Makefile +270 -0
- data/ext/XRB_Extension.bundle +0 -0
- data/ext/escape.o +0 -0
- data/ext/extconf.h +5 -0
- data/ext/extconf.rb +21 -0
- data/ext/markup.o +0 -0
- data/ext/mkmf.log +122 -0
- data/ext/query.o +0 -0
- data/ext/tag.o +0 -0
- data/ext/template.o +0 -0
- data/ext/xrb/escape.c +152 -0
- data/ext/xrb/escape.h +15 -0
- data/ext/xrb/markup.c +1949 -0
- data/ext/xrb/markup.h +6 -0
- data/ext/xrb/markup.rl +226 -0
- data/ext/xrb/query.c +619 -0
- data/ext/xrb/query.h +6 -0
- data/ext/xrb/query.rl +82 -0
- data/ext/xrb/tag.c +204 -0
- data/ext/xrb/tag.h +21 -0
- data/ext/xrb/template.c +1114 -0
- data/ext/xrb/template.h +6 -0
- data/ext/xrb/template.rl +77 -0
- data/ext/xrb/xrb.c +72 -0
- data/ext/xrb/xrb.h +132 -0
- data/ext/xrb.o +0 -0
- data/lib/xrb/buffer.rb +103 -0
- data/lib/xrb/builder.rb +229 -0
- data/lib/xrb/entities.rb +2137 -0
- data/lib/xrb/entities.xrb +15 -0
- data/lib/xrb/error.rb +81 -0
- data/lib/xrb/fallback/markup.rb +1657 -0
- data/lib/xrb/fallback/markup.rl +227 -0
- data/lib/xrb/fallback/query.rb +548 -0
- data/lib/xrb/fallback/query.rl +88 -0
- data/lib/xrb/fallback/template.rb +829 -0
- data/lib/xrb/fallback/template.rl +80 -0
- data/lib/xrb/markup.rb +56 -0
- data/lib/xrb/native.rb +15 -0
- data/lib/xrb/parsers.rb +16 -0
- data/lib/xrb/query.rb +80 -0
- data/lib/xrb/reference.rb +108 -0
- data/lib/xrb/strings.rb +47 -0
- data/lib/xrb/tag.rb +115 -0
- data/lib/xrb/template.rb +128 -0
- data/lib/xrb/uri.rb +100 -0
- data/lib/xrb/version.rb +8 -0
- data/lib/xrb.rb +11 -0
- data/license.md +23 -0
- data/readme.md +34 -0
- data.tar.gz.sig +0 -0
- metadata +118 -58
- metadata.gz.sig +2 -0
- data/README +0 -60
- data/app/helpers/ui_helper.rb +0 -80
- data/app/models/xrb/element.rb +0 -9
- data/lib/xrb/engine.rb +0 -4
- data/rails/init.rb +0 -1
- data/xrb.gemspec +0 -12
@@ -0,0 +1,548 @@
|
|
1
|
+
|
2
|
+
# line 1 "lib/xrb/fallback/query.rl"
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2016-2024, by Samuel Williams.
|
5
|
+
|
6
|
+
|
7
|
+
# line 57 "lib/xrb/fallback/query.rl"
|
8
|
+
|
9
|
+
|
10
|
+
require_relative '../error'
|
11
|
+
|
12
|
+
module XRB
|
13
|
+
module Fallback
|
14
|
+
|
15
|
+
# line 16 "lib/xrb/fallback/query.rb"
|
16
|
+
class << self
|
17
|
+
attr_accessor :_query_trans_keys
|
18
|
+
private :_query_trans_keys, :_query_trans_keys=
|
19
|
+
end
|
20
|
+
self._query_trans_keys = [
|
21
|
+
0, 0, 48, 102, 48, 102,
|
22
|
+
37, 93, 37, 93, 48,
|
23
|
+
102, 48, 102, 37, 93,
|
24
|
+
37, 93, 48, 102, 48, 102,
|
25
|
+
37, 93, 37, 93, 37,
|
26
|
+
93, 37, 93, 37, 93,
|
27
|
+
38, 91, 38, 61, 0
|
28
|
+
]
|
29
|
+
|
30
|
+
class << self
|
31
|
+
attr_accessor :_query_key_spans
|
32
|
+
private :_query_key_spans, :_query_key_spans=
|
33
|
+
end
|
34
|
+
self._query_key_spans = [
|
35
|
+
0, 55, 55, 57, 57, 55, 55, 57,
|
36
|
+
57, 55, 55, 57, 57, 57, 57, 57,
|
37
|
+
54, 24
|
38
|
+
]
|
39
|
+
|
40
|
+
class << self
|
41
|
+
attr_accessor :_query_index_offsets
|
42
|
+
private :_query_index_offsets, :_query_index_offsets=
|
43
|
+
end
|
44
|
+
self._query_index_offsets = [
|
45
|
+
0, 0, 56, 112, 170, 228, 284, 340,
|
46
|
+
398, 456, 512, 568, 626, 684, 742, 800,
|
47
|
+
858, 913
|
48
|
+
]
|
49
|
+
|
50
|
+
class << self
|
51
|
+
attr_accessor :_query_indicies
|
52
|
+
private :_query_indicies, :_query_indicies=
|
53
|
+
end
|
54
|
+
self._query_indicies = [
|
55
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
56
|
+
0, 0, 1, 1, 1, 1, 1, 1,
|
57
|
+
1, 0, 0, 0, 0, 0, 0, 1,
|
58
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
59
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
60
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
61
|
+
1, 0, 0, 0, 0, 0, 0, 1,
|
62
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
63
|
+
2, 2, 1, 1, 1, 1, 1, 1,
|
64
|
+
1, 2, 2, 2, 2, 2, 2, 1,
|
65
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
66
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
67
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
68
|
+
1, 2, 2, 2, 2, 2, 2, 1,
|
69
|
+
4, 1, 3, 3, 3, 3, 5, 3,
|
70
|
+
3, 3, 3, 6, 6, 6, 6, 6,
|
71
|
+
6, 6, 6, 6, 6, 3, 3, 3,
|
72
|
+
1, 3, 3, 3, 3, 3, 3, 3,
|
73
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
74
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
75
|
+
3, 3, 3, 3, 3, 3, 1, 3,
|
76
|
+
1, 3, 7, 1, 2, 2, 2, 2,
|
77
|
+
8, 2, 2, 2, 2, 9, 9, 9,
|
78
|
+
9, 9, 9, 9, 9, 9, 9, 2,
|
79
|
+
2, 2, 1, 2, 2, 2, 2, 2,
|
80
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
81
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
82
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
83
|
+
1, 2, 1, 2, 10, 10, 10, 10,
|
84
|
+
10, 10, 10, 10, 10, 10, 1, 1,
|
85
|
+
1, 1, 1, 1, 1, 10, 10, 10,
|
86
|
+
10, 10, 10, 1, 1, 1, 1, 1,
|
87
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
88
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
89
|
+
1, 1, 1, 1, 1, 10, 10, 10,
|
90
|
+
10, 10, 10, 1, 11, 11, 11, 11,
|
91
|
+
11, 11, 11, 11, 11, 11, 1, 1,
|
92
|
+
1, 1, 1, 1, 1, 11, 11, 11,
|
93
|
+
11, 11, 11, 1, 1, 1, 1, 1,
|
94
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
95
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
96
|
+
1, 1, 1, 1, 1, 11, 11, 11,
|
97
|
+
11, 11, 11, 1, 13, 1, 12, 12,
|
98
|
+
12, 12, 14, 12, 12, 12, 12, 15,
|
99
|
+
15, 15, 15, 15, 15, 15, 15, 15,
|
100
|
+
15, 12, 12, 12, 1, 12, 12, 12,
|
101
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
102
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
103
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
104
|
+
12, 12, 1, 12, 16, 12, 18, 1,
|
105
|
+
17, 17, 17, 17, 19, 17, 17, 17,
|
106
|
+
17, 17, 17, 17, 17, 17, 17, 17,
|
107
|
+
17, 17, 17, 17, 17, 17, 1, 17,
|
108
|
+
17, 17, 17, 17, 17, 17, 17, 17,
|
109
|
+
17, 17, 17, 17, 17, 17, 17, 17,
|
110
|
+
17, 17, 17, 17, 17, 17, 17, 17,
|
111
|
+
17, 17, 17, 17, 1, 17, 20, 17,
|
112
|
+
21, 21, 21, 21, 21, 21, 21, 21,
|
113
|
+
21, 21, 1, 1, 1, 1, 1, 1,
|
114
|
+
1, 21, 21, 21, 21, 21, 21, 1,
|
115
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
116
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
117
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
118
|
+
1, 21, 21, 21, 21, 21, 21, 1,
|
119
|
+
17, 17, 17, 17, 17, 17, 17, 17,
|
120
|
+
17, 17, 1, 1, 1, 1, 1, 1,
|
121
|
+
1, 17, 17, 17, 17, 17, 17, 1,
|
122
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
123
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
124
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
125
|
+
1, 17, 17, 17, 17, 17, 17, 1,
|
126
|
+
18, 1, 17, 17, 17, 17, 19, 17,
|
127
|
+
17, 17, 17, 22, 22, 22, 22, 22,
|
128
|
+
22, 22, 22, 22, 22, 17, 17, 17,
|
129
|
+
1, 17, 17, 17, 17, 17, 17, 17,
|
130
|
+
17, 17, 17, 17, 17, 17, 17, 17,
|
131
|
+
17, 17, 17, 17, 17, 17, 17, 17,
|
132
|
+
17, 17, 17, 17, 17, 17, 1, 17,
|
133
|
+
23, 17, 4, 1, 3, 3, 3, 3,
|
134
|
+
5, 3, 3, 3, 3, 6, 6, 6,
|
135
|
+
6, 6, 6, 6, 6, 6, 6, 3,
|
136
|
+
3, 3, 1, 3, 3, 3, 3, 3,
|
137
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
138
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
139
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
140
|
+
1, 3, 1, 3, 7, 24, 2, 2,
|
141
|
+
2, 2, 8, 2, 2, 2, 2, 2,
|
142
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
143
|
+
2, 2, 2, 2, 25, 2, 2, 2,
|
144
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
145
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
146
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
147
|
+
2, 2, 26, 2, 1, 2, 28, 29,
|
148
|
+
27, 27, 27, 27, 30, 27, 27, 27,
|
149
|
+
27, 27, 27, 27, 27, 27, 27, 27,
|
150
|
+
27, 27, 27, 27, 27, 27, 1, 27,
|
151
|
+
27, 27, 27, 27, 27, 27, 27, 27,
|
152
|
+
27, 27, 27, 27, 27, 27, 27, 27,
|
153
|
+
27, 27, 27, 27, 27, 27, 27, 27,
|
154
|
+
27, 27, 27, 27, 1, 27, 1, 27,
|
155
|
+
31, 32, 11, 11, 11, 11, 33, 11,
|
156
|
+
11, 11, 11, 11, 11, 11, 11, 11,
|
157
|
+
11, 11, 11, 11, 11, 11, 11, 11,
|
158
|
+
1, 11, 11, 11, 11, 11, 11, 11,
|
159
|
+
11, 11, 11, 11, 11, 11, 11, 11,
|
160
|
+
11, 11, 11, 11, 11, 11, 11, 11,
|
161
|
+
11, 11, 11, 11, 11, 11, 1, 11,
|
162
|
+
1, 11, 34, 1, 1, 1, 1, 1,
|
163
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
164
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
165
|
+
1, 35, 1, 1, 1, 1, 1, 1,
|
166
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
167
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
168
|
+
1, 1, 1, 1, 1, 1, 1, 36,
|
169
|
+
1, 37, 1, 1, 1, 1, 1, 1,
|
170
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
171
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
172
|
+
38, 1, 0
|
173
|
+
]
|
174
|
+
|
175
|
+
class << self
|
176
|
+
attr_accessor :_query_trans_targs
|
177
|
+
private :_query_trans_targs, :_query_trans_targs=
|
178
|
+
end
|
179
|
+
self._query_trans_targs = [
|
180
|
+
2, 0, 13, 13, 1, 13, 4, 1,
|
181
|
+
13, 4, 6, 15, 8, 9, 8, 11,
|
182
|
+
17, 8, 9, 8, 16, 10, 11, 16,
|
183
|
+
3, 14, 7, 15, 5, 3, 15, 5,
|
184
|
+
3, 15, 3, 14, 7, 3, 14
|
185
|
+
]
|
186
|
+
|
187
|
+
class << self
|
188
|
+
attr_accessor :_query_trans_actions
|
189
|
+
private :_query_trans_actions, :_query_trans_actions=
|
190
|
+
end
|
191
|
+
self._query_trans_actions = [
|
192
|
+
0, 0, 0, 1, 2, 2, 3, 4,
|
193
|
+
4, 0, 0, 0, 1, 2, 2, 5,
|
194
|
+
0, 0, 4, 4, 6, 0, 0, 7,
|
195
|
+
8, 6, 6, 10, 11, 9, 11, 4,
|
196
|
+
12, 4, 13, 0, 0, 14, 15
|
197
|
+
]
|
198
|
+
|
199
|
+
class << self
|
200
|
+
attr_accessor :_query_eof_actions
|
201
|
+
private :_query_eof_actions, :_query_eof_actions=
|
202
|
+
end
|
203
|
+
self._query_eof_actions = [
|
204
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
205
|
+
0, 0, 0, 0, 0, 8, 9, 12,
|
206
|
+
13, 14
|
207
|
+
]
|
208
|
+
|
209
|
+
class << self
|
210
|
+
attr_accessor :query_start
|
211
|
+
end
|
212
|
+
self.query_start = 12;
|
213
|
+
class << self
|
214
|
+
attr_accessor :query_first_final
|
215
|
+
end
|
216
|
+
self.query_first_final = 12;
|
217
|
+
class << self
|
218
|
+
attr_accessor :query_error
|
219
|
+
end
|
220
|
+
self.query_error = 0;
|
221
|
+
|
222
|
+
class << self
|
223
|
+
attr_accessor :query_en_main
|
224
|
+
end
|
225
|
+
self.query_en_main = 12;
|
226
|
+
|
227
|
+
|
228
|
+
# line 64 "lib/xrb/fallback/query.rl"
|
229
|
+
|
230
|
+
def self.parse_query(buffer, delegate)
|
231
|
+
data = buffer.read
|
232
|
+
bytes = data.bytes
|
233
|
+
|
234
|
+
p = 0
|
235
|
+
pe = eof = data.bytesize
|
236
|
+
stack = []
|
237
|
+
|
238
|
+
string_begin = string_end = nil
|
239
|
+
integer_begin = integer_end = nil
|
240
|
+
value_begin = value_end = nil
|
241
|
+
encoded = false
|
242
|
+
|
243
|
+
|
244
|
+
# line 245 "lib/xrb/fallback/query.rb"
|
245
|
+
begin
|
246
|
+
p ||= 0
|
247
|
+
pe ||= data.length
|
248
|
+
cs = query_start
|
249
|
+
end
|
250
|
+
|
251
|
+
# line 79 "lib/xrb/fallback/query.rl"
|
252
|
+
|
253
|
+
# line 254 "lib/xrb/fallback/query.rb"
|
254
|
+
begin
|
255
|
+
testEof = false
|
256
|
+
_slen, _trans, _keys, _inds, _acts, _nacts = nil
|
257
|
+
_goto_level = 0
|
258
|
+
_resume = 10
|
259
|
+
_eof_trans = 15
|
260
|
+
_again = 20
|
261
|
+
_test_eof = 30
|
262
|
+
_out = 40
|
263
|
+
while true
|
264
|
+
if _goto_level <= 0
|
265
|
+
if p == pe
|
266
|
+
_goto_level = _test_eof
|
267
|
+
next
|
268
|
+
end
|
269
|
+
if cs == 0
|
270
|
+
_goto_level = _out
|
271
|
+
next
|
272
|
+
end
|
273
|
+
end
|
274
|
+
if _goto_level <= _resume
|
275
|
+
_keys = cs << 1
|
276
|
+
_inds = _query_index_offsets[cs]
|
277
|
+
_slen = _query_key_spans[cs]
|
278
|
+
_wide = ( bytes[p])
|
279
|
+
_trans = if ( _slen > 0 &&
|
280
|
+
_query_trans_keys[_keys] <= _wide &&
|
281
|
+
_wide <= _query_trans_keys[_keys + 1]
|
282
|
+
) then
|
283
|
+
_query_indicies[ _inds + _wide - _query_trans_keys[_keys] ]
|
284
|
+
else
|
285
|
+
_query_indicies[ _inds + _slen ]
|
286
|
+
end
|
287
|
+
cs = _query_trans_targs[_trans]
|
288
|
+
if _query_trans_actions[_trans] != 0
|
289
|
+
case _query_trans_actions[_trans]
|
290
|
+
when 1 then
|
291
|
+
# line 7 "lib/xrb/fallback/query.rl"
|
292
|
+
begin
|
293
|
+
|
294
|
+
string_begin = p
|
295
|
+
end
|
296
|
+
when 6 then
|
297
|
+
# line 11 "lib/xrb/fallback/query.rl"
|
298
|
+
begin
|
299
|
+
|
300
|
+
string_end = p
|
301
|
+
|
302
|
+
delegate.string(data.byteslice(string_begin...string_end), encoded)
|
303
|
+
|
304
|
+
encoded = false
|
305
|
+
end
|
306
|
+
when 7 then
|
307
|
+
# line 23 "lib/xrb/fallback/query.rl"
|
308
|
+
begin
|
309
|
+
|
310
|
+
integer_end = p
|
311
|
+
|
312
|
+
delegate.integer(data.byteslice(integer_begin...integer_end))
|
313
|
+
end
|
314
|
+
when 15 then
|
315
|
+
# line 29 "lib/xrb/fallback/query.rl"
|
316
|
+
begin
|
317
|
+
|
318
|
+
delegate.append
|
319
|
+
end
|
320
|
+
when 10 then
|
321
|
+
# line 33 "lib/xrb/fallback/query.rl"
|
322
|
+
begin
|
323
|
+
|
324
|
+
value_begin = p
|
325
|
+
end
|
326
|
+
when 13 then
|
327
|
+
# line 45 "lib/xrb/fallback/query.rl"
|
328
|
+
begin
|
329
|
+
|
330
|
+
delegate.pair
|
331
|
+
end
|
332
|
+
when 4 then
|
333
|
+
# line 49 "lib/xrb/fallback/query.rl"
|
334
|
+
begin
|
335
|
+
|
336
|
+
encoded = 1;
|
337
|
+
end
|
338
|
+
when 3 then
|
339
|
+
# line 7 "lib/xrb/fallback/query.rl"
|
340
|
+
begin
|
341
|
+
|
342
|
+
string_begin = p
|
343
|
+
end
|
344
|
+
# line 19 "lib/xrb/fallback/query.rl"
|
345
|
+
begin
|
346
|
+
|
347
|
+
integer_begin = p
|
348
|
+
end
|
349
|
+
when 2 then
|
350
|
+
# line 7 "lib/xrb/fallback/query.rl"
|
351
|
+
begin
|
352
|
+
|
353
|
+
string_begin = p
|
354
|
+
end
|
355
|
+
# line 49 "lib/xrb/fallback/query.rl"
|
356
|
+
begin
|
357
|
+
|
358
|
+
encoded = 1;
|
359
|
+
end
|
360
|
+
when 8 then
|
361
|
+
# line 11 "lib/xrb/fallback/query.rl"
|
362
|
+
begin
|
363
|
+
|
364
|
+
string_end = p
|
365
|
+
|
366
|
+
delegate.string(data.byteslice(string_begin...string_end), encoded)
|
367
|
+
|
368
|
+
encoded = false
|
369
|
+
end
|
370
|
+
# line 45 "lib/xrb/fallback/query.rl"
|
371
|
+
begin
|
372
|
+
|
373
|
+
delegate.pair
|
374
|
+
end
|
375
|
+
when 5 then
|
376
|
+
# line 19 "lib/xrb/fallback/query.rl"
|
377
|
+
begin
|
378
|
+
|
379
|
+
integer_begin = p
|
380
|
+
end
|
381
|
+
# line 7 "lib/xrb/fallback/query.rl"
|
382
|
+
begin
|
383
|
+
|
384
|
+
string_begin = p
|
385
|
+
end
|
386
|
+
when 14 then
|
387
|
+
# line 29 "lib/xrb/fallback/query.rl"
|
388
|
+
begin
|
389
|
+
|
390
|
+
delegate.append
|
391
|
+
end
|
392
|
+
# line 45 "lib/xrb/fallback/query.rl"
|
393
|
+
begin
|
394
|
+
|
395
|
+
delegate.pair
|
396
|
+
end
|
397
|
+
when 11 then
|
398
|
+
# line 33 "lib/xrb/fallback/query.rl"
|
399
|
+
begin
|
400
|
+
|
401
|
+
value_begin = p
|
402
|
+
end
|
403
|
+
# line 49 "lib/xrb/fallback/query.rl"
|
404
|
+
begin
|
405
|
+
|
406
|
+
encoded = 1;
|
407
|
+
end
|
408
|
+
when 12 then
|
409
|
+
# line 37 "lib/xrb/fallback/query.rl"
|
410
|
+
begin
|
411
|
+
|
412
|
+
value_end = p
|
413
|
+
|
414
|
+
delegate.assign(data.byteslice(value_begin...value_end), encoded)
|
415
|
+
|
416
|
+
encoded = false
|
417
|
+
end
|
418
|
+
# line 45 "lib/xrb/fallback/query.rl"
|
419
|
+
begin
|
420
|
+
|
421
|
+
delegate.pair
|
422
|
+
end
|
423
|
+
when 9 then
|
424
|
+
# line 33 "lib/xrb/fallback/query.rl"
|
425
|
+
begin
|
426
|
+
|
427
|
+
value_begin = p
|
428
|
+
end
|
429
|
+
# line 37 "lib/xrb/fallback/query.rl"
|
430
|
+
begin
|
431
|
+
|
432
|
+
value_end = p
|
433
|
+
|
434
|
+
delegate.assign(data.byteslice(value_begin...value_end), encoded)
|
435
|
+
|
436
|
+
encoded = false
|
437
|
+
end
|
438
|
+
# line 45 "lib/xrb/fallback/query.rl"
|
439
|
+
begin
|
440
|
+
|
441
|
+
delegate.pair
|
442
|
+
end
|
443
|
+
# line 444 "lib/xrb/fallback/query.rb"
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
if _goto_level <= _again
|
448
|
+
if cs == 0
|
449
|
+
_goto_level = _out
|
450
|
+
next
|
451
|
+
end
|
452
|
+
p += 1
|
453
|
+
if p != pe
|
454
|
+
_goto_level = _resume
|
455
|
+
next
|
456
|
+
end
|
457
|
+
end
|
458
|
+
if _goto_level <= _test_eof
|
459
|
+
if p == eof
|
460
|
+
case _query_eof_actions[cs]
|
461
|
+
when 13 then
|
462
|
+
# line 45 "lib/xrb/fallback/query.rl"
|
463
|
+
begin
|
464
|
+
|
465
|
+
delegate.pair
|
466
|
+
end
|
467
|
+
when 8 then
|
468
|
+
# line 11 "lib/xrb/fallback/query.rl"
|
469
|
+
begin
|
470
|
+
|
471
|
+
string_end = p
|
472
|
+
|
473
|
+
delegate.string(data.byteslice(string_begin...string_end), encoded)
|
474
|
+
|
475
|
+
encoded = false
|
476
|
+
end
|
477
|
+
# line 45 "lib/xrb/fallback/query.rl"
|
478
|
+
begin
|
479
|
+
|
480
|
+
delegate.pair
|
481
|
+
end
|
482
|
+
when 14 then
|
483
|
+
# line 29 "lib/xrb/fallback/query.rl"
|
484
|
+
begin
|
485
|
+
|
486
|
+
delegate.append
|
487
|
+
end
|
488
|
+
# line 45 "lib/xrb/fallback/query.rl"
|
489
|
+
begin
|
490
|
+
|
491
|
+
delegate.pair
|
492
|
+
end
|
493
|
+
when 12 then
|
494
|
+
# line 37 "lib/xrb/fallback/query.rl"
|
495
|
+
begin
|
496
|
+
|
497
|
+
value_end = p
|
498
|
+
|
499
|
+
delegate.assign(data.byteslice(value_begin...value_end), encoded)
|
500
|
+
|
501
|
+
encoded = false
|
502
|
+
end
|
503
|
+
# line 45 "lib/xrb/fallback/query.rl"
|
504
|
+
begin
|
505
|
+
|
506
|
+
delegate.pair
|
507
|
+
end
|
508
|
+
when 9 then
|
509
|
+
# line 33 "lib/xrb/fallback/query.rl"
|
510
|
+
begin
|
511
|
+
|
512
|
+
value_begin = p
|
513
|
+
end
|
514
|
+
# line 37 "lib/xrb/fallback/query.rl"
|
515
|
+
begin
|
516
|
+
|
517
|
+
value_end = p
|
518
|
+
|
519
|
+
delegate.assign(data.byteslice(value_begin...value_end), encoded)
|
520
|
+
|
521
|
+
encoded = false
|
522
|
+
end
|
523
|
+
# line 45 "lib/xrb/fallback/query.rl"
|
524
|
+
begin
|
525
|
+
|
526
|
+
delegate.pair
|
527
|
+
end
|
528
|
+
# line 529 "lib/xrb/fallback/query.rb"
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
end
|
533
|
+
if _goto_level <= _out
|
534
|
+
break
|
535
|
+
end
|
536
|
+
end
|
537
|
+
end
|
538
|
+
|
539
|
+
# line 80 "lib/xrb/fallback/query.rl"
|
540
|
+
|
541
|
+
if p != eof
|
542
|
+
raise ParseError.new("could not consume all input", buffer, p)
|
543
|
+
end
|
544
|
+
|
545
|
+
return nil
|
546
|
+
end
|
547
|
+
end
|
548
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# Released under the MIT License.
|
2
|
+
# Copyright, 2016-2024, by Samuel Williams.
|
3
|
+
|
4
|
+
%%{
|
5
|
+
machine query;
|
6
|
+
|
7
|
+
action string_begin {
|
8
|
+
string_begin = p
|
9
|
+
}
|
10
|
+
|
11
|
+
action string_end {
|
12
|
+
string_end = p
|
13
|
+
|
14
|
+
delegate.string(data.byteslice(string_begin...string_end), encoded)
|
15
|
+
|
16
|
+
encoded = false
|
17
|
+
}
|
18
|
+
|
19
|
+
action integer_begin {
|
20
|
+
integer_begin = p
|
21
|
+
}
|
22
|
+
|
23
|
+
action integer_end {
|
24
|
+
integer_end = p
|
25
|
+
|
26
|
+
delegate.integer(data.byteslice(integer_begin...integer_end))
|
27
|
+
}
|
28
|
+
|
29
|
+
action append {
|
30
|
+
delegate.append
|
31
|
+
}
|
32
|
+
|
33
|
+
action value_begin {
|
34
|
+
value_begin = p
|
35
|
+
}
|
36
|
+
|
37
|
+
action value_end {
|
38
|
+
value_end = p
|
39
|
+
|
40
|
+
delegate.assign(data.byteslice(value_begin...value_end), encoded)
|
41
|
+
|
42
|
+
encoded = false
|
43
|
+
}
|
44
|
+
|
45
|
+
action pair {
|
46
|
+
delegate.pair
|
47
|
+
}
|
48
|
+
|
49
|
+
action encoded {
|
50
|
+
encoded = 1;
|
51
|
+
}
|
52
|
+
|
53
|
+
# This magic ensures that we process bytes.
|
54
|
+
getkey bytes[p];
|
55
|
+
|
56
|
+
include query "xrb/query.rl";
|
57
|
+
}%%
|
58
|
+
|
59
|
+
require_relative '../error'
|
60
|
+
|
61
|
+
module XRB
|
62
|
+
module Fallback
|
63
|
+
%% write data;
|
64
|
+
|
65
|
+
def self.parse_query(buffer, delegate)
|
66
|
+
data = buffer.read
|
67
|
+
bytes = data.bytes
|
68
|
+
|
69
|
+
p = 0
|
70
|
+
pe = eof = data.bytesize
|
71
|
+
stack = []
|
72
|
+
|
73
|
+
string_begin = string_end = nil
|
74
|
+
integer_begin = integer_end = nil
|
75
|
+
value_begin = value_end = nil
|
76
|
+
encoded = false
|
77
|
+
|
78
|
+
%% write init;
|
79
|
+
%% write exec;
|
80
|
+
|
81
|
+
if p != eof
|
82
|
+
raise ParseError.new("could not consume all input", buffer, p)
|
83
|
+
end
|
84
|
+
|
85
|
+
return nil
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|