2 votes 2 votes Given the following expressions of a grammar $E \rightarrow E * F / F + E / F$ $F \rightarrow F – F / id$ Which of the following is true? $*$ has the higher precedence than + - has the higher precedence than $*$ + and – have same precedence + has the higher precedence than $*$ Compiler Design ugcnetcse-dec2012-paper2 compiler-design parsing + – go_editor asked Jul 8, 2016 go_editor 2.0k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 4 votes 4 votes B. - has the higher precedence than * to check the precedence check the level in which the operator occurs. lower the level higher the priority and vice versa as - is lower than *,- has higher priority than * Roshan Sahu answered Jul 8, 2016 • selected Aug 19, 2016 by Sankaranarayanan P.N Roshan Sahu comment Share Follow See all 0 reply Please log in or register to add a comment.
3 votes 3 votes * and + both have same precedence .- has greater precedence than + and *. Option B is Correct. ManojK answered Apr 25, 2016 ManojK comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes Operator which is near the leaf gets the highest precedence . Precedence in a grammar is enforced by making sure that a production rule with higher precedence operator will never produce an expression with operator with lower precedence. In the given grammar ‘-’ has higher precedence than ‘*’ Pranay Datta 1 answered Jun 23, 2015 Pranay Datta 1 comment Share Follow See all 6 Comments See all 6 6 Comments reply Show 3 previous comments Pranay Datta 1 commented Jun 23, 2015 reply Follow Share id-id + id*id = ( (id-id) + (id*id) ) it is like if you see "-" then this have to evaluate 1st . but * , + can evaluated parallely if their is no clash 0 votes 0 votes Shimpy Goyal commented Jun 24, 2015 reply Follow Share by this diagram u want to say here also - evaluate first then rhs bcz level at whci - is evaluated in rhs at time e valuae tht f then id ryt so - higher then * ryt ?? 0 votes 0 votes Pranay Datta 1 commented Jun 24, 2015 reply Follow Share It`s like this , for example arithmetic precedence (/) = (*) > (+) = (-) now 25*2+14-6+8/7 now 1st / then * then - + . but if you notice - operation can perform parallely (25*2)+(14-6)+(8/7) but in case of 25*2-6 * will be evaluated 1st (25*2)-6 same goes for this where precedence (-) > (*) = (+) 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes Here '*' and '+' have same precedence and '-' has higher precedence than '*' and '+'. Ans- B. vijaycs answered Jul 8, 2016 vijaycs comment Share Follow See 1 comment See all 1 1 comment reply cse23 commented Jul 8, 2016 reply Follow Share answer is (B) operator closer to leaf during parsing has higher precedence than operator closer to start symbol 0 votes 0 votes Please log in or register to add a comment.