Machine-translated by Google. Questions are authored in English.
Top

Syntax Directed Translation Questions and Answers

Answer: C

A definition states dependencies, not sequence. Once side effects are introduced the sequence matters, which is exactly the point at which a translation scheme becomes necessary. A definition alone leaves too much about the sequence unstated.

Please log in or register to report this question.

Answer: D

The first three are ordinary attributes attached to tree nodes. The state count is a property of the parser itself and has no bearing on any particular node of any particular tree. Confusing properties of the parser with properties of the translation is a common slip.

Please log in or register to report this question.

53.

Which of the following is NOT a class of syntax directed definition?

Answer: A

Correct answer: LR-attributed as defined by the parser class

The recognised classes are defined by the direction and dependency of the attributes, not by the parser: S-attributed, L-attributed, and circular for those that cannot be evaluated at all. There is no class named after LR parsing, and naming one after a parser would confuse the definition with its implementation.

Please log in or register to report this question.

Answer: B

A nonterminal in a type checker might carry a type, a place and a code fragment simultaneously. The classification into S or L attributed depends on all of them together. A single inherited attribute anywhere takes the whole definition out of the S class.

Please log in or register to report this question.

Answer: C

Correct answer: may carry a synthesised attribute supplied by the scanner

A terminal has no children, so nothing can be synthesised from below - but the scanner supplies its value, which is treated as a synthesised attribute of the leaf. The numeric value of a constant and the name of an identifier both reach the translation this way.

Please log in or register to report this question.

56.

Assertion (A): Terminals in a syntax directed definition have synthesised attributes but never inherited ones.
Reason (R): A terminal has no children and its value is supplied by the lexical analyser rather than computed by any rule.

Answer: D

Correct answer: Both A and R are true, and R is the correct explanation of A

Both are true and the reason gives the mechanism. A terminal is a leaf, so there is nothing below it to inherit from and nothing to synthesise from either - its value simply arrives from the lexical analyser and is treated as synthesised. Inherited attributes would require a rule computing them, and no production has a terminal on its left.

Please log in or register to report this question.

Answer: A

With no parent there is nothing to inherit from. Any global information the translation needs is supplied as an initial value or held in a structure such as the symbol table instead. The symbol table is the usual home for anything genuinely global.

Please log in or register to report this question.

Answer: B

Actions at the end can only use values already computed, which means only synthesised attributes. This is exactly the postfix translation scheme that a bottom up parser implements naturally. Anything more elaborate requires markers or an explicit tree.

Please log in or register to report this question.

Answer: C

The name refers to the position of the actions, not to any notation. Such schemes are exactly those a shift reduce parser can execute without any additional machinery. Any action placed elsewhere forces a marker nonterminal into the grammar.

Please log in or register to report this question.

Answer: D

Each rule concatenates the postfix strings of its operands and appends the operator. The grammar's own structure supplies the precedence, so no extra attributes are needed. The example is the standard first illustration of an S-attributed definition.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Syntax Directed Translation Questions and Answers || Syntax Directed Translation MCQ Questions and Answers || Syntax Directed Translation GK Questions and Answers || Syntax Directed Translation GK MCQ Questions || Syntax Directed Translation Multiple Choice Questions and Answers || Syntax Directed Translation GK || GK on Syntax Directed Translation || Compiler Design Questions and Answers || Compiler Design MCQ Questions and Answers || Compiler Design GK Questions and Answers || GK on Compiler Design