2076 6

CSC376 · 2076 · 6 marks

Write Syntax Directed Definition to carry out type checking for the following expression.E→id∣E1 op E2∣E1 relop E2∣E1[E2]∣E1↑E \rightarrow id | E1 \text{ op } E2 | E1 \text{ relop } E2 | E1[E2] | E1↑E→id∣E1 op E2∣E1 relop E2∣E1[E2]∣E1↑

Write Syntax Directed Definition to carry out type checking for the following expression.E→id∣E1 op E2∣E1 relop E2∣E1[E2]∣E1↑E \rightarrow id | E1 \text{ op } E2 | E1 \text{ relop } E2 | E1[E2] | E1↑E→id∣E1 op E2∣E1 relop E2∣E1[E2]∣E1↑[6]

Compiler Design and ConstructionChapter 2: Lexical, Syntax and Semantic AnalysisType Checking and Conversion

Type checking is a key part of semantic analysis. A Syntax-Directed Definition (SDD) associates attributes with grammar symbols and semantic rules with productions. For type checking, each expression E carries a synthesized attribute E.type that is computed bottom-up. --- Symbol Meaning ---------...