COMPILER DESIGN

SYNTAX ANALYSIS

ROLE OF THE PARSER

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Type checking is done during
A
Syntax Analysis
B
Semantic Analysis
C
Code Optimization
D
Code Generation
Explanation: 

Detailed explanation-1: -Type checking is the process of verifying that each operation executed in a program respects the type system of the language. This generally means that all operands in any expression are of appropriate types and number. Much of what we do in the semantic analysis phase is type checking.

Detailed explanation-2: -Semantic analysis is the task of ensuring that the declarations and statements of a program are semantically correct, i.e, that their meaning is clear and consistent with the way in which control structures and data types are supposed to be used.

Detailed explanation-3: -I was somewhat surprised that type checking is categorized as semantics rather than syntax.

Detailed explanation-4: -Type checking is the process of verifying that the types of operands in a program are compatible with the operator being used and that the program is free from type errors before the code is executed.

Detailed explanation-5: -The semantic analysis process begins by studying and analyzing the dictionary definitions and meanings of individual words also referred to as lexical semantics. Following this, the relationship between words in a sentence is examined to provide clear understanding of the context.

There is 1 question to complete.