edited by
1,124 views
0 0 votes

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}{cl}
A \rightarrow \mathrm{xA}_{1} y & \{?\} \\
\mid \mathrm{z} & \text { \{A.n = 0; A.evenx }=\text { true; }\}
\end{array}
\]

  1. A.evenx $=$ ! ( $\mathrm{A}_{1}$.evenx $)$;
  2. A.n $=\mathrm{A}_{1} \cdot \mathrm{n}+1$; A.evenx $=(\mathrm{A} . \mathrm{n} \% 2==0)$;
  3. Both (A) \& (B)
  4. None

Please log in or register to answer this question.

Position:
Show:

Related questions

1 1 vote
1 1 answer
876
876 views
Abhishek Kumar Singh asked Dec 31, 2017
876 views
Consider the following translation scheme :\[\begin{array}{l}\mathrm{S} \rightarrow \mathrm{FER} \\\mathrm{R} \rightarrow * \mathrm{E} \text { \{Print ( '); \} R/E } \\\m...
1 1 vote
1 answers 1 answer
1.4k
1.4k views
set2018 asked Oct 26, 2017
1,353 views
what is the output produced for the input "pqsqsr" using the top down parsing?Also what is the result if semantic actions are at right not in middleLet ' $G$ ' be a gramm...
3 3 votes
1 answers 1 answer
626
626 views
KISHALAY DAS asked Nov 14, 2016
626 views
Consider the following attributed grammar\[\begin{array}{l}\mathrm{S} \rightarrow \mathrm{ABCT}\left\{\mathrm{x}=5^{*} \mathrm{x}+1 ;\right\} \\\mathrm{T} \rightarrow \ma...
1 1 vote
1 answers 1 answer
1.8k
1.8k views
KISHALAY DAS asked Nov 14, 2016
1,846 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 }+ \...