2075 6

CSC376 · 2075 · 6 marks

Differentiate between static and dynamic type checking. How can we carry out type checking for the following expression using syntax-directed definition? S rightarrow id = E S rightarrow textif E text then S1 S rightarrow textwhile E text do S1 S rightarrow S1; S2

Differentiate between static and dynamic type checking. How can we carry out type checking for the following expression using syntax-directed definition?

$S \rightarrow id = E$

$S \rightarrow \text{if } E \text{ then } S1$

$S \rightarrow \text{while } E \text{ do } S1$

$S \rightarrow S1; S2$

[6]

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

--- Type checking is the process of verifying that each operation in a program receives the correct number and type of operands. Feature Static Type Checking Dynamic Type Checking --------- When performed At compile time At run time Speed Faster execution (errors caught early) Slower (overhead at...