According to the documentation the default definition of the ws
method in a grammar is to match zero or more whitespace characters, as long as that point is not within a word:
regex ws { <!ww> \s* }
What is the difference between this definition and the following:
regex ws { \s+ }
I wonder why the zero width assertion <!ww>
is used instead of the simpler \s+
? I also note that the default definition allows to match zero white spaces, but when would that actually happen? Wouldn't it be more clear if it used \s+
instead of \s*
?
ws
will match between consecutive characters that are not word characters and not white space (like emojis). For example:perl6 -e 'my $str="\c[carrot]\c[potato]"; say $str.split(/<!ww>\s*/).elems'
gives 4. Is this a reasonable behavior? – Algebraicws
rule. – Foley