Skip to content

Commit

Permalink
Add note on binding power of numeric quantifiers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
414owen committed Jan 21, 2025
1 parent 08c9193 commit e8aab9e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ Each item is one of:
* `item ~ n` - Exactly *n* instances of item
* `item ~ n..m` - Between *n* to *m* instances of item (not recommended for wide ranges, due to performance issues)
Despite `~ n` being written with spaces, its binding power is the same as that of other operators,
for instance `a b ~ 3` parses as `a (b ~ 4)`, and `a ~ 2 b ~ 3` is parsed as `(a ~ 2) (b ~ 3)`.
**Examples:**
```perl
hello_world: "hello" "world"
Expand Down

0 comments on commit e8aab9e

Please sign in to comment.