News for hackers. Stuff that matters.
Re:Operator precedence by textual substitution by danhau on Monday May 16, 2022 @04:07AM (#31394580)
I also find operator precedence quite easy to implement.

In my parser, when it encounters two binary expressions `a * b + c`, it always initially parses them as `a * (b + c)` into temporary AST nodes. Then it compares the precedence of the operators and, if needed, rewrites the nodes to form the correct expression.

There are no comments on this comment yet.