retagged by
10,601 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

1 votes
1 votes

Given Grammar is:

E->E*F|F+E|F
F->F-|id


The operators at the lower level has higher precedence than those at the higher levels.

Here, * and + has same precedence, as they are at the same level.
- has higher precedence than * and + as it is in higher level.

So, B is the correct option.

0 votes
0 votes

Both B and D are true.  

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

Answer:

Related questions

41 votes
41 votes
7 answers
1
Kathleen asked Sep 14, 2014
36,422 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,917 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