News for hackers. Stuff that matters.
Re:The Packrat Parsing and Parsing Expression Grammars Page by drothlis on Monday February 21, 2022 @08:07AM (#30415473)
> 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.

Re:The Packrat Parsing and Parsing Expression Grammars Page by bmh on Monday February 21, 2022 @08:19AM (#30415570)
Thanks! I see the <cut> operator is actually explained in an older HN post: https://news.ycombinator.com/item?id=20502032
Re:The Packrat Parsing and Parsing Expression Grammars Page by vidarh on Monday February 21, 2022 @05:04PM (#30421230)
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...