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) {
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/))>