edited by
37,111 views
75 votes
75 votes

In a bottom-up evaluation of a syntax directed definition, inherited attributes can

  1. always be evaluated
  2. be evaluated only if the definition is L-attributed
  3. be evaluated only if the definition has synthesized attributes
  4. never be evaluated
edited by

10 Answers

0 votes
0 votes

Answer should be (B)

$(\text{p only if q} )\leftrightarrow (p\rightarrow q)$

so B is, evaluation is possible implies SDD is L-attributed,
which us true. Not all L-attributed SDDs can be evaluated in bottum-up parser but all SDDs which can be evaluated are L-attributed

0 votes
0 votes

In a bottom-up evaluation of a syntax-directed definition, inherited attributes can be evaluated only if the definition is L-attributed.

Explanation:

  1. Always be evaluated:

    • Incorrect. In a bottom-up evaluation, the inherited attributes are evaluated when the corresponding non-terminal is reduced during the bottom-up parsing process. However, this depends on whether the definition is L-attributed.
  2. Be evaluated only if the definition is L-attributed:

    • Correct. L-attributed definitions ensure that the inherited attributes can be evaluated in a bottom-up manner. In L-attributed definitions, attributes associated with the leftmost derivations can be computed bottom-up.
  3. Be evaluated only if the definition has synthesized attributes:

    • Incorrect. Inherited attributes are distinct from synthesized attributes. Both types of attributes can coexist in a syntax-directed definition, and the evaluation of inherited attributes depends on whether the definition is L-attributed.
  4. Never be evaluated:

    • Incorrect. In a syntax-directed definition, inherited attributes are evaluated during the parsing process. However, the ability to evaluate them in a bottom-up manner depends on the characteristics of the definition.
Answer:

Related questions

32 votes
32 votes
4 answers
2
Kathleen asked Sep 17, 2014
8,560 views
Consider the syntax directed definition shown below.$$\begin{array}{ll}S \rightarrow \mathbf{ id :=} E&\qquad \{gen(\mathbf{ id}.place = E.place;);\}\\E \rightarrow E_1 +...
40 votes
40 votes
3 answers
4
Kathleen asked Sep 17, 2014
20,168 views
Consider the grammar shown below. $S \rightarrow C \ C$$C \rightarrow c \ C \mid d$This grammar isLL(1)SLR(1) but not LL(1)LALR(1) but not SLR(1)LR(I) but not LALR(1)