diff --git a/src/Regex/P6Regex/Actions.pm b/src/Regex/P6Regex/Actions.pm index 8cd02a8..de090dd 100644 --- a/src/Regex/P6Regex/Actions.pm +++ b/src/Regex/P6Regex/Actions.pm @@ -168,6 +168,19 @@ method metachar:sym($/) { make $.ast; } +method metachar:sym($/) { + my $past; + my $name := $ ?? +$ !! ~$; + if $ { + $past := $[0].ast; + if $past.pasttype eq 'subrule' { + $past.subtype('capture'); + $past.name($name); + } + } + make $past; +} + method backslash:sym($/) { my $subtype := ~$ eq 'n' ?? 'nl' !! ~$; my $past := PAST::Regex.new( :pasttype('charclass'), :subtype($subtype) ); @@ -329,6 +342,7 @@ sub capnames($ast, $count) { $ast.name($count); $count := $count + 1; } + elsif $ast.name eq '0' || $ast.name > 0 { $count := $ast.name + 1; } %capnames{$ast.name} := 1; } elsif $pasttype eq 'quant' { diff --git a/src/Regex/P6Regex/Grammar.pm b/src/Regex/P6Regex/Grammar.pm index 73dacca..b41782e 100644 --- a/src/Regex/P6Regex/Grammar.pm +++ b/src/Regex/P6Regex/Grammar.pm @@ -71,6 +71,16 @@ grammar Regex::P6Regex::Grammar is PCT::Grammar; {*} } + token metachar:sym { + [ + | '$<' $=[<-[>]>+] '>' + | '$' $=[\d+] + ] + + [ <.ws> '=' <.ws> ]? + {*} + } + # proto token backslash { <...> } token backslash:sym { $=[<[dswnDSWN]>] {*} } token backslash:sym { $=[<[bB]>] {*} }