• edited by
14,079 views
15 15 votes

​Consider the following syntax-directed definition $\text{(SDD)}$.

$$\begin{array}{|l|l|} \hline  \text{$S \rightarrow D H T U$} & \text{$ \left\{S.v a l = D.val + H.val + T.val + U.val;\right\}$} \\ \hline D \rightarrow ^{"} \mathrm{M}^{"} D_1 & \left\{D.val =5+D_{1}.val; \right\} \\ \hline D \rightarrow \epsilon & \left\{D.val = -5; \right\} \\ \hline H \rightarrow ^{"}\mathrm{L}^{"} H_1 & \left\{H.val = 5^{*} 10+H_{1}.v a l;\right\} \\ \hline
H \rightarrow \epsilon &  \left\{H.val = -10; \right\} \\ \hline
T \rightarrow \text {"C" } T_1 & \left\{T.v a l=5^{*} 100+T_{1}. val;\right\} \\ \hline                                            T \rightarrow \epsilon & \left\{T . v a l= - 5;\right\} \\ \hline                                                                                U \rightarrow \text{"K"} & \left\{U . v a l=  5;\right\} \\ \hline \end{array}$$

Given $\text{"MMLK"}$ as the input, which one of the following options is the $\text{CORRECT}$ value computed by the $\text{SDD}$ (in the attribute $S.val$)?

  1. $45$
  2. $50$
  3. $55$
  4. $65$ 

4 Answers

Best answer
29 29 votes

Answer :  45

• selected by
Answer:
Position:
Show:

Related questions

20 20 votes
2 answers 2 answers
12.5k
12.5k views
Arjun asked Feb 16, 2024
12,513 views
Consider the following grammar $G$, with $S$ as the start symbol. The grammar $G$ has three incomplete productions denoted by $(1), (2)$, and $(3)$.$$\begin{aligned} & S ...
14 14 votes
2 2 answers
15.6k
15.6k views
Arjun asked Feb 16, 2024
15,617 views
Consider the following pseudo-code.L 1: t1 = -1 L 2: t2 = 0 L 3: t3 = 0 L 4: t4 = 4 * t3 L 5: t5 = 4 * t2 L 6: t6 = t5 * M L 7: t7 = t4 + t6 L 8: t8 = a[t7] L 9: if t8 <...
31 31 votes
4 4 answers
15.3k
15.3k views
Arjun asked Feb 16, 2024
15,251 views
Let $G=(V, \Sigma, S, P)$ be a context-free grammar in Chomsky Normal Form with $\Sigma=\{a, b, c\}$ and $V$ containing $10$ variable symbols including the start symbol $...
18 18 votes
3 3 answers
14.1k
14.1k views
Arjun asked Feb 16, 2024
14,123 views
Which of the following is/are Bottom-Up Parser(s)?Shift-reduce ParserPredictive ParserLL$(1)$ Parser LR Parser