You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
432 B
Markdown
21 lines
432 B
Markdown
7 years ago
|
### Backtracking
|
||
|
|
||
|
Unlike in regular expressions, there is no backtracking in PEG.js expressions.
|
||
|
|
||
|
For example, using the input "hi!":
|
||
|
|
||
|
```pegjs
|
||
|
|
||
|
// This will fail
|
||
|
HI = "hi" / "hi!"
|
||
|
|
||
|
// This will pass
|
||
|
HI = "hi!" / "hi"
|
||
|
|
||
|
// This will also pass
|
||
|
HI = w:"hi" !"!" { return w } / "hi!"
|
||
|
|
||
|
```
|
||
|
|
||
|
For more information on backtracking in PEG.js, [checkout this excellent answer on Stack Overflow](https://stackoverflow.com/a/24809596/1518408).
|