Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
enable regex special characters as delimiters
Special chars like quantifiers or control characters can be used
as delimiters. If they are used as delims they cant be used for
their original meaning, of course.
  • Loading branch information
FROGGS committed May 17, 2013
1 parent cb2aa86 commit c3cdeb6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/QRegex/P5Regex/Grammar.nqp
Expand Up @@ -69,7 +69,7 @@ grammar QRegex::P5Regex::Grammar is HLL::Grammar {
<![|)]>
<!rxstopper>
<atom>
[ <.ws> <quantifier=p5quantifier> ]**0..1
[ <.ws> <!before <rxstopper> > <quantifier=p5quantifier> ]**0..1
<.ws>
}

Expand Down
9 changes: 5 additions & 4 deletions src/QRegex/P6Regex/Grammar.nqp
Expand Up @@ -125,12 +125,12 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {

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

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

token termish {
Expand All @@ -140,9 +140,10 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
}

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

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

0 comments on commit c3cdeb6

Please sign in to comment.