Skip to content

Commit

Permalink
refacor adverb application and checking into a separate method - it w…
Browse files Browse the repository at this point in the history
…ill be reused for m//, hopefully
  • Loading branch information
moritz committed Jul 30, 2010
1 parent 50e0e7e commit cf9997a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Perl6/Actions.pm
Expand Up @@ -2697,6 +2697,16 @@ INIT {
}
}

method handle_and_check_adverbs($/, %adverbs, $past, $what) {
for $<quotepair> {
pir::printerr__vS("Found adverb " ~ $_.ast.named ~ "\n");
unless %adverbs{$_.ast.named} {
$/.CURSOR.panic("Adverb '" ~ $_.ast.named ~ "' not allowed on " ~ $what);
}
$past.push($_.ast);
}
}

method quote:sym<s>($/) {
# Build the regex.
my $regex_ast := Regex::P6Regex::Actions::buildsub($<p6regex>.ast);
Expand All @@ -2718,12 +2728,7 @@ method quote:sym<s>($/) {
PAST::Var.new( :name('$_'), :scope('lexical') ),
$regex, $closure
);
for $<quotepair> {
unless %SUBST_ALLOWED_ADVERBS{$_.ast.named} {
$/.CURSOR.panic("Adverb '" ~ $_.ast.named ~ "' not allowed on subsitution");
}
$past.push($_.ast);
}
self.handle_and_check_adverbs($/, %SUBST_ALLOWED_ADVERBS, $past, 'substitution');

$past := PAST::Op.new(
:node($/),
Expand Down

0 comments on commit cf9997a

Please sign in to comment.