Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

throwing warning from method to support typed exceptions

  • Loading branch information...
commit bc22f6bae3bc347bf86e98ea7677d6217f2d7a5b 1 parent d0f9fec
Tobias Leich FROGGS authored
Showing with 6 additions and 5 deletions.
  1. +6 −5 src/QRegex/P6Regex/Grammar.nqp
11 src/QRegex/P6Regex/Grammar.nqp
View
@@ -44,6 +44,10 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
~ ~$when ~ ' please use ' ~ ~$new);
}
+ method throw_unrecognized_metachar ($char) {
+ self.panic('Unrecognized regex metacharacter ' ~ $char ~ ' (must be quoted to match literally)');
+ }
+
token ws { [ \s+ | '#' \N* ]* }
token normspace { <?before \s | '#' > <.ws> }
@@ -78,7 +82,7 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
[
|| <?infixstopper>
|| $$ <.panic: "Regex not terminated">
- || (\W) { $/.CURSOR.panic("Unrecognized regex metacharacter " ~ $/[0].Str ~ " (must be quoted to match literally)") }
+ || (\W) { self.throw_unrecognized_metachar: ~$/[0] }
|| <.panic: "Regex not terminated">
]
}
@@ -116,10 +120,7 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
token termish {
|| <noun=.quantified_atom>+
- || (\W) {
- my $char := ~$/[0];
- $/.CURSOR.panic("Unrecognized regex metacharacter $char (must be quoted to match literally)")
- }
+ || (\W) { self.throw_unrecognized_metachar: ~$/[0] }
}
token quantified_atom {
Please sign in to comment.
Something went wrong with that request. Please try again.