→ = Semantic rule: .expected_type + .actual_type2. Syntax rule: → Semantic rule: .actual_type + .actual_typePredicate: .actual_type == . expected_type3. Syntax rule: → + Semantic rule: .actual_type...


1. Use the following attribute grammar to answer the questions below.<br>1. Syntax rule: <assign> → <var>= <expr><br>Semantic rule: <expr>.expected_type + <var>.actual_type<br>2. Syntax rule: <expr> →<var><br>Semantic rule: <expr>.actual_type + <var>.actual_type<br>Predicate: <expr>.actual_type == <expr>. expected_type<br>3. Syntax rule: <expr> →<var>+ <term><br>Semantic rule: <expr>.actual_type <term>.actual_type<br>Predicate: <expr>.actual_type == <expr>. expected_type<br>4. Syntax rule: <term> → <var><br>Semantic rule: <term>.actual_type + <var>.actual_type<br>5. Syntax rule: <term> → <var>[2] + <var>[3]<br>Semantic rule: <term>.actual_type + <var>[2].actual_type<br>Predicate: <var>[2].actual_type == <var>[3].actual_type<br>6. Syntax rule: <var> → A | B | C<br>Semantic rule: <var>.actual_type + look-up(<var>.string)<br>a) Draw a fully attributed parse tree for the sentence C = B+c +A, assuming that<br>A has type real, B has type int, and C has type real. See Figure 3.8 in Sebesta for<br>an example of such a tree.<br>b) According to the attribute grammar, is this sentence valid?<br>

Extracted text: 1. Use the following attribute grammar to answer the questions below. 1. Syntax rule:
= Semantic rule: .expected_type +
.actual_type 2. Syntax rule:
Semantic rule: .actual_type +
.actual_type Predicate: .actual_type == . expected_type 3. Syntax rule: + Semantic rule: .actual_type .actual_type Predicate: .actual_type == . expected_type 4. Syntax rule:

Semantic rule: .actual_type +
.actual_type 5. Syntax rule:
[2] +
[3] Semantic rule: .actual_type +
[2].actual_type Predicate:
[2].actual_type ==
[3].actual_type 6. Syntax rule:

→ A | B | C Semantic rule:
.actual_type + look-up(.string) a) Draw a fully attributed parse tree for the sentence C = B+c +A, assuming that A has type real, B has type int, and C has type real. See Figure 3.8 in Sebesta for an example of such a tree. b) According to the attribute grammar, is this sentence valid?













Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here