How to handle operator precedence in LALR(1) parser

61 views Asked by At

I was writing an LALR(1) parser for a simple arithmetic grammar

E -> E ('+' | '-') T
E -> T
T -> T ('*' | '/') F
T -> F
F -> '( E ')'
F -> int

How would I handle operator precedence for an expression such as 1 * 1 + 2 so that the 1+2 is evaluated before the multiplication?

0

There are 0 answers