Skip to content

Commit 9c348a6

Browse files
committed
Support empty positional captures.
1 parent f12484a commit 9c348a6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/QRegex/P5Regex/Actions.nqp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ class QRegex::P5Regex::Actions is HLL::Actions {
8585
}
8686

8787
method p5metachar:sym<( )>($/) {
88-
make QAST::Regex.new( $<nibbler>.ast, :rxtype<subcapture>, :node($/) );
88+
make QAST::Regex.new( :rxtype<subcapture>, :node($/),
89+
$<nibbler>
90+
?? $<nibbler>[0].ast
91+
!! QAST::Regex.new( :rxtype<anchor>, :subtype<pass> ) );
8992
}
9093

9194
method p5metachar:sym<[ ]>($/) {

src/QRegex/P5Regex/Grammar.nqp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ grammar QRegex::P5Regex::Grammar is HLL::Grammar {
5959
'(?' {} <assertion=p5assertion>
6060
[ ')' || <.panic: "Perl 5 regex assertion not terminated by parenthesis"> ]
6161
}
62-
token p5metachar:sym<( )> { '(' {} <nibbler> ')' }
62+
token p5metachar:sym<( )> { '(' {} <nibbler>? ')' }
6363
token p5metachar:sym<[ ]> { <?before '['> <cclass> }
6464

6565
token cclass {

0 commit comments

Comments
 (0)