Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
enable runtime adverbs or m//, enable checks for valid adverbs
  • Loading branch information
moritz committed Jul 24, 2011
1 parent c15a26e commit 5ee5857
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
24 changes: 16 additions & 8 deletions src/Perl6/Actions.pm
Expand Up @@ -2850,18 +2850,18 @@ class Perl6::Actions is HLL::Actions {
our %MATCH_ALLOWED_ADVERBS;
INIT {
my $mods := 'i ignorecase s sigspace r ratchet';
for pir::split__PSS(' ', $mods) {
for nqp::split(' ', $mods) {
%SHARED_ALLOWED_ADVERBS{$_} := 1;
}

$mods := 'g global ii samecase x c continue p pos nth th st nd rd';
for pir::split__PSS(' ', $mods) {
for nqp::split(' ', $mods) {
%SUBST_ALLOWED_ADVERBS{$_} := 1;
}

# TODO: add g global ov overlap once they actually work
$mods := 'x c continue p pos nth th st nd rd';
for pir::split__PSS(' ', $mods) {
for nqp::split(' ', $mods) {
%MATCH_ALLOWED_ADVERBS{$_} := 1;
}
}
Expand Down Expand Up @@ -2889,6 +2889,14 @@ class Perl6::Actions is HLL::Actions {
make $*value;
}

method rx_adverbs($/) {
my @pairs;
for $<quotepair> {
nqp::push(@pairs, $_.ast);
}
make @pairs;
}

method setup_quotepair($/) {
my %h;
my $key := $*ADVERB.ast.named;
Expand Down Expand Up @@ -2954,20 +2962,20 @@ class Perl6::Actions is HLL::Actions {
PAST::Var.new( :name('$_'), :scope('lexical_6model') ),
block_closure($coderef)
);
# self.handle_and_check_adverbs($/, %MATCH_ALLOWED_ADVERBS, 'm', $past);
self.handle_and_check_adverbs($/, %MATCH_ALLOWED_ADVERBS, 'm', $past);
make PAST::Op.new( :pasttype('bind_6model'),
PAST::Var.new(:name('$/'), :scope('lexical_6model')),
$past
);
}

method handle_and_check_adverbs($/, %adverbs, $what, $past?) {
for $<quotepair> {
unless %SHARED_ALLOWED_ADVERBS{$_.ast.named} || %adverbs{$_.ast.named} {
$/.CURSOR.panic("Adverb '" ~ $_.ast.named ~ "' not allowed on " ~ $what);
for $<rx_adverbs>.ast {
unless %SHARED_ALLOWED_ADVERBS{$_.named} || %adverbs{$_.named} {
$/.CURSOR.panic("Adverb '" ~ $_.named ~ "' not allowed on " ~ $what);
}
if $past {
$past.push($_.ast);
$past.push($_);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion t/spectest.data
Expand Up @@ -282,7 +282,7 @@ S05-modifier/overlapping.t
# S05-modifier/pos.t
# S05-modifier/repetition.t # needs regex
# S05-modifier/sigspace.t # needs regex
# S05-substitution/match.t # needs regex
S05-substitution/match.t
# S05-substitution/subst.t # needs regex
# S05-transliteration/trans.t # needs regex
# S05-transliteration/with-closure.t # needs regex
Expand Down

0 comments on commit 5ee5857

Please sign in to comment.