Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
implement wantarray, so /@<foo>=./ is about arrays
Now $<foo> will contain an Array of Match objects, as if it had a quantifier
applied on it. This is useful if you want to have consistant match structures
for different inputs.
  • Loading branch information
FROGGS committed Sep 24, 2015
1 parent dadb7bc commit ada83f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/QRegex/P6Regex/Actions.nqp
Expand Up @@ -274,8 +274,9 @@ class QRegex::P6Regex::Actions is HLL::Actions {
if ($qast.rxtype eq 'quant' || $qast.rxtype eq 'dynquant') && $qast[0].rxtype eq 'subrule' {
self.subrule_alias($qast[0], $name);
}
elsif $qast.rxtype eq 'subrule' {
self.subrule_alias($qast, $name);
elsif $qast.rxtype eq 'subrule' {
self.subrule_alias($qast, $name);
$qast := QAST::Regex.new( :rxtype<quant>, :min(0), :max(-1), $qast) if $<wantarray>;
}
else {
$qast := QAST::Regex.new( $qast, :name($name),
Expand Down
1 change: 1 addition & 0 deletions src/QRegex/P6Regex/Grammar.nqp
Expand Up @@ -316,6 +316,7 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {

token metachar:sym<var> {
[
| $<wantarray>=['@'] '<' $<name>=[<-[>]>+] '>'
| '$<' $<name>=[<-[>]>+] '>'
| '$' $<pos>=[\d+]
]
Expand Down

0 comments on commit ada83f2

Please sign in to comment.