Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rearranging for #1729
  • Loading branch information
JJ committed Jun 1, 2019
1 parent 2d276d1 commit bbe06be
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions doc/Language/grammars.pod6
Expand Up @@ -207,16 +207,6 @@ methods.
X<|ws>
=head3 C<ws>
When C<rule> instead of C<token> is used, any whitespace after terms and closing
parenthesis/brackets is turned into a non-capturing call to C<ws>,
written as C«<.ws>» where C<.> means non-capturing. That is to say:
rule entry { <key> '=' <value> }
Is the same as:
token entry { <key> <.ws> '=' <.ws> <value> <.ws> }
The default C<ws> matches zero or more whitespace characters, as long as that
point is not within a word (in code form, that's C«regex ws { <!ww> \s* }»):
Expand All @@ -231,6 +221,20 @@ point is not within a word (in code form, that's C«regex ws { <!ww> \s* }»):
# Successful match: there is a word boundary between ')' and 'b'
say ')b' ~~ /. <.ws> b/; # OUTPUT: «「)b」␤»
Please bear in mind that we're preceding C<ws> with a dot to avoid capturing,
which we are not interested in. Since in general whitespace is a separator, this
is how it's mostly found.
When C<rule> instead of C<token> is used, any whitespace after terms and closing
parenthesis/brackets is turned into a non-capturing call to C<ws>,
written as C«<.ws>» where C<.> means non-capturing. That is to say:
rule entry { <key> '=' <value> }
Is the same as:
token entry { <key> <.ws> '=' <.ws> <value> <.ws> }
You can also redefine the default C<ws> token:
grammar Foo {
Expand Down

0 comments on commit bbe06be

Please sign in to comment.