Permalink
Fetching contributors…
Cannot retrieve contributors at this time
21 lines (12 sloc) 432 Bytes

Backtracking

Unlike in regular expressions, there is no backtracking in PEG.js expressions.

For example, using the input "hi!":


// 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.