Skip to content

Commit

Permalink
Correct erroneous info on default <ws> token
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Feb 22, 2017
1 parent 5b1788c commit c206090
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions doc/Language/grammars.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,21 @@ Is the same as:
token entry { <key> <.ws> ’=’ <.ws> <value> <.ws> } # . = non-capturing
The default C<ws> matches "whitespace", such a sequence of spaces (of whatever
type), newlines, unspaces, or heredocs.
It's perfectly fine to provide your own C<ws> token:
The default C<ws> matches one or more whitespace characters (C<\s>) or a
word boundary (C«<|w>»):
# First <.ws> matches word boundary at the start of the line
# and second <.ws> matches the whitespace between 'b' and 'c'
say 'ab c' ~~ /<.ws> ab <.ws> c / # OUTPUT: «「ab c」␤»
# Failed match: there neither any whitespace nor a word
# boundary between 'a' and 'b'
say 'ab' ~~ /. <.ws> b/ # OUTPUT: «Nil␤»
# Successful match: there is a word boundary between ')' and 'b'
say ')b' ~~ /. <.ws> b/ # OUTPUT: «「)b」␤»
You can also redefine the default C<ws> token:
grammar Foo {
rule TOP { \d \d }
Expand Down

0 comments on commit c206090

Please sign in to comment.