Questions: Attribute Grammar Framework

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

In a compiler implementing type checking, the rule 'Expr → Expr₁ + Expr₂' computes the type of the parent Expr from the types of its two children. This is an example of:

AAn inherited attribute, because type information flows from the expression node to its children
BA synthesized attribute, because the parent's value is computed from its children's values
CA synthesized attribute, because type checking always flows upward in the AST
DAn inherited attribute, because the grammar rule defines the parent's type
Question 2 Multiple Choice

A grammar rule declares 'int x, y, z;' where the type 'int' must be propagated to each variable in the declarator list. This type-propagation attribute is most naturally represented as:

AA synthesized attribute computed bottom-up from the variable names
BAn inherited attribute passed down from the type specifier to each variable
CA synthesized attribute, because the type is determined once and flows to later uses
DAn inherited attribute that flows from z back toward x through the sibling list
Question 3 True / False

A grammar where nearly every attribute is synthesized (S-attributed) can be evaluated in a single top-down pass over the parse tree.

TTrue
FFalse
Question 4 True / False

In an L-attributed grammar, an attribute on a node can depend on the attributes of its right siblings.

TTrue
FFalse
Question 5 Short Answer

What is the practical difference between a synthesized and an inherited attribute, and why does this distinction affect how you can evaluate a grammar in a single pass?

Think about your answer, then reveal below.