@@ -519,6 +519,7 @@ class QRegex::P6Regex::Actions is HLL::Actions {
519
519
: hll<nqp >, : namespace([' Sub' ]), : lexical(0 ),
520
520
: name($ block . subid ~ ' _nfa' ), $ nfapast );
521
521
$ initpast . push (PAST::Stmt. new ($ nfablock ));
522
+ alt_nfas($ qast , $ block . subid, $ initpast );
522
523
}
523
524
524
525
unless $ block . symbol(' $¢' ) {
@@ -586,6 +587,28 @@ class QRegex::P6Regex::Actions is HLL::Actions {
586
587
% capnames {' ' } := $ count ;
587
588
% capnames ;
588
589
}
590
+
591
+ sub alt_nfas ($ ast , $ subid , $ initpast ) {
592
+ my $ rxtype := $ ast . rxtype;
593
+ if $ rxtype eq ' alt' {
594
+ my $ nfapast := PAST::Op. new ( : pasttype(' list' ) );
595
+ $ ast . name (PAST::Node. unique (' alt_nfa_' ));
596
+ for $ ast . list {
597
+ alt_nfas($ _ , $ subid , $ initpast );
598
+ $ nfapast . push (QRegex::NFA. new . addnode($ _ ). past);
599
+ }
600
+ my $ nfablock := PAST::Block. new (
601
+ : hll<nqp >, : namespace([' Sub' ]), : lexical(0 ),
602
+ : name($ subid ~ ' _' ~ $ ast . name ), $ nfapast );
603
+ $ initpast . push (PAST::Stmt. new ($ nfablock ));
604
+ }
605
+ elsif $ rxtype eq ' subcapture' || $ rxtype eq ' quant' {
606
+ alt_nfas($ ast [0 ], $ subid , $ initpast )
607
+ }
608
+ elsif $ rxtype eq ' concat' || $ rxtype eq ' altseq' || $ rxtype eq ' conj' || $ rxtype eq ' conjseq' {
609
+ for $ ast . list { alt_nfas($ _ , $ subid , $ initpast ) }
610
+ }
611
+ }
589
612
590
613
method subrule_alias ($ ast , $ name ) {
591
614
if $ ast . name gt ' ' { $ ast . name ( $ name ~ ' =' ~ $ ast . name ); }
0 commit comments