Re:Pratt Parsers: Expression Parsing Made Easy (2011)
by danybittel on Sunday January 21, 2024 @03:52AM
(#39076787)
I do have an error node, and it helps but it's still difficult.
If I only typed
if (cond &
It creates error nodes for if and &.. but none of them should show yet. (squiggly lines) if (cond & *
Now it should error on the multiply, except if multiply could also be a pointer.
The parser knows the And operator needs two arms. It can complete the missing arm with an error node.
In this way, the conditional expression is parsed to completion without interruption. Multiple errors can be handled with completion and recorded. At the end it's a matter of traversing the AST to print out all the ErrorNodes.