Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
X::Syntax::Regex::Adverb
  • Loading branch information
moritz committed Feb 24, 2012
1 parent 8ee2aa3 commit 867f9d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Perl6/Actions.pm
Expand Up @@ -3945,7 +3945,7 @@ class Perl6::Actions is HLL::Actions {

method quote:sym<rx>($/) {
my $block := PAST::Block.new(PAST::Stmts.new, PAST::Stmts.new, :node($/));
self.handle_and_check_adverbs($/, %SHARED_ALLOWED_ADVERBS, 'm', $block);
self.handle_and_check_adverbs($/, %SHARED_ALLOWED_ADVERBS, 'rx', $block);
my $coderef := regex_coderef($/, $<p6regex>.ast, 'anon', '', [], $block, :use_outer_match(1));
make block_closure($coderef);
}
Expand Down Expand Up @@ -3978,7 +3978,10 @@ class Perl6::Actions is HLL::Actions {
for $<rx_adverbs>.ast {
$multiple := 1 if %MATCH_ADVERBS_MULTIPLE{$_.named};
unless %SHARED_ALLOWED_ADVERBS{$_.named} || %adverbs{$_.named} {
$/.CURSOR.panic("Adverb '" ~ $_.named ~ "' not allowed on " ~ $what);
$*W.throw($/, 'X::Syntax::Regex::Adverb',
adverb => $_.named,
construct => $what,
);
}
if $past {
$past.push($_);
Expand Down
6 changes: 6 additions & 0 deletions src/core/Exceptions.pm
Expand Up @@ -280,6 +280,12 @@ my class X::Syntax::Number::RadixOutOfRange does X::Syntax {
method mesage() { "Radix $.radix out of range (allowed: 2..36)" }
}

my class X::Syntax::Regex::Adverb does X::Syntax {
has $.adverb;
has $.construct;
method message() { "Adverb $.adverb not allowed on $.construct" }
}

my class X::Attribute::Package does X::Comp {
has $.package-type;
method message() { "A $.package-type cannot have attributes" }
Expand Down

0 comments on commit 867f9d5

Please sign in to comment.