Skip to content

Commit e8aab9e

Browse files
committed
Add note on binding power of numeric quantifiers
I found this part of the syntax non-obvious, because `~` could conceivably have a lower binding power than sequences, so I added an example to the docs.
1 parent 08c9193 commit e8aab9e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

docs/grammar.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ Each item is one of:
239239
* `item ~ n` - Exactly *n* instances of item
240240
* `item ~ n..m` - Between *n* to *m* instances of item (not recommended for wide ranges, due to performance issues)
241241
242+
Despite `~ n` being written with spaces, its binding power is the same as that of other operators,
243+
for instance `a b ~ 3` parses as `a (b ~ 4)`, and `a ~ 2 b ~ 3` is parsed as `(a ~ 2) (b ~ 3)`.
244+
242245
**Examples:**
243246
```perl
244247
hello_world: "hello" "world"

0 commit comments

Comments
 (0)