Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Refactor regex creation a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Nov 22, 2009
1 parent 9f7db2e commit da4d6f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
14 changes: 2 additions & 12 deletions src/NQP/Actions.pm
Expand Up @@ -440,19 +440,9 @@ method regex_declarator($/, $key?) {
);
}
else {
my $rpast := $<p6regex>.ast;
my %capnames := Regex::P6Regex::Actions::capnames($rpast, 0);
%capnames{''} := 0;
$rpast := PAST::Regex.new(
$rpast,
PAST::Regex.new( :pasttype('pass') ),
:pasttype('concat'),
:capnames(%capnames)
);
$past := @BLOCK.shift;
$past.blocktype('method');
$past :=
Regex::P6Regex::Actions::buildsub($<p6regex>.ast, @BLOCK.shift);
$past.name($name);
$past.push($rpast);
@MODIFIERS.shift;
}
make $past;
Expand Down
6 changes: 4 additions & 2 deletions src/Regex/P6Regex/Actions.pm
Expand Up @@ -472,7 +472,7 @@ method mod_internal($/) {
make 0;
}

sub buildsub($rpast) {
sub buildsub($rpast, $block = PAST::Block.new() ) {
my %capnames := capnames($rpast, 0);
%capnames{''} := 0;
$rpast := PAST::Regex.new(
Expand All @@ -482,7 +482,9 @@ sub buildsub($rpast) {
:pasttype('concat'),
:capnames(%capnames)
);
PAST::Block.new( $rpast, :blocktype('method'));
$block.push($rpast);
$block.blocktype('method');
$block;
}

sub capnames($ast, $count) {
Expand Down

0 comments on commit da4d6f4

Please sign in to comment.