Hacker News new | ask | show | jobs
by drothlis 1584 days 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.

1 comments

Thanks! I see the <cut> operator is actually explained in an older HN post: https://news.ycombinator.com/item?id=20502032
It'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...