File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -192,10 +192,21 @@ Is the same as:
192
192
193
193
token entry { <key> <.ws> ’=’ <.ws> <value> <.ws> } # . = non-capturing
194
194
195
- The default C < ws > matches "whitespace", such a sequence of spaces (of whatever
196
- type), newlines, unspaces, or heredocs.
197
-
198
- It's perfectly fine to provide your own C < ws > token:
195
+ The default C < ws > matches one or more whitespace characters (C < \s > ) or a
196
+ word boundary (C « <|w> » ):
197
+
198
+ # First <.ws> matches word boundary at the start of the line
199
+ # and second <.ws> matches the whitespace between 'b' and 'c'
200
+ say 'ab c' ~~ /<.ws> ab <.ws> c / # OUTPUT: «「ab c」»
201
+
202
+ # Failed match: there neither any whitespace nor a word
203
+ # boundary between 'a' and 'b'
204
+ say 'ab' ~~ /. <.ws> b/ # OUTPUT: «Nil»
205
+
206
+ # Successful match: there is a word boundary between ')' and 'b'
207
+ say ')b' ~~ /. <.ws> b/ # OUTPUT: «「)b」»
208
+
209
+ You can also redefine the default C < ws > token:
199
210
200
211
grammar Foo {
201
212
rule TOP { \d \d }
You can’t perform that action at this time.
0 commit comments