Consider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (SDT) actions, given as pseudo-code:
P → D* E*
D → int ID {record that ID.lexeme is of type int}
D → bool ID { record that ID.lexeme is of type bool}
E → E1 + E2 {check that E1.type = E2.type = int; set E.type := int}
E → !E1 {check that E1.type = bool; set E.type := bool}
E → ID {set E.type := int}
With respect to the above grammar; which one of the following choices is correct?
Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let $X_1, X_2, X_3, X_4, X_5$, and $X_6$ be the placeholders for the nonterminals $\mathrm{D}, \mathrm{T}, \mathrm{L}$ or $\mathrm{L}_1$ in the following table :
Production rule | Semantic action |
---|---|
D → T L | X1.type = X2.type |
T → int | T.type = int |
T → float | T.type = float |
L → L1, id |
X3.type = X4.type addType(id.entry, X5.type) |
L → id | addType(id.entry, X6.type) |
Which one of the following are the appropriate choices for $X_1, X_2, X_3$ and $X_4$ ?
$$S \to aA$$ $$\,\,\,\,\,$${ print $$1$$ }
$$S \to a$$ $$\,\,\,\,$$$$\,\,\,\,\,$${ print $$2$$ }
$$A \to Sb$$ $$\,\,\,\,\,$${ print $$3$$ }
Using the above $$SDTS,$$ the output printed by a bottom-up parser, for the input $$aab$$ is:
Consider the basic block given below.
a = b + c
c = a + d
d = b + c
e = d - b
a = e + b
The minimum number of nodes and edges present in the DAG representation of the above basic block respectively are