Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Eliminate protoregex cheats for P6Regex, place directly in grammar.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 18, 2009
1 parent 9b7739d commit 2408264
Show file tree
Hide file tree
Showing 4 changed files with 3,987 additions and 3,807 deletions.
9 changes: 5 additions & 4 deletions src/Regex/P6Regex/Grammar.pm
Expand Up @@ -45,7 +45,7 @@ grammar Regex::P6Regex::Grammar;
]
}

# proto token quantifier { <...> }
proto token quantifier { <...> }
token quantifier:sym<*> { $<sym>=['*'] <backmod> }
token quantifier:sym<+> { $<sym>=['+'] <backmod> }
token quantifier:sym<?> { $<sym>=['?'] <backmod> }
Expand All @@ -59,7 +59,7 @@ grammar Regex::P6Regex::Grammar;

token backmod { ':'? [ '?' | '!' | <!before ':'> ] }

# proto token metachar { <...> }
proto token metachar { <...> }
token metachar:sym<ws> { <.normspace> }
token metachar:sym<[ ]> { '[' <nibbler> ']' }
token metachar:sym<( )> { '(' <nibbler> ')' }
Expand Down Expand Up @@ -94,7 +94,7 @@ grammar Regex::P6Regex::Grammar;
[ <.ws> '=' <.ws> <quantified_atom> ]?
}

# proto token backslash { <...> }
proto token backslash { <...> }
token backslash:sym<w> { $<sym>=[<[dswnDSWN]>] }
token backslash:sym<b> { $<sym>=[<[bB]>] }
token backslash:sym<e> { $<sym>=[<[eE]>] }
Expand All @@ -109,7 +109,7 @@ grammar Regex::P6Regex::Grammar;
token backslash:sym<Q> { 'Q' <.obs: '\\Q as quotemeta;quotes or literal variable match'> }
token backslash:sym<misc> { \W }

# proto token assertion { <...> }
proto token assertion { <...> }

token assertion:sym<?> { '?' [ <?before '>' > | <assertion> ] }
token assertion:sym<!> { '!' [ <?before '>' > | <assertion> ] }
Expand Down Expand Up @@ -151,6 +151,7 @@ grammar Regex::P6Regex::Grammar;
]
}

proto token mod_ident { <...> }
token mod_ident:sym<ignorecase> { $<sym>=[i] 'gnorecase'? }
token mod_ident:sym<ratchet> { $<sym>=[r] 'atchet'? }
token mod_ident:sym<sigspace> { $<sym>=[s] 'igspace'? }
30 changes: 0 additions & 30 deletions src/cheats/p6regex-grammar.pir
@@ -1,35 +1,5 @@
.namespace ['Regex';'P6Regex';'Grammar']

.sub 'quantifier' :method
.param pmc action :named('action') :optional
.param pmc dba :named('dba') :optional
.tailcall self.'!protoregex'('quantifier', 'action'=>action)
.end

.sub 'metachar' :method
.param pmc action :named('action') :optional
.param pmc dba :named('dba') :optional
.tailcall self.'!protoregex'('metachar', 'action'=>action)
.end

.sub 'backslash' :method
.param pmc action :named('action') :optional
.param pmc dba :named('dba') :optional
.tailcall self.'!protoregex'('backslash', 'action'=>action)
.end

.sub 'assertion' :method
.param pmc action :named('action') :optional
.param pmc dba :named('dba') :optional
.tailcall self.'!protoregex'('assertion', 'action'=>action)
.end

.sub 'mod_ident' :method
.param pmc action :named('action') :optional
.param pmc dba :named('dba') :optional
.tailcall self.'!protoregex'('mod_ident', 'action'=>action)
.end

.sub 'panic' :method
.param pmc args :slurpy

Expand Down

0 comments on commit 2408264

Please sign in to comment.