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