Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adds more examples to the definition of ws
Thanks go  @jnthn for his clarification in StackOverflow. Closes #1729
  • Loading branch information
JJ committed Jun 1, 2019
1 parent e89a63b commit c0e9876
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions doc/Language/grammars.pod6
Expand Up @@ -225,9 +225,10 @@ 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:
When C<rule> instead of C<token> is used, C<:sigspace> is enabled by default and
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> }
Expand All @@ -246,6 +247,13 @@ You can also redefine the default C<ws> token:
token ws { \h* }
}.parse: "4 \n\n 5"; # Fails
And even capture it, but you need to use it explicitly:
=for code
grammar Foo { rule TOP {\d <ws> \d} };
my $parsed = Foo.parse: "3 3";
say $parsed<ws>; # OUTPUT: «「」␤»
=head3 X«C<sym>|<sym>»
Expand Down

0 comments on commit c0e9876

Please sign in to comment.