3 ms·
> Is there a mechanism that works well for improving errors in PEGs (i.e. something like a non-returnable node) Yes, it's called the "cut operator". > how doe
by drothlis 5y ago
> Is there a mechanism that works well for improving errors in PEGs (i.e. something like a non-returnable node)
Yes, it's called the "cut operator".
> how does one practically implement that?
Pick a parser generator that supports it natively. ;-) If you're talking about implementing the parser generator yourself then you probably already know more about it than I do.
- bmh 5y agoThanks! I see the <cut> operator is actually explained in an older HN post: https://news.ycombinator.com/item?id=20502032 https://news.ycombinator.com/item?id=20502032
- vidarh 5y agoIt's fascinating how many times the Prolog cut operator has been borrowed into parsing. It shouldn't be surprising, probably, given how easily lookahead leads people down the path of some backtracking mechanism or other for ease of implementation, and how ingrained the idea of a cut to stop backtracking is if you've ever been exposed to Prolog...