[t/spec] Add tricky tests (which pass after latest Rakudo patch), unfudge old simple...
[pugs.git] / examples / rules / Regexp-Common.pm
blob48f120b3e9bd0290f53fef2dc3725a1f90a4430f
1 grammar Regexp::Common::ws {
2 regex crop { [ ^ \s+ ] | [ \s+ $ ] }
5 grammar Regexp::Common::lingua {
6 regex palindrome (Regex :$chars = /<alpha>/) {
7 <$chars> | [ <$chars> <~~>? $0 ]
8 # XXX not quite certain this is right :-)
12 grammar Regexp::Common::list {
13 regex list (Regex :$pat = /.*? \S/, Str|Regex :$sep = /\s* ',' \s*/, Str|Regex :$lsep = $sep) {
15 [ <$pet> <$sep> ]*
16 <$pat> <$lsep> <$pat>
20 regex conj (Regex :$pat, Str|Regex :$sep, Regex :$word = /and | or/) {
21 <list(:pat($pat) :sep($sep) :lsep(/\s* ','? \s* <$word> \s*/))>
24 regex and (Regex :$pat, Str|Regex :$sep) {
25 <conj(:pat($pat) :sep($sep) :word(/and/))>
28 regex or (Regex :$pat, Str|Regex :$sep) {
29 <conj(:pat($pat) :sep($sep) :word(/or/))>