Given the following expression grammar: E -> E * F

0

Given the following expression grammar:
E -> E * F | F+E | F
F -> F-F | id
which of the following is true? (GATE CS 2000)
(a) * has higher precedence than +
(b) – has higher precedence than *
(c) + and — have same precedence
(d) + has higher precedence than *

 

Ravi Garg edited question
    0
    Sonali Kapoor (anonymous)

    Answer(b)

    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 ‘*’

    Sonali Kapoor answered
      Add image to editor add image from link

      Question stats

      • Active
      • Views453 times
      • Answers1 answer
      • Followers1 follower
      Question and answer is powered by AnsPress