4 ms·
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 a
by danhau 4y ago
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.