Skip to content

Commit

Permalink
throwing typed exception for unrecognized metacharacters in regexes
Browse files Browse the repository at this point in the history
bumps NQP revision
  • Loading branch information
FROGGS authored and moritz committed Nov 25, 2012
1 parent 50be5d2 commit 784cb73
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Perl6/Grammar.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3485,8 +3485,12 @@ grammar Perl6::QGrammar is HLL::Grammar does STD {
}

grammar Perl6::RegexGrammar is QRegex::P6Regex::Grammar does STD {
method throw_unrecognized_metachar ($metachar) {
$*W.throw(self.MATCH(), <X Syntax Regex UnrecognizedMetachar>, :$metachar);
}

token rxstopper { <stopper> }

token metachar:sym<:my> {
':' <?before 'my'|'constant'|'state'|'our'> <statement=.LANG('MAIN', 'statement')> <.ws> ';'
}
Expand Down
5 changes: 5 additions & 0 deletions src/core/Exception.pm
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,11 @@ my class X::Syntax::Regex::Adverb does X::Syntax {
method message() { "Adverb $.adverb not allowed on $.construct" }
}

my class X::Syntax::Regex::UnrecognizedMetachar does X::Syntax {
has $.metachar;
method message() { "Unrecognized regex metacharacter $.metachar (must be quoted to match literally)" }
}

my class X::Syntax::Signature::InvocantMarker does X::Syntax {
method message() {
"Can only use : as invocant marker in a signature after the first parameter"
Expand Down
2 changes: 1 addition & 1 deletion tools/build/NQP_REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2012.11
2012.11-1-gbc22f6b

0 comments on commit 784cb73

Please sign in to comment.