【正文】
Semantic analysis Parsing only verifies that the program consists of tokens arranged in a syntacticallyvalid bination, we now move on to semantic analysis, where we delve deeper to check whether they form a sensible set of instructions in the programming language. For a program to be semantically correct, all variables, functions, classes, etc. are properly defined, expressions and variables are used in ways that respect the type system, access control isn’t violated, and so on. Semantic analysis is the nexttolast phase of the front end and the piler’s last chance to weed out incorrect programs. We need to ensure the program is wellformed enough to continue on to the next phase where we generate code. semantic analysis and symbol table A large part of semantic analysis consists of tracking variable/function/type declarations .As we enter each new identifier in our symbol table, we need to record the type information of the declaration. Then, as we continue parsing the rest of the program, we make sure that the type of each identifier and expression is respected in terms of the operations being performed Examples of the things we check in the semantic analysis phase. . The type of the rightside expression of an assignment statement should match the type of the leftside, and the leftside needs to be a properly declared and assignable identifie