Chapter 2: Introduction to compilers

Understanding the meaning

. Once the sentence structure is understood we try to understand the meaning of the sentence (semantic analysis)

. Example: Prateek said Nitin left his assignment at home

. What does his refer to? Prateek or Nitin ?

. Even worse case

Amit said Amit left his assignment at home

. How many Amits are there? Which one left the assignment?

Semantic analysis is the process of examining the statements and to make sure that they make sense. During the semantic analysis, the types, values, and other required information about statements are recorded, checked, and transformed appropriately to make sure the program makes sense. Ideally there should be no ambiguity in the grammar of the language. Each sentence should have just one meaning.