SEMANTIC
ANALYSIS
ZahidWaqas FA15-BSCS-208
Tasmiya Muddaser FA15-BSCS-209
SemanticAnalysis
CC
Compiler
High level language
Lexical Analysis
Machine Language
Syntax Analysis
Semantic Analysis
Types of SemanticAction Performed by:
■ Scope Resolution
■ Type Checking
■ Array Bound Checking
Syntax DirectedTranslation (SDT)
■ SDT is done by attaching rules to productions in a grammar
■ Every node of the abstract syntax tree is attached with certain attribute set
Example :
E---- E+T {E.val=E.val+T.val}
Example SDT
Types of Attribute :
■ Synthesized Attribute
■ Inherited Attribute
To help semantic analysis we need some
tools :
■ Semantic Rules (Syntax Directed Definition )
Example
■ Semantic Action (Syntax DirectedTranslation)
Example
Example :
Reference :
■ https://www.wisdomjobs.com/e-university/compiler-design-tutorial-1144/compiler-
design-semantic-analysis-25305.html
■ https://www.youtube.com/channel/UCFWCFYvqnAMT-jcCqTp_SlA
Thanku !!!!!!!!!! 

Semantic analysis