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

Syntax Directed Translation Questions and Answers

Answer: A

Such a definition is entirely about the order in which output appears, so it must be expressed as a translation scheme with the actions placed explicitly. A bare definition would leave the sequence of output undetermined.

Please log in or register to report this question.

62.

State whether the following is true or false.
The parse tree is always constructed explicitly before attributes are evaluated.

Answer: B

Correct answer: False

For an S-attributed or L-attributed definition the attributes can be computed during the parse, with no tree ever built - the values live on a stack or in procedure parameters. The annotated tree is a way of describing what the definition means rather than an object the compiler must construct.

Please log in or register to report this question.

Answer: C

The general formalism allows dependencies in any direction. Compilers restrict themselves to the acyclic S and L classes so that evaluation is guaranteed possible and cheap. The general formalism remains useful as a theoretical framework.

Please log in or register to report this question.

Answer: D

Reading the rules alongside the productions makes it plain what each construct means. The translation can be reviewed against the language definition production by production. That reviewability is worth a great deal on a compiler of any size.

Please log in or register to report this question.

Answer: A

Keeping machine dependence out of the front end is what allows one front end to serve several targets. Widths and alignments are the usual borderline cases and are normally parameterised. A clean separation is what allows one front end to serve several targets.

Please log in or register to report this question.

Answer: B

A table of target properties keeps the rules themselves independent of any one machine. Hard coding the values would tie the front end to a particular architecture. The parameterisation is usually a small table consulted by the semantic rules.

Please log in or register to report this question.

Answer: C

The labels for the loop head and exit must be passed into the body while the generated code flows upward. The mixture is what makes such translations L-attributed rather than S-attributed. Almost every real control construct needs both directions of flow.

Please log in or register to report this question.

Answer: D

A counter guarantees uniqueness. Labels are consumed by the jump instructions the translation emits and are resolved either immediately or by backpatching. The counter is reset for each procedure in some implementations.

Please log in or register to report this question.

Answer: A

Holding code in attributes lets a rule place its children's fragments in any order. Emitting directly is cheaper but fixes the output order to the order of the actions. Which approach suits depends on whether the code must be rearranged later.

Please log in or register to report this question.

Answer: B

The grammar cannot express the rule, but a semantic rule with access to the symbol table can check it. This is the standard division of labour between syntax and static semantics. The grammar handles form and the semantic rules handle everything else.

Please log in or register to report this question.

Loading…
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