331 views
2 2 votes

Consider the following syntax-directed translation scheme (SDTS) where $S$ is the start symbol:

$$
\begin{aligned}
& S \rightarrow E\{\text { print }(\text { E.val })\} \\
& E \rightarrow E_1+T\left\{\text { E.val }=E_1 . \text { val } \times T . \text { val }\right\} \\
& E \rightarrow T\{\text { E.val }=T . \text { val }\} \\
& T \rightarrow T_1 * F\left\{T . \text { val }=T_1 . \text { val }+F . \text { val }\right\} \\
& T \rightarrow F\{T . \text { val }=F . \text { val }\} \\
& F \rightarrow \text { id }\{F . \text { val }=\text { id.lexval }\}
\end{aligned}
$$

What is the output printed by the SDTS for the input expression: $2+3 \star 5$ ?

  1. $17$
     
  2. $16$
     
  3. $40$
     
  4. $25$

3 Answers

0 0 votes

Answer:
Position:
Show:

Related questions

2 2 votes
2 2 answers
284
284 views
GO Classes asked Jan 31
284 views
Consider the following L-attributed Syntax Directed Definition (SDD). $S$ is the start symbol, and S.val is a synthesized attribute. A.inh is an inherited attribute.$S \r...
1 1 vote
2 2 answers
363
363 views
GO Classes asked Jan 31
363 views
A lexical analyzer for a specific language identifies tokens using the following regular expressions:$$\begin{aligned}& L_1: a(a \mid b)^* \\& L_2: a b(a \mid b)^* \\& L_...
1 1 vote
1 1 answer
288
288 views
GO Classes asked Jan 31
288 views
Consider the following basic block of intermediate code:1. a = 10 2. b = a + 5 3. c = b * 2 4. a = c - b 5. d = a + bAssuming that only the variable $\verb|d|$ is "live" ...
1 1 vote
1 1 answer
260
260 views
GO Classes asked Jan 31
260 views
In the context of Code Optimization, consider the following code segment inside a loop:for (i = 0; i < n; i++) { x = y + z; a[i] = 2 * i + x; }Moving the statemen...