Skip to content
This repository
Browse code

throwing warning from method to support typed exceptions

  • Loading branch information...
commit bc22f6bae3bc347bf86e98ea7677d6217f2d7a5b 1 parent d0f9fec
Tobias Leich FROGGS authored

Showing 1 changed file with 6 additions and 5 deletions. Show diff stats Hide diff stats

  1. +6 5 src/QRegex/P6Regex/Grammar.nqp
11 src/QRegex/P6Regex/Grammar.nqp
@@ -44,6 +44,10 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
44 44 ~ ~$when ~ ' please use ' ~ ~$new);
45 45 }
46 46
  47 + method throw_unrecognized_metachar ($char) {
  48 + self.panic('Unrecognized regex metacharacter ' ~ $char ~ ' (must be quoted to match literally)');
  49 + }
  50 +
47 51 token ws { [ \s+ | '#' \N* ]* }
48 52
49 53 token normspace { <?before \s | '#' > <.ws> }
@@ -78,7 +82,7 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
78 82 [
79 83 || <?infixstopper>
80 84 || $$ <.panic: "Regex not terminated">
81   - || (\W) { $/.CURSOR.panic("Unrecognized regex metacharacter " ~ $/[0].Str ~ " (must be quoted to match literally)") }
  85 + || (\W) { self.throw_unrecognized_metachar: ~$/[0] }
82 86 || <.panic: "Regex not terminated">
83 87 ]
84 88 }
@@ -116,10 +120,7 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
116 120
117 121 token termish {
118 122 || <noun=.quantified_atom>+
119   - || (\W) {
120   - my $char := ~$/[0];
121   - $/.CURSOR.panic("Unrecognized regex metacharacter $char (must be quoted to match literally)")
122   - }
  123 + || (\W) { self.throw_unrecognized_metachar: ~$/[0] }
123 124 }
124 125
125 126 token quantified_atom {

0 comments on commit bc22f6b

Please sign in to comment.
Something went wrong with that request. Please try again.