@@ -35,7 +35,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
35
35
}
36
36
else {
37
37
$ qast . push ($ _ . ast);
38
- $ lastlit := $ ast . rxtype eq ' literal'
38
+ $ lastlit := $ ast . rxtype eq ' literal'
39
39
&& ! QAST ::Node. ACCEPTS ($ ast [0 ])
40
40
?? $ ast !! 0 ;
41
41
}
@@ -73,11 +73,11 @@ class QRegex::P5Regex::Actions is HLL::Actions {
73
73
make $ qast ;
74
74
}
75
75
}
76
-
76
+
77
77
method p5metachar :sym <bs >($/ ) {
78
78
make $ < backslash > . ast;
79
79
}
80
-
80
+
81
81
method p5metachar :sym <. >($/ ) {
82
82
make % * RX <s >
83
83
?? QAST ::Regex. new ( : rxtype<cclass >, : name<. >, : node($/ ) )
@@ -98,7 +98,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
98
98
QAST ::Regex. new ( : rxtype<anchor >, : subtype(% * RX <m > ?? ' eol' !! ' eos' ), : node($/ ) )
99
99
);
100
100
}
101
-
101
+
102
102
method p5metachar :sym < (? )> ($/ ) { # like P6's $<name>=[ ... ]
103
103
my $ qast ;
104
104
if $ < nibbler > {
@@ -110,20 +110,20 @@ class QRegex::P5Regex::Actions is HLL::Actions {
110
110
}
111
111
make $ qast ;
112
112
}
113
-
113
+
114
114
method p5metachar :sym < (?: )> ($/ ) {
115
115
make $ < nibbler > . ast;
116
116
}
117
-
117
+
118
118
method p5metachar :sym < ( )> ($/ ) {
119
119
make QAST ::Regex. new ( : rxtype<subcapture >, : node($/ ),
120
120
$ < nibbler > . ast );
121
121
}
122
-
122
+
123
123
method p5metachar :sym < [ ]> ($/ ) {
124
124
make $ < cclass > . ast;
125
125
}
126
-
126
+
127
127
method cclass ($/ ) {
128
128
my $ str := ' ' ;
129
129
my $ qast ;
@@ -183,7 +183,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
183
183
$ qast := + @ alts == 1 ?? @ alts [0 ] !!
184
184
$ < sign > eq ' ^' ??
185
185
QAST ::Regex. new ( : rxtype<concat >, : node($/ ),
186
- QAST ::Regex. new ( : rxtype<conj >, : subtype<zerowidth >, | @ alts ),
186
+ QAST ::Regex. new ( : rxtype<conj >, : subtype<zerowidth >, | @ alts ),
187
187
QAST ::Regex. new ( : rxtype<cclass >, : name<. > ) ) !!
188
188
QAST ::Regex. new ( : rxtype<altseq >, | @ alts );
189
189
make $ qast ;
@@ -267,7 +267,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
267
267
QAST ::SVal. new ( : value(~ $ < number > - 1 ) ) ) );
268
268
}
269
269
}
270
-
270
+
271
271
method p5assertion :sym «< »($/ ) {
272
272
if $ < nibbler > {
273
273
make QAST ::Regex. new (
@@ -281,7 +281,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
281
281
make 0 ;
282
282
}
283
283
}
284
-
284
+
285
285
method p5assertion :sym <= >($/ ) {
286
286
if $ < nibbler > {
287
287
make QAST ::Regex. new (
@@ -295,7 +295,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
295
295
make 0 ;
296
296
}
297
297
}
298
-
298
+
299
299
method p5assertion :sym <! >($/ ) {
300
300
if $ < nibbler > {
301
301
make QAST ::Regex. new (
@@ -320,7 +320,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
320
320
}
321
321
}
322
322
}
323
-
323
+
324
324
method p5assertion :sym <mod >($/ ) {
325
325
if $ < nibbler > {
326
326
make $ < nibbler > [0 ]. ast;
@@ -332,7 +332,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
332
332
make 0 ;
333
333
}
334
334
}
335
-
335
+
336
336
method p5quantifier :sym <* >($/ ) {
337
337
my $ qast := QAST ::Regex. new ( : rxtype<quant >, : min (0 ), : max (-1 ), : node($/ ) );
338
338
make quantmod($ qast , $ < quantmod > );
@@ -347,7 +347,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
347
347
my $ qast := QAST ::Regex. new ( : rxtype<quant >, : min (0 ), : max (1 ), : node($/ ) );
348
348
make quantmod($ qast , ~ $ < quantmod > );
349
349
}
350
-
350
+
351
351
method p5quantifier :sym < { }> ($/ ) {
352
352
my $ qast ;
353
353
$ qast := QAST ::Regex. new ( : rxtype<quant >, : min (nqp ::radix(10 , $ < start > , 0 , 0 )[0 ]), : node($/ ) );
@@ -356,13 +356,13 @@ class QRegex::P5Regex::Actions is HLL::Actions {
356
356
else { $ qast . max ($ qast . min ); }
357
357
make quantmod($ qast , $ < quantmod > );
358
358
}
359
-
359
+
360
360
sub quantmod ($ ast , $ mod ) {
361
361
if $ mod eq ' ?' { $ ast . backtrack(' f' ) }
362
362
elsif $ mod eq ' +' { $ ast . backtrack(' g' ) }
363
363
$ ast ;
364
364
}
365
-
365
+
366
366
method qbuildsub ($ qast , $ block = QAST ::Block. new (), : $ anon , : $ addself , * % rest ) {
367
367
my $ * LANG := $ qast . node;
368
368
my $ code_obj := nqp ::existskey(% rest , ' code_obj' )
@@ -388,7 +388,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
388
388
QAST ::Regex. new ( : rxtype<pass > ) !!
389
389
QAST ::Regex. new ( : rxtype<pass >, : name(% * RX <name >) )));
390
390
$ block . push ($ qast );
391
-
391
+
392
392
$ block ;
393
393
}
394
394
@@ -400,7 +400,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
400
400
my % x := capnames($ _ , $ count );
401
401
for % x { % capnames {$ _ . key } := + % capnames {$ _ . key } + $ _ . value ; }
402
402
$ count := % x {' ' };
403
- }
403
+ }
404
404
}
405
405
elsif $ rxtype eq ' altseq' || $ rxtype eq ' alt' {
406
406
my $ max := $ count ;
@@ -441,7 +441,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
441
441
nqp ::deletekey(% capnames , ' $!to' );
442
442
% capnames ;
443
443
}
444
-
444
+
445
445
method flip_ast ($ qast ) {
446
446
return $ qast unless nqp ::istype($ qast , QAST ::Regex);
447
447
if $ qast . rxtype eq ' literal' {
@@ -457,18 +457,18 @@ class QRegex::P5Regex::Actions is HLL::Actions {
457
457
}
458
458
$ qast
459
459
}
460
-
460
+
461
461
# This is overridden by a compiler that wants to create code objects
462
462
# for regexes. We just use the standard NQP one in standalone mode.
463
463
method create_regex_code_object ($ block ) {
464
464
$ * W . create_code($ block , $ block . name );
465
465
}
466
-
466
+
467
467
# Stores the captures info for a regex.
468
468
method store_regex_caps ($ code_obj , $ block , % caps ) {
469
469
$ code_obj . SET_CAPS(% caps );
470
470
}
471
-
471
+
472
472
# Override this to store the overall NFA for a regex. (Standalone mode doesn't need
473
473
# it, as it only supports executing individual regexes).
474
474
method store_regex_nfa ($ code_obj , $ block , $ nfa ) {
@@ -528,11 +528,11 @@ class QRegex::P5Regex::Actions is HLL::Actions {
528
528
if $ qast . rxtype eq ' quant' && $ qast [0 ]. rxtype eq ' subrule' {
529
529
self . subrule_alias($ qast [0 ], $ name );
530
530
}
531
- elsif $ qast . rxtype eq ' subrule' {
532
- self . subrule_alias($ qast , $ name );
531
+ elsif $ qast . rxtype eq ' subrule' {
532
+ self . subrule_alias($ qast , $ name );
533
533
}
534
534
else {
535
- $ qast := QAST ::Regex. new ( $ qast , : name($ name ),
535
+ $ qast := QAST ::Regex. new ( $ qast , : name($ name ),
536
536
: rxtype<subcapture >, : node($/ ) );
537
537
}
538
538
}
@@ -619,7 +619,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
619
619
self . subrule_alias($ qast , $ name );
620
620
}
621
621
else {
622
- $ qast := QAST ::Regex. new ( $ qast , : name($ name ),
622
+ $ qast := QAST ::Regex. new ( $ qast , : name($ name ),
623
623
: rxtype<subcapture >, : node($/ ) );
624
624
}
625
625
}
@@ -647,7 +647,7 @@ class QRegex::P5Regex::Actions is HLL::Actions {
647
647
}
648
648
make $ qast ;
649
649
}
650
-
650
+
651
651
method arg ($/ ) {
652
652
make $ < quote_EXPR > ?? $ < quote_EXPR > . ast !! + $ < val > ;
653
653
}
0 commit comments