logoalt Hacker News

stevefan1999today at 1:35 AM1 replyview on HN

As a guy who writes compiler the answer for this is it depends on the type of parser you are using.

LL and LR parser generates different derivation, and as such it is deterministically non-deterministic, hence UB.


Replies

daemintoday at 2:06 AM

But you can still change the parser to output the expression in the AST (or otherwise) so it is evaluated left to right or right to left. Just that doing it in a way that is not natural for the algorithm will require extra code.