• edited by
634 views
3 3 votes

Consider the following attributed grammar
\[
\begin{array}{l}
\mathrm{S} \rightarrow \mathrm{ABCT}\left\{\mathrm{x}=5^{*} \mathrm{x}+1 ;\right\} \\
\mathrm{T} \rightarrow \mathrm{a}\left\{\mathrm{x}=4^{*} \mathrm{x}+1 ;\right\} \\
\mathrm{C} \rightarrow \mathrm{bb}\left\{\mathrm{x}=3^{*} \mathrm{x}-3 ;\right\} \\
\mathrm{B} \rightarrow \mathrm{Be}\left\{\mathrm{x}=2^{*} \mathrm{x}+1 ;\right\} \\
\mathrm{B} \rightarrow \mathrm{e}\{\mathrm{x}=\mathrm{x}+1 ;\} \\
\mathrm{A} \rightarrow \mathrm{gBd}\left\{\mathrm{x}=5^{*} \mathrm{x}-1 ;\right\}
\end{array}
\]

All semantic actions update the same global variable $x$ Assume $x$ initialized before parsing to zero. What is the final value of x in bottom up parse of following $\mathrm{i} / \mathrm{p}$ string gedeebba?

1 Answer

Answer:
Position:
Show:

Related questions

1 1 vote
1 answers 1 answer
1.9k
1.9k views
KISHALAY DAS asked Nov 14, 2016
1,854 views
Consider the following grammar:\[\begin{array}{l}\mathrm{S} \rightarrow \mathrm{~S}_{1}+\mathrm{E} \quad\left\{\mathrm{~S} . \mathrm{val}=\mathrm{S}_{1}, \text { val }+ \...
1 1 vote
1 1 answer
1.4k
1.4k views
worst_engineer asked Jan 5, 2016
1,443 views
The way I solved it was :is this correct evaluation order ?Because in the answer they have mentioned different order :Consider the SDTS for the ambiguous grammar\[\begin{...
0 0 votes
0 0 answers
1.2k
1.2k views
sidlewis asked Sep 2, 2018
1,176 views
Write semantic rules for the grammar below to compute the Boolean attribute A. evenx, which is true iff the sentence parsed has an even number of $x$ 's.\[\begin{array}{c...
1 1 vote
1 1 answer
889
889 views
Abhishek Kumar Singh asked Dec 31, 2017
889 views
Consider the following translation scheme :\[\begin{array}{l}\mathrm{S} \rightarrow \mathrm{FER} \\\mathrm{R} \rightarrow * \mathrm{E} \text { \{Print ( '); \} R/E } \\\m...