iregexp 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/iregexp +1 -1
- data/iregexp.gemspec +1 -1
- data/lib/iregexp.rb +1 -1
- data/lib/parser/iregexpgrammar.rb +233 -152
- data/test-data/simple.out +12 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5202a3cb240a8a7849884fb8687bde6f35ff10fe4922557a10755c7f056934d3
|
4
|
+
data.tar.gz: e3b28251af5dadeecbf3f38ab8f331bdfebb2fe7dd6ee9c8be4ff53188a16c6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e605b8e6d21851018b876857581ebf45ec8e1f4c46b886bf30eb69ea82f15afeb861df545f172f4f154d4d1a5dd4d0f27a73c2f3548c67f85f2cf92cde3363d7
|
7
|
+
data.tar.gz: 47b142bfe32057951c99e5f9ee1b311c2dbf88e1e05ee43607754e25e6a8684dd191dc22c41ed7b0e28f004a7ecaef70a70c1ea1481314d99aa5087ba7c8a462
|
data/bin/iregexp
CHANGED
@@ -15,7 +15,7 @@ FUNCSIG_CHARS = {"l" => :logical, "n" => :nodes, "v" => :value}
|
|
15
15
|
$options = OpenStruct.new
|
16
16
|
begin
|
17
17
|
op = OptionParser.new do |opts|
|
18
|
-
opts.banner = "Usage:
|
18
|
+
opts.banner = "Usage: iregexp [options] file | -e expr"
|
19
19
|
|
20
20
|
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
21
21
|
$options.verbose = v
|
data/iregexp.gemspec
CHANGED
data/lib/iregexp.rb
CHANGED
@@ -196,19 +196,6 @@ module IREGEXPGRAMMAR
|
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
199
|
-
module Quantifier1
|
200
|
-
def quantity
|
201
|
-
elements[1]
|
202
|
-
end
|
203
|
-
|
204
|
-
end
|
205
|
-
|
206
|
-
module Quantifier2
|
207
|
-
def ast
|
208
|
-
quantity.ast
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
199
|
def _nt_quantifier
|
213
200
|
start_index = index
|
214
201
|
if node_cache[:quantifier].has_key?(index)
|
@@ -222,11 +209,11 @@ module IREGEXPGRAMMAR
|
|
222
209
|
|
223
210
|
i0 = index
|
224
211
|
i1 = index
|
225
|
-
if
|
212
|
+
if (match_len = has_terminal?("*", false, index))
|
226
213
|
r2 = true
|
227
|
-
@index +=
|
214
|
+
@index += match_len
|
228
215
|
else
|
229
|
-
terminal_parse_failure('
|
216
|
+
terminal_parse_failure('"*"')
|
230
217
|
r2 = nil
|
231
218
|
end
|
232
219
|
if r2
|
@@ -235,11 +222,11 @@ module IREGEXPGRAMMAR
|
|
235
222
|
r1.extend(Quantifier0)
|
236
223
|
r1.extend(Quantifier0)
|
237
224
|
else
|
238
|
-
if (match_len = has_terminal?("
|
225
|
+
if (match_len = has_terminal?("+", false, index))
|
239
226
|
r3 = true
|
240
227
|
@index += match_len
|
241
228
|
else
|
242
|
-
terminal_parse_failure('"
|
229
|
+
terminal_parse_failure('"+"')
|
243
230
|
r3 = nil
|
244
231
|
end
|
245
232
|
if r3
|
@@ -248,48 +235,32 @@ module IREGEXPGRAMMAR
|
|
248
235
|
r1.extend(Quantifier0)
|
249
236
|
r1.extend(Quantifier0)
|
250
237
|
else
|
251
|
-
|
252
|
-
|
238
|
+
if (match_len = has_terminal?("?", false, index))
|
239
|
+
r4 = true
|
240
|
+
@index += match_len
|
241
|
+
else
|
242
|
+
terminal_parse_failure('"?"')
|
243
|
+
r4 = nil
|
244
|
+
end
|
245
|
+
if r4
|
246
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
247
|
+
r1 = r4
|
248
|
+
r1.extend(Quantifier0)
|
249
|
+
r1.extend(Quantifier0)
|
250
|
+
else
|
251
|
+
@index = i1
|
252
|
+
r1 = nil
|
253
|
+
end
|
253
254
|
end
|
254
255
|
end
|
255
256
|
if r1
|
256
257
|
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
257
258
|
r0 = r1
|
258
259
|
else
|
259
|
-
|
260
|
-
if (match_len = has_terminal?("{", false, index))
|
261
|
-
r5 = true
|
262
|
-
@index += match_len
|
263
|
-
else
|
264
|
-
terminal_parse_failure('"{"')
|
265
|
-
r5 = nil
|
266
|
-
end
|
267
|
-
s4 << r5
|
260
|
+
r5 = _nt_range_quantifier
|
268
261
|
if r5
|
269
|
-
|
270
|
-
|
271
|
-
if r6
|
272
|
-
if (match_len = has_terminal?("}", false, index))
|
273
|
-
r7 = true
|
274
|
-
@index += match_len
|
275
|
-
else
|
276
|
-
terminal_parse_failure('"}"')
|
277
|
-
r7 = nil
|
278
|
-
end
|
279
|
-
s4 << r7
|
280
|
-
end
|
281
|
-
end
|
282
|
-
if s4.last
|
283
|
-
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
284
|
-
r4.extend(Quantifier1)
|
285
|
-
r4.extend(Quantifier2)
|
286
|
-
else
|
287
|
-
@index = i4
|
288
|
-
r4 = nil
|
289
|
-
end
|
290
|
-
if r4
|
291
|
-
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
292
|
-
r0 = r4
|
262
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
263
|
+
r0 = r5
|
293
264
|
else
|
294
265
|
@index = i0
|
295
266
|
r0 = nil
|
@@ -301,20 +272,20 @@ module IREGEXPGRAMMAR
|
|
301
272
|
r0
|
302
273
|
end
|
303
274
|
|
304
|
-
module
|
275
|
+
module RangeQuantifier0
|
305
276
|
end
|
306
277
|
|
307
|
-
module
|
278
|
+
module RangeQuantifier1
|
308
279
|
def QuantExact
|
309
|
-
elements[
|
280
|
+
elements[1]
|
310
281
|
end
|
311
282
|
|
312
283
|
end
|
313
284
|
|
314
|
-
module
|
285
|
+
module RangeQuantifier2
|
315
286
|
def ast
|
316
|
-
l = elements[
|
317
|
-
r = if rp = elements[
|
287
|
+
l = elements[1].ast
|
288
|
+
r = if rp = elements[2].elements
|
318
289
|
if rp[1].text_value != ''
|
319
290
|
rp[1].ast
|
320
291
|
else
|
@@ -327,63 +298,83 @@ module IREGEXPGRAMMAR
|
|
327
298
|
end
|
328
299
|
end
|
329
300
|
|
330
|
-
def
|
301
|
+
def _nt_range_quantifier
|
331
302
|
start_index = index
|
332
|
-
if node_cache[:
|
333
|
-
cached = node_cache[:
|
303
|
+
if node_cache[:range_quantifier].has_key?(index)
|
304
|
+
cached = node_cache[:range_quantifier][index]
|
334
305
|
if cached
|
335
|
-
node_cache[:
|
306
|
+
node_cache[:range_quantifier][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
336
307
|
@index = cached.interval.end
|
337
308
|
end
|
338
309
|
return cached
|
339
310
|
end
|
340
311
|
|
341
312
|
i0, s0 = index, []
|
342
|
-
|
313
|
+
if (match_len = has_terminal?("{", false, index))
|
314
|
+
r1 = true
|
315
|
+
@index += match_len
|
316
|
+
else
|
317
|
+
terminal_parse_failure('"{"')
|
318
|
+
r1 = nil
|
319
|
+
end
|
343
320
|
s0 << r1
|
344
321
|
if r1
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
end
|
353
|
-
s3 << r4
|
354
|
-
if r4
|
355
|
-
r6 = _nt_QuantExact
|
356
|
-
if r6
|
357
|
-
r5 = r6
|
322
|
+
r2 = _nt_QuantExact
|
323
|
+
s0 << r2
|
324
|
+
if r2
|
325
|
+
i4, s4 = index, []
|
326
|
+
if (match_len = has_terminal?(",", false, index))
|
327
|
+
r5 = true
|
328
|
+
@index += match_len
|
358
329
|
else
|
359
|
-
|
330
|
+
terminal_parse_failure('","')
|
331
|
+
r5 = nil
|
332
|
+
end
|
333
|
+
s4 << r5
|
334
|
+
if r5
|
335
|
+
r7 = _nt_QuantExact
|
336
|
+
if r7
|
337
|
+
r6 = r7
|
338
|
+
else
|
339
|
+
r6 = instantiate_node(SyntaxNode,input, index...index)
|
340
|
+
end
|
341
|
+
s4 << r6
|
342
|
+
end
|
343
|
+
if s4.last
|
344
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
345
|
+
r4.extend(RangeQuantifier0)
|
346
|
+
else
|
347
|
+
@index = i4
|
348
|
+
r4 = nil
|
349
|
+
end
|
350
|
+
if r4
|
351
|
+
r3 = r4
|
352
|
+
else
|
353
|
+
r3 = instantiate_node(SyntaxNode,input, index...index)
|
354
|
+
end
|
355
|
+
s0 << r3
|
356
|
+
if r3
|
357
|
+
if (match_len = has_terminal?("}", false, index))
|
358
|
+
r8 = true
|
359
|
+
@index += match_len
|
360
|
+
else
|
361
|
+
terminal_parse_failure('"}"')
|
362
|
+
r8 = nil
|
363
|
+
end
|
364
|
+
s0 << r8
|
360
365
|
end
|
361
|
-
s3 << r5
|
362
|
-
end
|
363
|
-
if s3.last
|
364
|
-
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
365
|
-
r3.extend(Quantity0)
|
366
|
-
else
|
367
|
-
@index = i3
|
368
|
-
r3 = nil
|
369
|
-
end
|
370
|
-
if r3
|
371
|
-
r2 = r3
|
372
|
-
else
|
373
|
-
r2 = instantiate_node(SyntaxNode,input, index...index)
|
374
366
|
end
|
375
|
-
s0 << r2
|
376
367
|
end
|
377
368
|
if s0.last
|
378
369
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
379
|
-
r0.extend(
|
380
|
-
r0.extend(
|
370
|
+
r0.extend(RangeQuantifier1)
|
371
|
+
r0.extend(RangeQuantifier2)
|
381
372
|
else
|
382
373
|
@index = i0
|
383
374
|
r0 = nil
|
384
375
|
end
|
385
376
|
|
386
|
-
node_cache[:
|
377
|
+
node_cache[:range_quantifier][start_index] = r0
|
387
378
|
|
388
379
|
r0
|
389
380
|
end
|
@@ -547,11 +538,11 @@ module IREGEXPGRAMMAR
|
|
547
538
|
r0.extend(NormalChar0)
|
548
539
|
r0.extend(NormalChar0)
|
549
540
|
else
|
550
|
-
if
|
541
|
+
if (match_len = has_terminal?(",", false, index))
|
551
542
|
r2 = true
|
552
|
-
@index +=
|
543
|
+
@index += match_len
|
553
544
|
else
|
554
|
-
terminal_parse_failure('
|
545
|
+
terminal_parse_failure('","')
|
555
546
|
r2 = nil
|
556
547
|
end
|
557
548
|
if r2
|
@@ -560,11 +551,11 @@ module IREGEXPGRAMMAR
|
|
560
551
|
r0.extend(NormalChar0)
|
561
552
|
r0.extend(NormalChar0)
|
562
553
|
else
|
563
|
-
if
|
554
|
+
if (match_len = has_terminal?("-", false, index))
|
564
555
|
r3 = true
|
565
|
-
@index +=
|
556
|
+
@index += match_len
|
566
557
|
else
|
567
|
-
terminal_parse_failure('
|
558
|
+
terminal_parse_failure('"-"')
|
568
559
|
r3 = nil
|
569
560
|
end
|
570
561
|
if r3
|
@@ -573,11 +564,11 @@ module IREGEXPGRAMMAR
|
|
573
564
|
r0.extend(NormalChar0)
|
574
565
|
r0.extend(NormalChar0)
|
575
566
|
else
|
576
|
-
if has_terminal?(@regexps[gr = '\A[
|
567
|
+
if has_terminal?(@regexps[gr = '\A[/->]'] ||= Regexp.new(gr), :regexp, index)
|
577
568
|
r4 = true
|
578
569
|
@index += 1
|
579
570
|
else
|
580
|
-
terminal_parse_failure('[
|
571
|
+
terminal_parse_failure('[/->]')
|
581
572
|
r4 = nil
|
582
573
|
end
|
583
574
|
if r4
|
@@ -586,11 +577,11 @@ module IREGEXPGRAMMAR
|
|
586
577
|
r0.extend(NormalChar0)
|
587
578
|
r0.extend(NormalChar0)
|
588
579
|
else
|
589
|
-
if has_terminal?(@regexps[gr = '\A[
|
580
|
+
if has_terminal?(@regexps[gr = '\A[@-Z]'] ||= Regexp.new(gr), :regexp, index)
|
590
581
|
r5 = true
|
591
582
|
@index += 1
|
592
583
|
else
|
593
|
-
terminal_parse_failure('[
|
584
|
+
terminal_parse_failure('[@-Z]')
|
594
585
|
r5 = nil
|
595
586
|
end
|
596
587
|
if r5
|
@@ -599,11 +590,11 @@ module IREGEXPGRAMMAR
|
|
599
590
|
r0.extend(NormalChar0)
|
600
591
|
r0.extend(NormalChar0)
|
601
592
|
else
|
602
|
-
if has_terminal?(@regexps[gr = '\A[
|
593
|
+
if has_terminal?(@regexps[gr = '\A[\\^-z]'] ||= Regexp.new(gr), :regexp, index)
|
603
594
|
r6 = true
|
604
595
|
@index += 1
|
605
596
|
else
|
606
|
-
terminal_parse_failure('[
|
597
|
+
terminal_parse_failure('[\\^-z]')
|
607
598
|
r6 = nil
|
608
599
|
end
|
609
600
|
if r6
|
@@ -612,8 +603,36 @@ module IREGEXPGRAMMAR
|
|
612
603
|
r0.extend(NormalChar0)
|
613
604
|
r0.extend(NormalChar0)
|
614
605
|
else
|
615
|
-
@
|
616
|
-
|
606
|
+
if has_terminal?(@regexps[gr = '\A[~-]'] ||= Regexp.new(gr), :regexp, index)
|
607
|
+
r7 = true
|
608
|
+
@index += 1
|
609
|
+
else
|
610
|
+
terminal_parse_failure('[~-]')
|
611
|
+
r7 = nil
|
612
|
+
end
|
613
|
+
if r7
|
614
|
+
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
615
|
+
r0 = r7
|
616
|
+
r0.extend(NormalChar0)
|
617
|
+
r0.extend(NormalChar0)
|
618
|
+
else
|
619
|
+
if has_terminal?(@regexps[gr = '\A[-]'] ||= Regexp.new(gr), :regexp, index)
|
620
|
+
r8 = true
|
621
|
+
@index += 1
|
622
|
+
else
|
623
|
+
terminal_parse_failure('[-]')
|
624
|
+
r8 = nil
|
625
|
+
end
|
626
|
+
if r8
|
627
|
+
r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
|
628
|
+
r0 = r8
|
629
|
+
r0.extend(NormalChar0)
|
630
|
+
r0.extend(NormalChar0)
|
631
|
+
else
|
632
|
+
@index = i0
|
633
|
+
r0 = nil
|
634
|
+
end
|
635
|
+
end
|
617
636
|
end
|
618
637
|
end
|
619
638
|
end
|
@@ -726,85 +745,97 @@ module IREGEXPGRAMMAR
|
|
726
745
|
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
727
746
|
r2 = r3
|
728
747
|
else
|
729
|
-
if
|
748
|
+
if (match_len = has_terminal?("-", false, index))
|
730
749
|
r4 = true
|
731
|
-
@index +=
|
750
|
+
@index += match_len
|
732
751
|
else
|
733
|
-
terminal_parse_failure('
|
752
|
+
terminal_parse_failure('"-"')
|
734
753
|
r4 = nil
|
735
754
|
end
|
736
755
|
if r4
|
737
756
|
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
738
757
|
r2 = r4
|
739
758
|
else
|
740
|
-
if (match_len = has_terminal?("
|
759
|
+
if (match_len = has_terminal?(".", false, index))
|
741
760
|
r5 = true
|
742
761
|
@index += match_len
|
743
762
|
else
|
744
|
-
terminal_parse_failure('"
|
763
|
+
terminal_parse_failure('"."')
|
745
764
|
r5 = nil
|
746
765
|
end
|
747
766
|
if r5
|
748
767
|
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
749
768
|
r2 = r5
|
750
769
|
else
|
751
|
-
if
|
770
|
+
if (match_len = has_terminal?("?", false, index))
|
752
771
|
r6 = true
|
753
|
-
@index +=
|
772
|
+
@index += match_len
|
754
773
|
else
|
755
|
-
terminal_parse_failure('
|
774
|
+
terminal_parse_failure('"?"')
|
756
775
|
r6 = nil
|
757
776
|
end
|
758
777
|
if r6
|
759
778
|
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
760
779
|
r2 = r6
|
761
780
|
else
|
762
|
-
if (
|
781
|
+
if has_terminal?(@regexps[gr = '\A[\\[-\\^]'] ||= Regexp.new(gr), :regexp, index)
|
763
782
|
r7 = true
|
764
|
-
@index +=
|
783
|
+
@index += 1
|
765
784
|
else
|
766
|
-
terminal_parse_failure('
|
785
|
+
terminal_parse_failure('[\\[-\\^]')
|
767
786
|
r7 = nil
|
768
787
|
end
|
769
788
|
if r7
|
770
789
|
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
771
790
|
r2 = r7
|
772
791
|
else
|
773
|
-
if (match_len = has_terminal?("
|
792
|
+
if (match_len = has_terminal?("n", false, index))
|
774
793
|
r8 = true
|
775
794
|
@index += match_len
|
776
795
|
else
|
777
|
-
terminal_parse_failure('"
|
796
|
+
terminal_parse_failure('"n"')
|
778
797
|
r8 = nil
|
779
798
|
end
|
780
799
|
if r8
|
781
800
|
r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
|
782
801
|
r2 = r8
|
783
802
|
else
|
784
|
-
if (match_len = has_terminal?("
|
803
|
+
if (match_len = has_terminal?("r", false, index))
|
785
804
|
r9 = true
|
786
805
|
@index += match_len
|
787
806
|
else
|
788
|
-
terminal_parse_failure('"
|
807
|
+
terminal_parse_failure('"r"')
|
789
808
|
r9 = nil
|
790
809
|
end
|
791
810
|
if r9
|
792
811
|
r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
|
793
812
|
r2 = r9
|
794
813
|
else
|
795
|
-
if
|
814
|
+
if (match_len = has_terminal?("t", false, index))
|
796
815
|
r10 = true
|
797
|
-
@index +=
|
816
|
+
@index += match_len
|
798
817
|
else
|
799
|
-
terminal_parse_failure('
|
818
|
+
terminal_parse_failure('"t"')
|
800
819
|
r10 = nil
|
801
820
|
end
|
802
821
|
if r10
|
803
822
|
r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
|
804
823
|
r2 = r10
|
805
824
|
else
|
806
|
-
@
|
807
|
-
|
825
|
+
if has_terminal?(@regexps[gr = '\A[\\{-\\}]'] ||= Regexp.new(gr), :regexp, index)
|
826
|
+
r11 = true
|
827
|
+
@index += 1
|
828
|
+
else
|
829
|
+
terminal_parse_failure('[\\{-\\}]')
|
830
|
+
r11 = nil
|
831
|
+
end
|
832
|
+
if r11
|
833
|
+
r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
|
834
|
+
r2 = r11
|
835
|
+
else
|
836
|
+
@index = i2
|
837
|
+
r2 = nil
|
838
|
+
end
|
808
839
|
end
|
809
840
|
end
|
810
841
|
end
|
@@ -1130,11 +1161,11 @@ module IREGEXPGRAMMAR
|
|
1130
1161
|
r1.extend(CCchar0)
|
1131
1162
|
r1.extend(CCchar0)
|
1132
1163
|
else
|
1133
|
-
if has_terminal?(@regexps[gr = '\A[
|
1164
|
+
if has_terminal?(@regexps[gr = '\A[\\^-]'] ||= Regexp.new(gr), :regexp, index)
|
1134
1165
|
r4 = true
|
1135
1166
|
@index += 1
|
1136
1167
|
else
|
1137
|
-
terminal_parse_failure('[
|
1168
|
+
terminal_parse_failure('[\\^-]')
|
1138
1169
|
r4 = nil
|
1139
1170
|
end
|
1140
1171
|
if r4
|
@@ -1143,8 +1174,22 @@ module IREGEXPGRAMMAR
|
|
1143
1174
|
r1.extend(CCchar0)
|
1144
1175
|
r1.extend(CCchar0)
|
1145
1176
|
else
|
1146
|
-
@
|
1147
|
-
|
1177
|
+
if has_terminal?(@regexps[gr = '\A[-]'] ||= Regexp.new(gr), :regexp, index)
|
1178
|
+
r5 = true
|
1179
|
+
@index += 1
|
1180
|
+
else
|
1181
|
+
terminal_parse_failure('[-]')
|
1182
|
+
r5 = nil
|
1183
|
+
end
|
1184
|
+
if r5
|
1185
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
1186
|
+
r1 = r5
|
1187
|
+
r1.extend(CCchar0)
|
1188
|
+
r1.extend(CCchar0)
|
1189
|
+
else
|
1190
|
+
@index = i1
|
1191
|
+
r1 = nil
|
1192
|
+
end
|
1148
1193
|
end
|
1149
1194
|
end
|
1150
1195
|
end
|
@@ -1152,10 +1197,10 @@ module IREGEXPGRAMMAR
|
|
1152
1197
|
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
1153
1198
|
r0 = r1
|
1154
1199
|
else
|
1155
|
-
|
1156
|
-
if
|
1157
|
-
|
1158
|
-
r0 =
|
1200
|
+
r6 = _nt_SingleCharEsc
|
1201
|
+
if r6
|
1202
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
1203
|
+
r0 = r6
|
1159
1204
|
else
|
1160
1205
|
@index = i0
|
1161
1206
|
r0 = nil
|
@@ -1390,41 +1435,65 @@ module IREGEXPGRAMMAR
|
|
1390
1435
|
s0 << r1
|
1391
1436
|
if r1
|
1392
1437
|
i3 = index
|
1393
|
-
if
|
1438
|
+
if (match_len = has_terminal?("l", false, index))
|
1394
1439
|
r4 = true
|
1395
|
-
@index +=
|
1440
|
+
@index += match_len
|
1396
1441
|
else
|
1397
|
-
terminal_parse_failure('
|
1442
|
+
terminal_parse_failure('"l"')
|
1398
1443
|
r4 = nil
|
1399
1444
|
end
|
1400
1445
|
if r4
|
1401
1446
|
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
1402
1447
|
r3 = r4
|
1403
1448
|
else
|
1404
|
-
if (match_len = has_terminal?("
|
1449
|
+
if (match_len = has_terminal?("m", false, index))
|
1405
1450
|
r5 = true
|
1406
1451
|
@index += match_len
|
1407
1452
|
else
|
1408
|
-
terminal_parse_failure('"
|
1453
|
+
terminal_parse_failure('"m"')
|
1409
1454
|
r5 = nil
|
1410
1455
|
end
|
1411
1456
|
if r5
|
1412
1457
|
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
1413
1458
|
r3 = r5
|
1414
1459
|
else
|
1415
|
-
if
|
1460
|
+
if (match_len = has_terminal?("o", false, index))
|
1416
1461
|
r6 = true
|
1417
|
-
@index +=
|
1462
|
+
@index += match_len
|
1418
1463
|
else
|
1419
|
-
terminal_parse_failure('
|
1464
|
+
terminal_parse_failure('"o"')
|
1420
1465
|
r6 = nil
|
1421
1466
|
end
|
1422
1467
|
if r6
|
1423
1468
|
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
1424
1469
|
r3 = r6
|
1425
1470
|
else
|
1426
|
-
|
1427
|
-
|
1471
|
+
if (match_len = has_terminal?("t", false, index))
|
1472
|
+
r7 = true
|
1473
|
+
@index += match_len
|
1474
|
+
else
|
1475
|
+
terminal_parse_failure('"t"')
|
1476
|
+
r7 = nil
|
1477
|
+
end
|
1478
|
+
if r7
|
1479
|
+
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
1480
|
+
r3 = r7
|
1481
|
+
else
|
1482
|
+
if (match_len = has_terminal?("u", false, index))
|
1483
|
+
r8 = true
|
1484
|
+
@index += match_len
|
1485
|
+
else
|
1486
|
+
terminal_parse_failure('"u"')
|
1487
|
+
r8 = nil
|
1488
|
+
end
|
1489
|
+
if r8
|
1490
|
+
r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
|
1491
|
+
r3 = r8
|
1492
|
+
else
|
1493
|
+
@index = i3
|
1494
|
+
r3 = nil
|
1495
|
+
end
|
1496
|
+
end
|
1428
1497
|
end
|
1429
1498
|
end
|
1430
1499
|
end
|
@@ -1934,19 +2003,31 @@ module IREGEXPGRAMMAR
|
|
1934
2003
|
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
1935
2004
|
r3 = r5
|
1936
2005
|
else
|
1937
|
-
if
|
2006
|
+
if (match_len = has_terminal?("n", false, index))
|
1938
2007
|
r6 = true
|
1939
|
-
@index +=
|
2008
|
+
@index += match_len
|
1940
2009
|
else
|
1941
|
-
terminal_parse_failure('
|
2010
|
+
terminal_parse_failure('"n"')
|
1942
2011
|
r6 = nil
|
1943
2012
|
end
|
1944
2013
|
if r6
|
1945
2014
|
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
1946
2015
|
r3 = r6
|
1947
2016
|
else
|
1948
|
-
|
1949
|
-
|
2017
|
+
if (match_len = has_terminal?("o", false, index))
|
2018
|
+
r7 = true
|
2019
|
+
@index += match_len
|
2020
|
+
else
|
2021
|
+
terminal_parse_failure('"o"')
|
2022
|
+
r7 = nil
|
2023
|
+
end
|
2024
|
+
if r7
|
2025
|
+
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
2026
|
+
r3 = r7
|
2027
|
+
else
|
2028
|
+
@index = i3
|
2029
|
+
r3 = nil
|
2030
|
+
end
|
1950
2031
|
end
|
1951
2032
|
end
|
1952
2033
|
end
|
data/test-data/simple.out
CHANGED
@@ -6,22 +6,22 @@
|
|
6
6
|
"a"
|
7
7
|
=🤔 "🤔"
|
8
8
|
"🤔"
|
9
|
-
-\ Expected one of [\(-\+],
|
9
|
+
-\ Expected one of [\(-\+], "-", ".", "?", [\[-\^], "n", "r", "t", [\{-\}] at line 1, column 2 (byte 2):
|
10
10
|
\
|
11
11
|
~^
|
12
|
-
-\v Expected one of [\(-\+],
|
12
|
+
-\v Expected one of [\(-\+], "-", ".", "?", [\[-\^], "n", "r", "t", [\{-\}] at line 1, column 2 (byte 2):
|
13
13
|
\v
|
14
14
|
~^
|
15
|
-
-\\\ Expected one of [\(-\+],
|
15
|
+
-\\\ Expected one of [\(-\+], "-", ".", "?", [\[-\^], "n", "r", "t", [\{-\}] at line 1, column 4 (byte 4):
|
16
16
|
\\\
|
17
17
|
~~~^
|
18
|
-
-\\\v Expected one of [\(-\+],
|
18
|
+
-\\\v Expected one of [\(-\+], "-", ".", "?", [\[-\^], "n", "r", "t", [\{-\}] at line 1, column 4 (byte 4):
|
19
19
|
\\\v
|
20
20
|
~~~^
|
21
|
-
-\\\z Expected one of [\(-\+],
|
21
|
+
-\\\z Expected one of [\(-\+], "-", ".", "?", [\[-\^], "n", "r", "t", [\{-\}] at line 1, column 4 (byte 4):
|
22
22
|
\\\z
|
23
23
|
~~~^
|
24
|
-
-\ca Expected one of [\(-\+],
|
24
|
+
-\ca Expected one of [\(-\+], "-", ".", "?", [\[-\^], "n", "r", "t", [\{-\}] at line 1, column 2 (byte 2):
|
25
25
|
\ca
|
26
26
|
~^
|
27
27
|
=\(\)\*\+\.\?\[\\ ["seq", "(", ")", "*", "+", ".", "?", "[", "\\"]
|
@@ -32,7 +32,7 @@
|
|
32
32
|
"", "a", "aa", "aaa", "aaaa"
|
33
33
|
=🤔* ["rep", 0, false, "🤔"]
|
34
34
|
"", "🤔", "🤔🤔", "🤔🤔🤔", "🤔🤔🤔🤔"
|
35
|
-
-a** Expected one of [\u0000-'],
|
35
|
+
-a** Expected one of [\u0000-'], ",", "-", [/->], [@-Z], [\^-z], [~-], ".", "\\", "\\p{", "\\P{", "[", "(", "|" at line 1, column 3 (byte 3):
|
36
36
|
a**
|
37
37
|
~~^
|
38
38
|
=a|b ["alt", "a", "b"]
|
@@ -57,18 +57,18 @@
|
|
57
57
|
"aa", "bbbbbbb", "bbbbbbbb", "bbbbbbbbb"
|
58
58
|
=(aa) ["seq", "a", "a"]
|
59
59
|
"aa"
|
60
|
-
-aa) Expected one of
|
60
|
+
-aa) Expected one of "*", "+", "?", "{", [\u0000-'], ",", "-", [/->], [@-Z], [\^-z], [~-], ".", "\\", "\\p{", "\\P{", "[", "(", "|" at line 1, column 3 (byte 3):
|
61
61
|
aa)
|
62
62
|
~~^
|
63
|
-
-(aa Expected one of
|
63
|
+
-(aa Expected one of "*", "+", "?", "{", [\u0000-'], ",", "-", [/->], [@-Z], [\^-z], [~-], ".", "\\", "\\p{", "\\P{", "[", "(", "|", ")" at line 1, column 4 (byte 4):
|
64
64
|
(aa
|
65
65
|
~~~^
|
66
66
|
=aa(bb|cc)dd ["seq", "a", "a", ["alt", ["seq", "b", "b"], ["seq", "c", "c"]], "d", "d"]
|
67
67
|
"aabbdd", "aaccdd"
|
68
|
-
-aabb|cc)dd Expected one of
|
68
|
+
-aabb|cc)dd Expected one of "*", "+", "?", "{", [\u0000-'], ",", "-", [/->], [@-Z], [\^-z], [~-], ".", "\\", "\\p{", "\\P{", "[", "(", "|" at line 1, column 8 (byte 8):
|
69
69
|
aabb|cc)dd
|
70
70
|
~~~~~~~^
|
71
|
-
-aa(bb|ccdd Expected one of
|
71
|
+
-aa(bb|ccdd Expected one of "*", "+", "?", "{", [\u0000-'], ",", "-", [/->], [@-Z], [\^-z], [~-], ".", "\\", "\\p{", "\\P{", "[", "(", "|", ")" at line 1, column 11 (byte 11):
|
72
72
|
aa(bb|ccdd
|
73
73
|
~~~~~~~~~~^
|
74
74
|
=[abc] ["pos", "a", "b", "c"]
|
@@ -76,7 +76,7 @@
|
|
76
76
|
-[a Expected one of "-", [\u0000-,], [\.-Z], [\^-], "\\", "\\p{", "\\P{", "]" at line 1, column 3 (byte 3):
|
77
77
|
[a
|
78
78
|
~~^
|
79
|
-
-a] Expected one of
|
79
|
+
-a] Expected one of "*", "+", "?", "{", [\u0000-'], ",", "-", [/->], [@-Z], [\^-z], [~-], ".", "\\", "\\p{", "\\P{", "[", "(", "|" at line 1, column 2 (byte 2):
|
80
80
|
a]
|
81
81
|
~^
|
82
82
|
=[a🤔b] ["pos", "a", "🤔", "b"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iregexp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
|
-
rubygems_version: 3.4.
|
103
|
+
rubygems_version: 3.4.10
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: I-Regexp Tools
|