Skip to content

Commit

Permalink
Some <before...> simplification in P6Regex grammar
Browse files Browse the repository at this point in the history
There's a few other places we could in theory do it, but they break
tests, it seems. This one is the big win, anyway.
  • Loading branch information
jnthn committed Sep 29, 2013
1 parent 7c9689a commit 52a81c0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/QRegex/P6Regex/Grammar.nqp
Expand Up @@ -57,7 +57,7 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {

token ws { [ \s+ | '#' \N* ]* }

token normspace { <?before \s | '#' > <.ws> }
token normspace { <?[\s#]> <.ws> }

token identifier { <.ident> [ <[\-']> <.ident> ]* }

Expand Down Expand Up @@ -107,7 +107,7 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
[
| <?before <[\) \} \]]> >
| <?before '>' <-[>]> >
| <?before <rxstopper> >
| <?rxstopper>
]
}

Expand All @@ -125,12 +125,12 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {

token termalt {
<termconj>
[ <!before <rxstopper> > '|' <![|]> [ { $*SEQ := 0; } <termconj> || <.throw_null_pattern> ] ]*
[ <!rxstopper> '|' <![|]> [ { $*SEQ := 0; } <termconj> || <.throw_null_pattern> ] ]*
}

token termconj {
<termish>
[ <!before <rxstopper> > '&' <![&]> [ { $*SEQ := 0; } <termish> || <.throw_null_pattern> ] ]*
[ <!rxstopper> '&' <![&]> [ { $*SEQ := 0; } <termish> || <.throw_null_pattern> ] ]*
}

token termish {
Expand All @@ -143,7 +143,7 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
<!rxstopper>
<atom>
[
<.ws> [ <!before <rxstopper> > <quantifier> | <?before ':'> <backmod> <!alpha> ]
<.ws> [ <!rxstopper> <quantifier> | <?before ':'> <backmod> <!alpha> ]
[ <.ws> <separator> ]**0..1
]**0..1
}
Expand Down Expand Up @@ -208,7 +208,7 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
token metachar:sym<bs> { \\ <backslash> }
token metachar:sym<mod> { <mod_internal> }
token metachar:sym<quantifier> {
<!before <rxstopper> > <quantifier> <.panic: 'Quantifier quantifies nothing'>
<!rxstopper> <quantifier> <.panic: 'Quantifier quantifies nothing'>
}

## we cheat here, really should be regex_infix:sym<~>
Expand Down

0 comments on commit 52a81c0

Please sign in to comment.