Skip to content

Commit

Permalink
docs: add note on regex anchoring
Browse files Browse the repository at this point in the history
refs #8 #9
  • Loading branch information
igordejanovic committed Mar 10, 2024
1 parent 329d37b commit c1ae41e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/src/grammar_language.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ write and they don't add to readability so it is always better to reference
regex terminal by name in grammar rules.
```

```admonish warning
During regex construction a `^` prefix is added to the regex from the grammar to
make sure that the content is matched at the current input position. This can be
an issue if you use a pattern like `A|B` in your regex as it translates to
`^A|B` which matches either `A` at the current position or `B` in the rest of
the input. So, the workaround for now is to use `(A|B)`, i.e. always wrap
alternative choices in parentheses.
```


## Usual patterns
This section explains how some common grammar patterns can be written using just
Expand Down

0 comments on commit c1ae41e

Please sign in to comment.