search_syntax 0.1.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
- data/.ruby-version +1 -0
- data/.standard.yml +4 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +55 -0
- data/LICENSE.txt +21 -0
- data/README.md +103 -0
- data/Rakefile +14 -0
- data/lib/search_syntax/errors.rb +33 -0
- data/lib/search_syntax/parser.rb +9 -0
- data/lib/search_syntax/ransack.rb +23 -0
- data/lib/search_syntax/ransack_transformer.rb +81 -0
- data/lib/search_syntax/search_syntax_grammar.rb +781 -0
- data/lib/search_syntax/search_syntax_grammar.tt +70 -0
- data/lib/search_syntax/version.rb +5 -0
- data/lib/search_syntax.rb +9 -0
- data/search_syntax.gemspec +38 -0
- data/sig/search_syntax.rbs +4 -0
- metadata +64 -0
@@ -0,0 +1,781 @@
|
|
1
|
+
# Autogenerated from a Treetop grammar. Edits may be lost.
|
2
|
+
|
3
|
+
module SearchSyntaxGrammar
|
4
|
+
include Treetop::Runtime
|
5
|
+
|
6
|
+
def root
|
7
|
+
@root ||= :root
|
8
|
+
end
|
9
|
+
|
10
|
+
module Root0
|
11
|
+
def expressions
|
12
|
+
elements[1]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Root1
|
17
|
+
def value
|
18
|
+
elements[1].value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def _nt_root
|
23
|
+
start_index = index
|
24
|
+
if node_cache[:root].has_key?(index)
|
25
|
+
cached = node_cache[:root][index]
|
26
|
+
if cached
|
27
|
+
node_cache[:root][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
28
|
+
@index = cached.interval.end
|
29
|
+
end
|
30
|
+
return cached
|
31
|
+
end
|
32
|
+
|
33
|
+
i0, s0 = index, []
|
34
|
+
s1, i1 = [], index
|
35
|
+
loop do
|
36
|
+
r2 = _nt_space
|
37
|
+
if r2
|
38
|
+
s1 << r2
|
39
|
+
else
|
40
|
+
break
|
41
|
+
end
|
42
|
+
end
|
43
|
+
r1 = instantiate_node(SyntaxNode, input, i1...index, s1)
|
44
|
+
s0 << r1
|
45
|
+
if r1
|
46
|
+
r3 = _nt_expressions
|
47
|
+
s0 << r3
|
48
|
+
if r3
|
49
|
+
s4, i4 = [], index
|
50
|
+
loop do
|
51
|
+
r5 = _nt_space
|
52
|
+
if r5
|
53
|
+
s4 << r5
|
54
|
+
else
|
55
|
+
break
|
56
|
+
end
|
57
|
+
end
|
58
|
+
r4 = instantiate_node(SyntaxNode, input, i4...index, s4)
|
59
|
+
s0 << r4
|
60
|
+
end
|
61
|
+
end
|
62
|
+
if s0.last
|
63
|
+
r0 = instantiate_node(SyntaxNode, input, i0...index, s0)
|
64
|
+
r0.extend(Root0)
|
65
|
+
r0.extend(Root1)
|
66
|
+
else
|
67
|
+
@index = i0
|
68
|
+
r0 = nil
|
69
|
+
end
|
70
|
+
|
71
|
+
node_cache[:root][start_index] = r0
|
72
|
+
|
73
|
+
r0
|
74
|
+
end
|
75
|
+
|
76
|
+
module Expressions0
|
77
|
+
end
|
78
|
+
|
79
|
+
module Expressions1
|
80
|
+
def value
|
81
|
+
elements.map { |e|
|
82
|
+
e.elements[0].value.merge({
|
83
|
+
raw: e.elements[0].text_value,
|
84
|
+
start: e.elements[0].interval.begin,
|
85
|
+
finish: e.elements[0].interval.end
|
86
|
+
})
|
87
|
+
}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def _nt_expressions
|
92
|
+
start_index = index
|
93
|
+
if node_cache[:expressions].has_key?(index)
|
94
|
+
cached = node_cache[:expressions][index]
|
95
|
+
if cached
|
96
|
+
node_cache[:expressions][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
97
|
+
@index = cached.interval.end
|
98
|
+
end
|
99
|
+
return cached
|
100
|
+
end
|
101
|
+
|
102
|
+
s0, i0 = [], index
|
103
|
+
loop do
|
104
|
+
i1, s1 = index, []
|
105
|
+
i2 = index
|
106
|
+
r3 = _nt_quoted_value
|
107
|
+
if r3
|
108
|
+
r3 = SyntaxNode.new(input, (index - 1)...index) if r3 == true
|
109
|
+
r2 = r3
|
110
|
+
else
|
111
|
+
r4 = _nt_param
|
112
|
+
if r4
|
113
|
+
r4 = SyntaxNode.new(input, (index - 1)...index) if r4 == true
|
114
|
+
r2 = r4
|
115
|
+
else
|
116
|
+
r5 = _nt_bare_value
|
117
|
+
if r5
|
118
|
+
r5 = SyntaxNode.new(input, (index - 1)...index) if r5 == true
|
119
|
+
r2 = r5
|
120
|
+
else
|
121
|
+
@index = i2
|
122
|
+
r2 = nil
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
s1 << r2
|
127
|
+
if r2
|
128
|
+
r7 = _nt_space
|
129
|
+
r6 = r7 || instantiate_node(SyntaxNode, input, index...index)
|
130
|
+
s1 << r6
|
131
|
+
end
|
132
|
+
if s1.last
|
133
|
+
r1 = instantiate_node(SyntaxNode, input, i1...index, s1)
|
134
|
+
r1.extend(Expressions0)
|
135
|
+
else
|
136
|
+
@index = i1
|
137
|
+
r1 = nil
|
138
|
+
end
|
139
|
+
if r1
|
140
|
+
s0 << r1
|
141
|
+
else
|
142
|
+
break
|
143
|
+
end
|
144
|
+
end
|
145
|
+
r0 = instantiate_node(SyntaxNode, input, i0...index, s0)
|
146
|
+
r0.extend(Expressions1)
|
147
|
+
r0.extend(Expressions1)
|
148
|
+
|
149
|
+
node_cache[:expressions][start_index] = r0
|
150
|
+
|
151
|
+
r0
|
152
|
+
end
|
153
|
+
|
154
|
+
def _nt_space
|
155
|
+
start_index = index
|
156
|
+
if node_cache[:space].has_key?(index)
|
157
|
+
cached = node_cache[:space][index]
|
158
|
+
if cached
|
159
|
+
node_cache[:space][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
160
|
+
@index = cached.interval.end
|
161
|
+
end
|
162
|
+
return cached
|
163
|
+
end
|
164
|
+
|
165
|
+
s0, i0 = [], index
|
166
|
+
loop do
|
167
|
+
if has_terminal?(@regexps[gr = '\A[ \\t]'] ||= Regexp.new(gr), :regexp, index)
|
168
|
+
r1 = true
|
169
|
+
@index += 1
|
170
|
+
else
|
171
|
+
terminal_parse_failure('[ \\t]')
|
172
|
+
r1 = nil
|
173
|
+
end
|
174
|
+
if r1
|
175
|
+
s0 << r1
|
176
|
+
else
|
177
|
+
break
|
178
|
+
end
|
179
|
+
end
|
180
|
+
if s0.empty?
|
181
|
+
@index = i0
|
182
|
+
r0 = nil
|
183
|
+
else
|
184
|
+
r0 = instantiate_node(SyntaxNode, input, i0...index, s0)
|
185
|
+
end
|
186
|
+
|
187
|
+
node_cache[:space][start_index] = r0
|
188
|
+
|
189
|
+
r0
|
190
|
+
end
|
191
|
+
|
192
|
+
module QuotedValue0
|
193
|
+
end
|
194
|
+
|
195
|
+
module QuotedValue1
|
196
|
+
end
|
197
|
+
|
198
|
+
module QuotedValue2
|
199
|
+
end
|
200
|
+
|
201
|
+
module QuotedValue3
|
202
|
+
end
|
203
|
+
|
204
|
+
module QuotedValue4
|
205
|
+
def value
|
206
|
+
quote = elements[0].text_value
|
207
|
+
{
|
208
|
+
type: :quoted,
|
209
|
+
value: elements[1].text_value.gsub("\\#{quote}", quote)
|
210
|
+
}
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def _nt_quoted_value
|
215
|
+
start_index = index
|
216
|
+
if node_cache[:quoted_value].has_key?(index)
|
217
|
+
cached = node_cache[:quoted_value][index]
|
218
|
+
if cached
|
219
|
+
node_cache[:quoted_value][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
220
|
+
@index = cached.interval.end
|
221
|
+
end
|
222
|
+
return cached
|
223
|
+
end
|
224
|
+
|
225
|
+
i0 = index
|
226
|
+
i1, s1 = index, []
|
227
|
+
if (match_len = has_terminal?('"', false, index))
|
228
|
+
r2 = true
|
229
|
+
@index += match_len
|
230
|
+
else
|
231
|
+
terminal_parse_failure('\'"\'')
|
232
|
+
r2 = nil
|
233
|
+
end
|
234
|
+
s1 << r2
|
235
|
+
if r2
|
236
|
+
s3, i3 = [], index
|
237
|
+
loop do
|
238
|
+
i4 = index
|
239
|
+
if (match_len = has_terminal?('\"', false, index))
|
240
|
+
r5 = instantiate_node(SyntaxNode, input, index...(index + match_len))
|
241
|
+
@index += match_len
|
242
|
+
else
|
243
|
+
terminal_parse_failure('\'\\"\'')
|
244
|
+
r5 = nil
|
245
|
+
end
|
246
|
+
if r5
|
247
|
+
r5 = SyntaxNode.new(input, (index - 1)...index) if r5 == true
|
248
|
+
r4 = r5
|
249
|
+
else
|
250
|
+
i6, s6 = index, []
|
251
|
+
i7 = index
|
252
|
+
if (match_len = has_terminal?('"', false, index))
|
253
|
+
r8 = true
|
254
|
+
@index += match_len
|
255
|
+
else
|
256
|
+
terminal_parse_failure('\'"\'')
|
257
|
+
r8 = nil
|
258
|
+
end
|
259
|
+
if r8
|
260
|
+
@index = i7
|
261
|
+
r7 = nil
|
262
|
+
terminal_parse_failure('\'"\'', true)
|
263
|
+
else
|
264
|
+
@terminal_failures.pop
|
265
|
+
@index = i7
|
266
|
+
r7 = instantiate_node(SyntaxNode, input, index...index)
|
267
|
+
end
|
268
|
+
s6 << r7
|
269
|
+
if r7
|
270
|
+
if index < input_length
|
271
|
+
r9 = true
|
272
|
+
@index += 1
|
273
|
+
else
|
274
|
+
terminal_parse_failure("any character")
|
275
|
+
r9 = nil
|
276
|
+
end
|
277
|
+
s6 << r9
|
278
|
+
end
|
279
|
+
if s6.last
|
280
|
+
r6 = instantiate_node(SyntaxNode, input, i6...index, s6)
|
281
|
+
r6.extend(QuotedValue0)
|
282
|
+
else
|
283
|
+
@index = i6
|
284
|
+
r6 = nil
|
285
|
+
end
|
286
|
+
if r6
|
287
|
+
r6 = SyntaxNode.new(input, (index - 1)...index) if r6 == true
|
288
|
+
r4 = r6
|
289
|
+
else
|
290
|
+
@index = i4
|
291
|
+
r4 = nil
|
292
|
+
end
|
293
|
+
end
|
294
|
+
if r4
|
295
|
+
s3 << r4
|
296
|
+
else
|
297
|
+
break
|
298
|
+
end
|
299
|
+
end
|
300
|
+
r3 = instantiate_node(SyntaxNode, input, i3...index, s3)
|
301
|
+
s1 << r3
|
302
|
+
if r3
|
303
|
+
if (match_len = has_terminal?('"', false, index))
|
304
|
+
r10 = true
|
305
|
+
@index += match_len
|
306
|
+
else
|
307
|
+
terminal_parse_failure('\'"\'')
|
308
|
+
r10 = nil
|
309
|
+
end
|
310
|
+
s1 << r10
|
311
|
+
end
|
312
|
+
end
|
313
|
+
if s1.last
|
314
|
+
r1 = instantiate_node(SyntaxNode, input, i1...index, s1)
|
315
|
+
r1.extend(QuotedValue1)
|
316
|
+
else
|
317
|
+
@index = i1
|
318
|
+
r1 = nil
|
319
|
+
end
|
320
|
+
if r1
|
321
|
+
r1 = SyntaxNode.new(input, (index - 1)...index) if r1 == true
|
322
|
+
r0 = r1
|
323
|
+
r0.extend(QuotedValue4)
|
324
|
+
r0.extend(QuotedValue4)
|
325
|
+
else
|
326
|
+
i11, s11 = index, []
|
327
|
+
if (match_len = has_terminal?("'", false, index))
|
328
|
+
r12 = true
|
329
|
+
@index += match_len
|
330
|
+
else
|
331
|
+
terminal_parse_failure("'\\''")
|
332
|
+
r12 = nil
|
333
|
+
end
|
334
|
+
s11 << r12
|
335
|
+
if r12
|
336
|
+
s13, i13 = [], index
|
337
|
+
loop do
|
338
|
+
i14 = index
|
339
|
+
if (match_len = has_terminal?("\\'", false, index))
|
340
|
+
r15 = instantiate_node(SyntaxNode, input, index...(index + match_len))
|
341
|
+
@index += match_len
|
342
|
+
else
|
343
|
+
terminal_parse_failure("'\\\\\\''")
|
344
|
+
r15 = nil
|
345
|
+
end
|
346
|
+
if r15
|
347
|
+
r15 = SyntaxNode.new(input, (index - 1)...index) if r15 == true
|
348
|
+
r14 = r15
|
349
|
+
else
|
350
|
+
i16, s16 = index, []
|
351
|
+
i17 = index
|
352
|
+
if (match_len = has_terminal?("'", false, index))
|
353
|
+
r18 = true
|
354
|
+
@index += match_len
|
355
|
+
else
|
356
|
+
terminal_parse_failure("'\\''")
|
357
|
+
r18 = nil
|
358
|
+
end
|
359
|
+
if r18
|
360
|
+
@index = i17
|
361
|
+
r17 = nil
|
362
|
+
terminal_parse_failure("'\\''", true)
|
363
|
+
else
|
364
|
+
@terminal_failures.pop
|
365
|
+
@index = i17
|
366
|
+
r17 = instantiate_node(SyntaxNode, input, index...index)
|
367
|
+
end
|
368
|
+
s16 << r17
|
369
|
+
if r17
|
370
|
+
if index < input_length
|
371
|
+
r19 = true
|
372
|
+
@index += 1
|
373
|
+
else
|
374
|
+
terminal_parse_failure("any character")
|
375
|
+
r19 = nil
|
376
|
+
end
|
377
|
+
s16 << r19
|
378
|
+
end
|
379
|
+
if s16.last
|
380
|
+
r16 = instantiate_node(SyntaxNode, input, i16...index, s16)
|
381
|
+
r16.extend(QuotedValue2)
|
382
|
+
else
|
383
|
+
@index = i16
|
384
|
+
r16 = nil
|
385
|
+
end
|
386
|
+
if r16
|
387
|
+
r16 = SyntaxNode.new(input, (index - 1)...index) if r16 == true
|
388
|
+
r14 = r16
|
389
|
+
else
|
390
|
+
@index = i14
|
391
|
+
r14 = nil
|
392
|
+
end
|
393
|
+
end
|
394
|
+
if r14
|
395
|
+
s13 << r14
|
396
|
+
else
|
397
|
+
break
|
398
|
+
end
|
399
|
+
end
|
400
|
+
r13 = instantiate_node(SyntaxNode, input, i13...index, s13)
|
401
|
+
s11 << r13
|
402
|
+
if r13
|
403
|
+
if (match_len = has_terminal?("'", false, index))
|
404
|
+
r20 = true
|
405
|
+
@index += match_len
|
406
|
+
else
|
407
|
+
terminal_parse_failure("'\\''")
|
408
|
+
r20 = nil
|
409
|
+
end
|
410
|
+
s11 << r20
|
411
|
+
end
|
412
|
+
end
|
413
|
+
if s11.last
|
414
|
+
r11 = instantiate_node(SyntaxNode, input, i11...index, s11)
|
415
|
+
r11.extend(QuotedValue3)
|
416
|
+
else
|
417
|
+
@index = i11
|
418
|
+
r11 = nil
|
419
|
+
end
|
420
|
+
if r11
|
421
|
+
r11 = SyntaxNode.new(input, (index - 1)...index) if r11 == true
|
422
|
+
r0 = r11
|
423
|
+
r0.extend(QuotedValue4)
|
424
|
+
r0.extend(QuotedValue4)
|
425
|
+
else
|
426
|
+
@index = i0
|
427
|
+
r0 = nil
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
node_cache[:quoted_value][start_index] = r0
|
432
|
+
|
433
|
+
r0
|
434
|
+
end
|
435
|
+
|
436
|
+
module BareValue0
|
437
|
+
end
|
438
|
+
|
439
|
+
module BareValue1
|
440
|
+
end
|
441
|
+
|
442
|
+
module BareValue2
|
443
|
+
def value
|
444
|
+
{
|
445
|
+
type: :bare,
|
446
|
+
value: elements[0].text_value
|
447
|
+
}
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
451
|
+
def _nt_bare_value
|
452
|
+
start_index = index
|
453
|
+
if node_cache[:bare_value].has_key?(index)
|
454
|
+
cached = node_cache[:bare_value][index]
|
455
|
+
if cached
|
456
|
+
node_cache[:bare_value][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
457
|
+
@index = cached.interval.end
|
458
|
+
end
|
459
|
+
return cached
|
460
|
+
end
|
461
|
+
|
462
|
+
i0, s0 = index, []
|
463
|
+
s1, i1 = [], index
|
464
|
+
loop do
|
465
|
+
i2, s2 = index, []
|
466
|
+
i3 = index
|
467
|
+
r4 = _nt_space
|
468
|
+
@index = i3
|
469
|
+
r3 = if r4
|
470
|
+
nil
|
471
|
+
else
|
472
|
+
instantiate_node(SyntaxNode, input, index...index)
|
473
|
+
end
|
474
|
+
s2 << r3
|
475
|
+
if r3
|
476
|
+
if index < input_length
|
477
|
+
r5 = true
|
478
|
+
@index += 1
|
479
|
+
else
|
480
|
+
terminal_parse_failure("any character")
|
481
|
+
r5 = nil
|
482
|
+
end
|
483
|
+
s2 << r5
|
484
|
+
end
|
485
|
+
if s2.last
|
486
|
+
r2 = instantiate_node(SyntaxNode, input, i2...index, s2)
|
487
|
+
r2.extend(BareValue0)
|
488
|
+
else
|
489
|
+
@index = i2
|
490
|
+
r2 = nil
|
491
|
+
end
|
492
|
+
if r2
|
493
|
+
s1 << r2
|
494
|
+
else
|
495
|
+
break
|
496
|
+
end
|
497
|
+
end
|
498
|
+
if s1.empty?
|
499
|
+
@index = i1
|
500
|
+
r1 = nil
|
501
|
+
else
|
502
|
+
r1 = instantiate_node(SyntaxNode, input, i1...index, s1)
|
503
|
+
end
|
504
|
+
s0 << r1
|
505
|
+
if r1
|
506
|
+
if (match_len = has_terminal?("", false, index))
|
507
|
+
r6 = true
|
508
|
+
@index += match_len
|
509
|
+
else
|
510
|
+
terminal_parse_failure("''")
|
511
|
+
r6 = nil
|
512
|
+
end
|
513
|
+
s0 << r6
|
514
|
+
end
|
515
|
+
if s0.last
|
516
|
+
r0 = instantiate_node(SyntaxNode, input, i0...index, s0)
|
517
|
+
r0.extend(BareValue1)
|
518
|
+
r0.extend(BareValue2)
|
519
|
+
else
|
520
|
+
@index = i0
|
521
|
+
r0 = nil
|
522
|
+
end
|
523
|
+
|
524
|
+
node_cache[:bare_value][start_index] = r0
|
525
|
+
|
526
|
+
r0
|
527
|
+
end
|
528
|
+
|
529
|
+
def _nt_predicate
|
530
|
+
start_index = index
|
531
|
+
if node_cache[:predicate].has_key?(index)
|
532
|
+
cached = node_cache[:predicate][index]
|
533
|
+
if cached
|
534
|
+
node_cache[:predicate][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
535
|
+
@index = cached.interval.end
|
536
|
+
end
|
537
|
+
return cached
|
538
|
+
end
|
539
|
+
|
540
|
+
i0 = index
|
541
|
+
if (match_len = has_terminal?(">=", false, index))
|
542
|
+
r1 = instantiate_node(SyntaxNode, input, index...(index + match_len))
|
543
|
+
@index += match_len
|
544
|
+
else
|
545
|
+
terminal_parse_failure('">="')
|
546
|
+
r1 = nil
|
547
|
+
end
|
548
|
+
if r1
|
549
|
+
r1 = SyntaxNode.new(input, (index - 1)...index) if r1 == true
|
550
|
+
r0 = r1
|
551
|
+
else
|
552
|
+
if (match_len = has_terminal?("<=", false, index))
|
553
|
+
r2 = instantiate_node(SyntaxNode, input, index...(index + match_len))
|
554
|
+
@index += match_len
|
555
|
+
else
|
556
|
+
terminal_parse_failure('"<="')
|
557
|
+
r2 = nil
|
558
|
+
end
|
559
|
+
if r2
|
560
|
+
r2 = SyntaxNode.new(input, (index - 1)...index) if r2 == true
|
561
|
+
r0 = r2
|
562
|
+
else
|
563
|
+
if (match_len = has_terminal?("=>", false, index))
|
564
|
+
r3 = instantiate_node(SyntaxNode, input, index...(index + match_len))
|
565
|
+
@index += match_len
|
566
|
+
else
|
567
|
+
terminal_parse_failure('"=>"')
|
568
|
+
r3 = nil
|
569
|
+
end
|
570
|
+
if r3
|
571
|
+
r3 = SyntaxNode.new(input, (index - 1)...index) if r3 == true
|
572
|
+
r0 = r3
|
573
|
+
else
|
574
|
+
if (match_len = has_terminal?("=<", false, index))
|
575
|
+
r4 = instantiate_node(SyntaxNode, input, index...(index + match_len))
|
576
|
+
@index += match_len
|
577
|
+
else
|
578
|
+
terminal_parse_failure('"=<"')
|
579
|
+
r4 = nil
|
580
|
+
end
|
581
|
+
if r4
|
582
|
+
r4 = SyntaxNode.new(input, (index - 1)...index) if r4 == true
|
583
|
+
r0 = r4
|
584
|
+
else
|
585
|
+
if (match_len = has_terminal?("!=", false, index))
|
586
|
+
r5 = instantiate_node(SyntaxNode, input, index...(index + match_len))
|
587
|
+
@index += match_len
|
588
|
+
else
|
589
|
+
terminal_parse_failure('"!="')
|
590
|
+
r5 = nil
|
591
|
+
end
|
592
|
+
if r5
|
593
|
+
r5 = SyntaxNode.new(input, (index - 1)...index) if r5 == true
|
594
|
+
r0 = r5
|
595
|
+
else
|
596
|
+
if (match_len = has_terminal?(">", false, index))
|
597
|
+
r6 = true
|
598
|
+
@index += match_len
|
599
|
+
else
|
600
|
+
terminal_parse_failure('">"')
|
601
|
+
r6 = nil
|
602
|
+
end
|
603
|
+
if r6
|
604
|
+
r6 = SyntaxNode.new(input, (index - 1)...index) if r6 == true
|
605
|
+
r0 = r6
|
606
|
+
else
|
607
|
+
if (match_len = has_terminal?("<", false, index))
|
608
|
+
r7 = true
|
609
|
+
@index += match_len
|
610
|
+
else
|
611
|
+
terminal_parse_failure('"<"')
|
612
|
+
r7 = nil
|
613
|
+
end
|
614
|
+
if r7
|
615
|
+
r7 = SyntaxNode.new(input, (index - 1)...index) if r7 == true
|
616
|
+
r0 = r7
|
617
|
+
else
|
618
|
+
@index = i0
|
619
|
+
r0 = nil
|
620
|
+
end
|
621
|
+
end
|
622
|
+
end
|
623
|
+
end
|
624
|
+
end
|
625
|
+
end
|
626
|
+
end
|
627
|
+
|
628
|
+
node_cache[:predicate][start_index] = r0
|
629
|
+
|
630
|
+
r0
|
631
|
+
end
|
632
|
+
|
633
|
+
module Param0
|
634
|
+
end
|
635
|
+
|
636
|
+
module Param1
|
637
|
+
end
|
638
|
+
|
639
|
+
module Param2
|
640
|
+
def value
|
641
|
+
result = {
|
642
|
+
type: :param,
|
643
|
+
name: elements[0].text_value,
|
644
|
+
value: elements[3].value[:value]
|
645
|
+
}
|
646
|
+
predicate = elements[2].text_value
|
647
|
+
if predicate != ""
|
648
|
+
result[:predicate] = predicate.to_sym
|
649
|
+
end
|
650
|
+
result
|
651
|
+
end
|
652
|
+
end
|
653
|
+
|
654
|
+
def _nt_param
|
655
|
+
start_index = index
|
656
|
+
if node_cache[:param].has_key?(index)
|
657
|
+
cached = node_cache[:param][index]
|
658
|
+
if cached
|
659
|
+
node_cache[:param][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
660
|
+
@index = cached.interval.end
|
661
|
+
end
|
662
|
+
return cached
|
663
|
+
end
|
664
|
+
|
665
|
+
i0, s0 = index, []
|
666
|
+
s1, i1 = [], index
|
667
|
+
loop do
|
668
|
+
i2, s2 = index, []
|
669
|
+
i3 = index
|
670
|
+
i4 = index
|
671
|
+
r5 = _nt_space
|
672
|
+
if r5
|
673
|
+
r5 = SyntaxNode.new(input, (index - 1)...index) if r5 == true
|
674
|
+
r4 = r5
|
675
|
+
else
|
676
|
+
if (match_len = has_terminal?(":", false, index))
|
677
|
+
r6 = true
|
678
|
+
@index += match_len
|
679
|
+
else
|
680
|
+
terminal_parse_failure('":"')
|
681
|
+
r6 = nil
|
682
|
+
end
|
683
|
+
if r6
|
684
|
+
r6 = SyntaxNode.new(input, (index - 1)...index) if r6 == true
|
685
|
+
r4 = r6
|
686
|
+
else
|
687
|
+
@index = i4
|
688
|
+
r4 = nil
|
689
|
+
end
|
690
|
+
end
|
691
|
+
if r4
|
692
|
+
@index = i3
|
693
|
+
r3 = nil
|
694
|
+
terminal_parse_failure("(any alternative)", true)
|
695
|
+
else
|
696
|
+
@terminal_failures.pop
|
697
|
+
@index = i3
|
698
|
+
r3 = instantiate_node(SyntaxNode, input, index...index)
|
699
|
+
end
|
700
|
+
s2 << r3
|
701
|
+
if r3
|
702
|
+
if index < input_length
|
703
|
+
r7 = true
|
704
|
+
@index += 1
|
705
|
+
else
|
706
|
+
terminal_parse_failure("any character")
|
707
|
+
r7 = nil
|
708
|
+
end
|
709
|
+
s2 << r7
|
710
|
+
end
|
711
|
+
if s2.last
|
712
|
+
r2 = instantiate_node(SyntaxNode, input, i2...index, s2)
|
713
|
+
r2.extend(Param0)
|
714
|
+
else
|
715
|
+
@index = i2
|
716
|
+
r2 = nil
|
717
|
+
end
|
718
|
+
if r2
|
719
|
+
s1 << r2
|
720
|
+
else
|
721
|
+
break
|
722
|
+
end
|
723
|
+
end
|
724
|
+
if s1.empty?
|
725
|
+
@index = i1
|
726
|
+
r1 = nil
|
727
|
+
else
|
728
|
+
r1 = instantiate_node(SyntaxNode, input, i1...index, s1)
|
729
|
+
end
|
730
|
+
s0 << r1
|
731
|
+
if r1
|
732
|
+
if (match_len = has_terminal?(":", false, index))
|
733
|
+
r8 = true
|
734
|
+
@index += match_len
|
735
|
+
else
|
736
|
+
terminal_parse_failure('":"')
|
737
|
+
r8 = nil
|
738
|
+
end
|
739
|
+
s0 << r8
|
740
|
+
if r8
|
741
|
+
r10 = _nt_predicate
|
742
|
+
r9 = r10 || instantiate_node(SyntaxNode, input, index...index)
|
743
|
+
s0 << r9
|
744
|
+
if r9
|
745
|
+
i11 = index
|
746
|
+
r12 = _nt_quoted_value
|
747
|
+
if r12
|
748
|
+
r12 = SyntaxNode.new(input, (index - 1)...index) if r12 == true
|
749
|
+
r11 = r12
|
750
|
+
else
|
751
|
+
r13 = _nt_bare_value
|
752
|
+
if r13
|
753
|
+
r13 = SyntaxNode.new(input, (index - 1)...index) if r13 == true
|
754
|
+
r11 = r13
|
755
|
+
else
|
756
|
+
@index = i11
|
757
|
+
r11 = nil
|
758
|
+
end
|
759
|
+
end
|
760
|
+
s0 << r11
|
761
|
+
end
|
762
|
+
end
|
763
|
+
end
|
764
|
+
if s0.last
|
765
|
+
r0 = instantiate_node(SyntaxNode, input, i0...index, s0)
|
766
|
+
r0.extend(Param1)
|
767
|
+
r0.extend(Param2)
|
768
|
+
else
|
769
|
+
@index = i0
|
770
|
+
r0 = nil
|
771
|
+
end
|
772
|
+
|
773
|
+
node_cache[:param][start_index] = r0
|
774
|
+
|
775
|
+
r0
|
776
|
+
end
|
777
|
+
end
|
778
|
+
|
779
|
+
class SearchSyntaxGrammarParser < Treetop::Runtime::CompiledParser
|
780
|
+
include SearchSyntaxGrammar
|
781
|
+
end
|