Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more awesome error message for unrecognized meta character in regexes
not quite awesome yet, it does not report the actual offending character
  • Loading branch information
moritz committed May 12, 2011
1 parent dcd196e commit d846b25
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Regex/P6Regex/Grammar.pm
Expand Up @@ -32,8 +32,10 @@ grammar Regex::P6Regex::Grammar is HLL::Grammar {
{*} #= open
[ <.ws> ['||'|'|'|'&&'|'&'] ]?
<termconj>
[ ['||'|'|']
[ <termconj> || <.panic: 'Null pattern not allowed'> ]
[
|| ['||'|'|'] [ <termconj>
|| (\W) <.panic: "Unrecognized regex metacharacter (must be quoted to match literally)">
|| <.panic: 'Null pattern not allowed'> ]
]*
}

Expand All @@ -45,7 +47,8 @@ grammar Regex::P6Regex::Grammar is HLL::Grammar {
}

token termish {
<noun=.quantified_atom>+
|| <noun=.quantified_atom>+
|| (\W) <.panic: "Unrecognized regex metacharacter (must be quoted to match literally)">
}

token quantified_atom {
Expand Down

0 comments on commit d846b25

Please sign in to comment.