retagged by
10,595 views
27 votes
27 votes

Given the following expression grammar:

$$\begin{align}
E &\to E * F \mid F + E \mid F \\[1em]
F &\to F - F \mid id
\end{align}$$

Which of the following is true?

  1. $*$ has higher precedence than $+$
  2. $-$ has higher precedence than $*$
  3. $+$ and $-$ have same precedence
  4. $+$ has higher precedence than $*$
retagged by

6 Answers

Best answer
37 votes
37 votes

Correct Option: B

Operator which is at lower level in the grammar is termed to have higher precedence.

edited by
8 votes
8 votes
F->F-E

Operator at lower  level in tree has higher precedence than operator at upper levels

- has higher precedence than  +and *

+  and * have equal precedence
Answer:

Related questions

41 votes
41 votes
7 answers
1
Kathleen asked Sep 14, 2014
36,412 views
The number of tokens in the following C statement isprintf("i=%d, &i=%x", i, &i);$3$$26$$10$$21$
15 votes
15 votes
3 answers
3
Kathleen asked Sep 14, 2014
7,916 views
Consider the syntax directed translation scheme $\textsf{(SDTS)}$ given in the following. Assume attribute evaluation with bottom-up parsing, i.e., attributes are evaluat...
22 votes
22 votes
6 answers
4