Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assignment #4 Due Tuesday, March 20, 2018 Problem 1. Consider the following stat

ID: 3728453 • Letter: A

Question

Assignment #4 Due Tuesday, March 20, 2018 Problem 1. Consider the following statement: "In Java, a floating-point value cannot be assigned to an integer type variable, although the opposite is legal. " Which of the following is wrong? (a) Context-free grammars cannot describe this statement at al. (b) Context-free grammars can describe this statement but it is cumbersome. (c) Attribute grammars must be used to describe this statement Problem 2:Complete the following statements using the provides options nodes. This grammar can be -,--.._..-, or their combination. (a) Attribute grammars, inherited attribute, and synthesized attribute. (d) This statement has nothing to do with Semantic of grammar. have additions to Context-free grammars to carry so me semantic info on parse tree .........- (b) Static Semantic grammars, inherited attribute, and synthesized attribute. Semantic attribute, static attribute, and dynamic attribute. (c) (d) Non of the above Problem 3: Which of the following option is correct about the addition to a context-free grammar to implement an attribute grammar? (a) For each grammar symbol x there is a set Afx) of attribute values (b) Each rule has a set of functions that define certain attributes of the oootecninals in the rule (c) Each rule has a (possibly empty) set of predicates to check for attribute consistency (d) All of the above are correct Problem 4: In synthesized attributes, the semantic information passes , so that the value ed attribute on a parse tree node depends only on the values of the attributes on that of a synthesiz node's (a) up a parse tree, children nodes (b) down (c) up a parse tree, node's parent node and those of its sibling nodes (d) down and across a tree, children nodes and across a tree, node's parent node and those of its sibling nodes Problem 5: In inherited attributes, semantic information passes , so that the value of an inherited attribute on a parse tree node depends on the attribute values of that MacBook

Explanation / Answer

Problem 2:

Answer a)

Attribute grammars (AGs), inherited attribute and synthesized attribute

Explanation:

AGS have additions to Context – free grammars CFGs to carry some semantic info on parse tree nodes

Attribute values are computed by

The tree could be tinted in top-down order if all attributes were inherited,

The tree could be tinted in bottom-up order if all attributes were synthesized,

4)

Answer : a)

Explanation:

The attributes are divided into 2 groups:

Synthesized attributes: This is the result of the attribute evaluation rules and regulations, and could also make use of the values of the inherited attribute.

In some move towards, synthesized attributes are determined from nodes of children in parse tree if x0-> x1->x2->....... xn is a rule, the s(x0)=f(A(x1), ....., A(xn))

And it passes semantic information up the tree

5.

Answer b)

Explanation: second one inherited attributes pass semantic information down and across tree example for one inherited attributes is passed from parent to child so the value of this on a parse tree node depends on the attribute values of that node's parent node and those of its sibling nodes

7.

Answer b)

Explanation:

Backus Naur Form and CFG are equivalent meta languages well suited for describing the syntax of programming languages both syntax and semantics of language an attribute grammar is descriptive formalism that can describe both one above

8.

Three primary methods of semantics description is