Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Parse _ in ** quantifier values.
Also sneak in a decent NYI error for the ** {...} case.
  • Loading branch information
jnthn committed Sep 25, 2013
1 parent 3898d17 commit a47a76b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/QRegex/P6Regex/Actions.nqp
Expand Up @@ -129,7 +129,7 @@ class QRegex::P6Regex::Actions is HLL::Actions {
my $qast;
$qast := QAST::Regex.new( :rxtype<quant>, :min(+$<min>), :max(-1), :node($/) );
if ! $<max> { $qast.max(+$<min>) }
elsif $<max>[0] ne '*' { $qast.max(+$<max>[0]); }
elsif $<max> ne '*' { $qast.max(+$<max>); }
make backmod($qast, $<backmod>);
}

Expand Down
24 changes: 14 additions & 10 deletions src/QRegex/P6Regex/Grammar.nqp
Expand Up @@ -170,16 +170,20 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
token quantifier:sym<**> {
<sym> <normspace>**0..1 <backmod> <normspace>**0..1
[
|| $<min>=[\d+]
[ '..'
$<max>=[
|| \d+
|| '*'
|| \-\d+ <.panic: "Negative numbers are not allowed as range quantifier endpoint">
|| <.panic: "Only integers or '*' allowed as range quantifier endpoint">
]
]**0..1
|| \-\d+ <.panic: "Negative numbers are not allowed as quantifiers">
| <.decint> \s+ '..' <.panic: "Spaces not allowed in bare range">
| <min=.decint>
[ '..'
[
| <max=.decint> {
$/.CURSOR.panic("Negative numbers are not allowed as quantifiers") if $<max>.Str < 0;
$/.CURSOR.panic("Empty range") if $<min>.Str > $<max>.Str;
}
| $<max>=['*']
| <.panic: "Malformed range">
]
]?
{ $/.CURSOR.panic("Negative numbers are not allowed as quantifiers") if $<min>.Str < 0 }
| <?[{]> { $/.CURSOR.panic("Block case of ** quantifier not yet implemented") }
]
}

Expand Down

0 comments on commit a47a76b

Please sign in to comment.