File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -44,10 +44,17 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
44
44
~ ~ $ when ~ ' please use ' ~ ~ $ new );
45
45
}
46
46
47
+ # errors are reported through methods, so that subclasses like Rakudo's
48
+ # Perl6::RegexGrammar can override them, and throw language-specific
49
+ # exceptions
47
50
method throw_unrecognized_metachar ($ char ) {
48
51
self . panic(' Unrecognized regex metacharacter ' ~ $ char ~ ' (must be quoted to match literally)' );
49
52
}
50
53
54
+ method throw_null_pattern () {
55
+ self . panic(' Null regex not allowed' );
56
+ }
57
+
51
58
token ws { [ \s + | '#' \N * ]* }
52
59
53
60
token normspace { <? before \s | '#' > <.ws > }
@@ -100,22 +107,22 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
100
107
101
108
token termaltseq {
102
109
<termconjseq >
103
- [ '||' [ <termconjseq > || <.panic : 'Null pattern not allowed' > ] ]*
110
+ [ '||' [ <termconjseq > || <.throw_null_pattern > ] ]*
104
111
}
105
112
106
113
token termconjseq {
107
114
<termalt >
108
- [ '&&' [ <termalt > || <.panic : 'Null pattern not allowed' > ] ]*
115
+ [ '&&' [ <termalt > || <.throw_null_pattern > ] ]*
109
116
}
110
117
111
118
token termalt {
112
119
<termconj >
113
- [ '|' <![ | ] > [ <termconj > || <.panic : 'Null pattern not allowed' > ] ]*
120
+ [ '|' <![ | ] > [ <termconj > || <.throw_null_pattern > ] ]*
114
121
}
115
122
116
123
token termconj {
117
124
<termish >
118
- [ '&' <![ & ] > [ <termish > || <.panic : 'Null pattern not allowed' > ] ]*
125
+ [ '&' <![ & ] > [ <termish > || <.throw_null_pattern > ] ]*
119
126
}
120
127
121
128
token termish {
You can’t perform that action at this time.
0 commit comments