I want to have a grammar that is lax in whether whitespace is present or not... I want to match:
this ' <foo> <bar> <baz> '
and also this '<foo><bar><baz>'
This works:
token TOP { \s* <foo> \s* <bar> \s* <baz> \s* }
But after reading all about :sigspace, <.ws> and rule I can imagine that there is a way to do this without the repeated *\s . (viz. How do I match a hex array in per6 grammar)
Please can someone tell me if there is nicer way to do this in a perl6 grammar?
NB. this is not solved by simply changing the token declarator to rule - when I try that approach I end up either matching space or no space (but not both) in the parse string.
<ws>
rule requires a word boundary if there is no whitespace, and if it's not literally "<foo>" that is to be matched, but "something", that could be a problem. So defining your own ws to just be\s*
would do the trick in that case – Allstar