File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -99,8 +99,20 @@ class QRegex::P5Regex::Actions is HLL::Actions {
99
99
);
100
100
}
101
101
102
- method p5metachar :sym < (? )> ($/ ) {
103
- make $ < assertion > . ast;
102
+ method p5metachar :sym < (? )> ($/ ) { # like P6's $<name>=[ ... ]
103
+ my $ qast ;
104
+ if $ < nibbler > {
105
+ $ qast := QAST ::Regex. new ( : rxtype<subcapture >, : name(~ $ < name > ),
106
+ $ < nibbler > . ast, : node($/ ) );
107
+ }
108
+ else {
109
+ $ qast := $ < assertion > . ast;
110
+ }
111
+ make $ qast ;
112
+ }
113
+
114
+ method p5metachar :sym < (?: )> ($/ ) {
115
+ make $ < nibbler > . ast;
104
116
}
105
117
106
118
method p5metachar :sym < ( )> ($/ ) {
Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ grammar QRegex::P5Regex::Grammar is HLL::Grammar {
86
86
proto token p5metachar { <...> }
87
87
88
88
token p5metachar :sym <quant > {
89
+ <![ (? ] >
89
90
<quantifier = p5quantifier >
90
91
<.panic : "quantifier quantifies nothing" >
91
92
}
@@ -96,9 +97,15 @@ grammar QRegex::P5Regex::Grammar is HLL::Grammar {
96
97
'$' <? before \W | $ >
97
98
}
98
99
token p5metachar :sym <(? ) > {
99
- '(?' { } <assertion = p5assertion >
100
- [ ')' || <.panic : "Perl 5 regex assertion not terminated by parenthesis" > ]
100
+ '(?' <![ ? ] >
101
+ [
102
+ | <?[ < ] > '<' $ < name > =[<- [ > ] >+ ] '>' { } <nibbler >
103
+ | <?[ ' ] > "'" $ < name > =[<- [ ' ] >+ ] "'" { } <nibbler >
104
+ | <assertion = p5assertion >
105
+ ]
106
+ [ ')' || <.panic : "Perl 5 named capture group not terminated by parenthesis" > ]
101
107
}
108
+ token p5metachar :sym <(?: ) > { '(?:' { } <nibbler > ')' }
102
109
token p5metachar :sym <( ) > { '(' { } <nibbler > ')' }
103
110
token p5metachar :sym <[ ] > { <? before '[' > <cclass > }
104
111
You can’t perform that action at this time.
0 commit comments