SlideShare uma empresa Scribd logo
1 de 11
CSE 420
Lecture 10
• Semantic Analysis computes additional information related to the
meaning of the program once the syntactic structure is known.
• In typed languages as C, semantic analysis involves
• adding information to the symbol table and
• performing type checking.
• The information to be computed is beyond the capabilities of
standard parsing techniques, therefore it is not regarded as
syntax.
• As for Lexical and Syntax analysis, also for Semantic Analysis we need
both a Representation Formalism and an Implementation
Mechanism.
• The Principle of Syntax Directed Translation states that
the meaning of an input sentence is related to its syntactic
structure, i.e., to its Parse-Tree.
• By Syntax Directed Translations we indicate those
formalisms for specifying translations for programming
language constructs guided by context-free grammars.
– We associate Attributes to the grammar symbols
representing the language constructs.
– Values for attributes are computed by Semantic Rules
associated with grammar productions.
• Evaluation of Semantic Rules may:
– Generate Code;
– Insert information into the Symbol Table;
– Perform Semantic Check;
– Issue error messages; etc.
• There are two notations for attaching semantic rules:
1. Syntax Directed Definitions.High-level specification hiding many
implementation details (also called Attribute Grammars).
2. Translation Schemes. More implementation oriented: Indicate the order
in which semantic rules are to be evaluated.
• Syntax Directed Definitions are a generalization of context-free
grammars in which:
1. Grammar symbols have an associated set of Attributes;
2. Productions are associated with Semantic Rules for computing
the values of attributes.
• Such formalism generates Annotated Parse-Trees where each node of
the tree is a record with a field for each attribute (e.g., X.a indicates the
attribute a of the grammar symbolX).
• The value of an attribute of a grammar symbol at a given parse-
tree node is defined by a semantic rule associated with the
production used at that node.
• We distinguish between two kinds of attributes:
1. Synthesized Attributes.They are computed from the
values of the attributes of the children nodes.
2. Inherited Attributes. They are computed from the
values of the attributes of both the siblings and the
parent nodes.
• Each production, A → α, is associated with a set of semantic
rules:
b : = f (c1, c2, . . . , ck), where f is a function and either
1. b is a synthesized attribute of A, and c1, c2, . . . , ck are attributes
of the grammar symbols of the production, or
2. b is an inherited attribute of a grammar symbol in α, and c1, c2, . .
. , ck are attributes of grammar symbols in α or attributes of A.
• Note. Terminal symbols are assumed to have synthesized attributes
supplied by the lexical analyzer.
• Procedure calls (e.g. print in the next slide) define values of
Dummy synthesized attributes of the non terminal on the left-
hand side of the production.
• Example. Let us consider the Grammar for arithmetic expressions.
The Syntax Directed Definition associates to each non terminal a
synthesized attribute called val.
PRODUCTION
L → En
E → E1 + T
E → T
T → T1 ∗F
T → F
F → ( E )
F → digit
SEMANTIC RULE
print(E.val)
E.val : = E1.val + T.val
E.val : = T.val
T.val : = T1.val ∗F.val
T.val : = F.val
F.val : = E.val
F.val :=digit.lexval
Definition. An S-Attributed Definition is a Syntax Directed
Definition that uses only synthesized attributes.
• Evaluation Order.Semantic rules in a S-Attributed
Definition can be evaluated by a bottom-up, or
PostOrder, traversal of the parse-tree.
• Example. The above arithmetic grammar is an example of
an S-Attributed Definition. The annotated parse-tree for the
input 3*5+4n is:
E.val = 19 n
+ T.val = 4E.val = 15
T.val = 15
T.val = 3 *
F.val = 4
digit.lexval= 4F.val = 5
digit.lexval= 5F.val = 3
digit.lexval= 3
L
Lecture 10 semantic analysis 01

Mais conteúdo relacionado

Mais procurados

Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignAkhil Kaushik
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translationAkshaya Arunan
 
Chapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.pptChapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.pptFamiDan
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler DesignKuppusamy P
 
Context free grammars
Context free grammarsContext free grammars
Context free grammarsRonak Thakkar
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Iffat Anjum
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming languageVasavi College of Engg
 
Relationship Among Token, Lexeme & Pattern
Relationship Among Token, Lexeme & PatternRelationship Among Token, Lexeme & Pattern
Relationship Among Token, Lexeme & PatternBharat Rathore
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design BasicsAkhil Kaushik
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compilerIffat Anjum
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical AnalysisMunni28
 
Semantic Analysis.pptx
Semantic Analysis.pptxSemantic Analysis.pptx
Semantic Analysis.pptxZarfaMasood
 

Mais procurados (20)

Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler Design
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
Chapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.pptChapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.ppt
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
Role-of-lexical-analysis
Role-of-lexical-analysisRole-of-lexical-analysis
Role-of-lexical-analysis
 
Relationship Among Token, Lexeme & Pattern
Relationship Among Token, Lexeme & PatternRelationship Among Token, Lexeme & Pattern
Relationship Among Token, Lexeme & Pattern
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Symbol Table
Symbol TableSymbol Table
Symbol Table
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
 
Cocomo model
Cocomo modelCocomo model
Cocomo model
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Daa notes 3
Daa notes 3Daa notes 3
Daa notes 3
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
 
Semantic Analysis.pptx
Semantic Analysis.pptxSemantic Analysis.pptx
Semantic Analysis.pptx
 
Compilers Design
Compilers DesignCompilers Design
Compilers Design
 

Destaque

Type checking
Type checkingType checking
Type checkingrawan_z
 
Syntax directed-translation
Syntax directed-translationSyntax directed-translation
Syntax directed-translationJunaid Lodhi
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler DesignShine Raj
 
Lecture 3 Conditionals, expressions and Variables
Lecture 3   Conditionals, expressions and VariablesLecture 3   Conditionals, expressions and Variables
Lecture 3 Conditionals, expressions and VariablesSyed Afaq Shah MACS CP
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1Shashwat Shriparv
 
Semantic Analysis of User Browsing Patterns in the Web of Data @USEWOD, WWW2012
Semantic Analysis of User Browsing Patterns in the Web of Data @USEWOD, WWW2012Semantic Analysis of User Browsing Patterns in the Web of Data @USEWOD, WWW2012
Semantic Analysis of User Browsing Patterns in the Web of Data @USEWOD, WWW2012juliahoxha
 
Lecture 06 syntax analysis 3
Lecture 06 syntax analysis 3Lecture 06 syntax analysis 3
Lecture 06 syntax analysis 3Iffat Anjum
 
compiler and their types
compiler and their typescompiler and their types
compiler and their typespatchamounika7
 
Lecture 12 intermediate code generation
Lecture 12 intermediate code generationLecture 12 intermediate code generation
Lecture 12 intermediate code generationIffat Anjum
 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler designSudip Singh
 
Code generator
Code generatorCode generator
Code generatorTech_MX
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generationVipul Naik
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generationrawan_z
 
Abstract syntax semantic analyze
Abstract syntax semantic analyzeAbstract syntax semantic analyze
Abstract syntax semantic analyzeHyunJoon Park
 
Fog computing ( foggy cloud)
Fog computing  ( foggy cloud)Fog computing  ( foggy cloud)
Fog computing ( foggy cloud)Iffat Anjum
 
Code Optimization
Code OptimizationCode Optimization
Code Optimizationguest9f8315
 

Destaque (20)

Type checking
Type checkingType checking
Type checking
 
Syntax directed-translation
Syntax directed-translationSyntax directed-translation
Syntax directed-translation
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler Design
 
Lecture 3 Conditionals, expressions and Variables
Lecture 3   Conditionals, expressions and VariablesLecture 3   Conditionals, expressions and Variables
Lecture 3 Conditionals, expressions and Variables
 
Type conversion
Type conversionType conversion
Type conversion
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1
 
Semantic Analysis of User Browsing Patterns in the Web of Data @USEWOD, WWW2012
Semantic Analysis of User Browsing Patterns in the Web of Data @USEWOD, WWW2012Semantic Analysis of User Browsing Patterns in the Web of Data @USEWOD, WWW2012
Semantic Analysis of User Browsing Patterns in the Web of Data @USEWOD, WWW2012
 
Compiler
CompilerCompiler
Compiler
 
Lecture 06 syntax analysis 3
Lecture 06 syntax analysis 3Lecture 06 syntax analysis 3
Lecture 06 syntax analysis 3
 
compiler and their types
compiler and their typescompiler and their types
compiler and their types
 
Lecture 12 intermediate code generation
Lecture 12 intermediate code generationLecture 12 intermediate code generation
Lecture 12 intermediate code generation
 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler design
 
Code generator
Code generatorCode generator
Code generator
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generation
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
 
Abstract syntax semantic analyze
Abstract syntax semantic analyzeAbstract syntax semantic analyze
Abstract syntax semantic analyze
 
Fog computing ( foggy cloud)
Fog computing  ( foggy cloud)Fog computing  ( foggy cloud)
Fog computing ( foggy cloud)
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Code generation
Code generationCode generation
Code generation
 
Ch5a
Ch5aCh5a
Ch5a
 

Semelhante a Lecture 10 semantic analysis 01

12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.pptvenkatapranaykumarGa
 
Unit iv-syntax-directed-translation
Unit iv-syntax-directed-translationUnit iv-syntax-directed-translation
Unit iv-syntax-directed-translationAjith kumar M P
 
Chapter -4.pptx
Chapter -4.pptxChapter -4.pptx
Chapter -4.pptxwoldu2
 
Chapter _4_Semantic Analysis .pptx
Chapter _4_Semantic Analysis .pptxChapter _4_Semantic Analysis .pptx
Chapter _4_Semantic Analysis .pptxArebuMaruf
 
L14 Semantic analysis This process is crucial in various applications such a...
L14 Semantic analysis  This process is crucial in various applications such a...L14 Semantic analysis  This process is crucial in various applications such a...
L14 Semantic analysis This process is crucial in various applications such a...CodingChamp1
 
Syntax Directed Definition and its applications
Syntax Directed Definition and its applicationsSyntax Directed Definition and its applications
Syntax Directed Definition and its applicationsShivanandManjaragi2
 
Cd ch2 - lexical analysis
Cd   ch2 - lexical analysisCd   ch2 - lexical analysis
Cd ch2 - lexical analysismengistu23
 
RMM CD LECTURE NOTES UNIT-3 ALL.pdf
RMM CD LECTURE NOTES UNIT-3 ALL.pdfRMM CD LECTURE NOTES UNIT-3 ALL.pdf
RMM CD LECTURE NOTES UNIT-3 ALL.pdfRishikeshPathak10
 
3a. Context Free Grammar.pdf
3a. Context Free Grammar.pdf3a. Context Free Grammar.pdf
3a. Context Free Grammar.pdfTANZINTANZINA
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compilerSudhaa Ravi
 
role of lexical anaysis
role of lexical anaysisrole of lexical anaysis
role of lexical anaysisSudhaa Ravi
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compileradilmehmood93
 

Semelhante a Lecture 10 semantic analysis 01 (20)

12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
 
Unit iv-syntax-directed-translation
Unit iv-syntax-directed-translationUnit iv-syntax-directed-translation
Unit iv-syntax-directed-translation
 
chp2sds.pdfgh
chp2sds.pdfghchp2sds.pdfgh
chp2sds.pdfgh
 
lect-05.pdf
lect-05.pdflect-05.pdf
lect-05.pdf
 
Chapter -4.pptx
Chapter -4.pptxChapter -4.pptx
Chapter -4.pptx
 
Chapter _4_Semantic Analysis .pptx
Chapter _4_Semantic Analysis .pptxChapter _4_Semantic Analysis .pptx
Chapter _4_Semantic Analysis .pptx
 
L14 Semantic analysis This process is crucial in various applications such a...
L14 Semantic analysis  This process is crucial in various applications such a...L14 Semantic analysis  This process is crucial in various applications such a...
L14 Semantic analysis This process is crucial in various applications such a...
 
Module4 lex and yacc.ppt
Module4 lex and yacc.pptModule4 lex and yacc.ppt
Module4 lex and yacc.ppt
 
Syntax Directed Definition and its applications
Syntax Directed Definition and its applicationsSyntax Directed Definition and its applications
Syntax Directed Definition and its applications
 
Compiler design Project
Compiler design ProjectCompiler design Project
Compiler design Project
 
Plc part 2
Plc  part 2Plc  part 2
Plc part 2
 
Unit1.ppt
Unit1.pptUnit1.ppt
Unit1.ppt
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Cd ch2 - lexical analysis
Cd   ch2 - lexical analysisCd   ch2 - lexical analysis
Cd ch2 - lexical analysis
 
RMM CD LECTURE NOTES UNIT-3 ALL.pdf
RMM CD LECTURE NOTES UNIT-3 ALL.pdfRMM CD LECTURE NOTES UNIT-3 ALL.pdf
RMM CD LECTURE NOTES UNIT-3 ALL.pdf
 
3a. Context Free Grammar.pdf
3a. Context Free Grammar.pdf3a. Context Free Grammar.pdf
3a. Context Free Grammar.pdf
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compiler
 
role of lexical anaysis
role of lexical anaysisrole of lexical anaysis
role of lexical anaysis
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
 
Language processors
Language processorsLanguage processors
Language processors
 

Mais de Iffat Anjum

Cognitive radio network_MS_defense_presentation
Cognitive radio network_MS_defense_presentationCognitive radio network_MS_defense_presentation
Cognitive radio network_MS_defense_presentationIffat Anjum
 
Lecture 15 run timeenvironment_2
Lecture 15 run timeenvironment_2Lecture 15 run timeenvironment_2
Lecture 15 run timeenvironment_2Iffat Anjum
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generationIffat Anjum
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environmentIffat Anjum
 
Lecture 13 intermediate code generation 2.pptx
Lecture 13 intermediate code generation 2.pptxLecture 13 intermediate code generation 2.pptx
Lecture 13 intermediate code generation 2.pptxIffat Anjum
 
Lecture 09 syntax analysis 05
Lecture 09 syntax analysis 05Lecture 09 syntax analysis 05
Lecture 09 syntax analysis 05Iffat Anjum
 
Lecture 07 08 syntax analysis-4
Lecture 07 08 syntax analysis-4Lecture 07 08 syntax analysis-4
Lecture 07 08 syntax analysis-4Iffat Anjum
 
Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Iffat Anjum
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysisIffat Anjum
 
Lecture 04 syntax analysis
Lecture 04 syntax analysisLecture 04 syntax analysis
Lecture 04 syntax analysisIffat Anjum
 
Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysisIffat Anjum
 
Compiler Design - Introduction to Compiler
Compiler Design - Introduction to CompilerCompiler Design - Introduction to Compiler
Compiler Design - Introduction to CompilerIffat Anjum
 
Distributed contention based mac protocol for cognitive radio
Distributed contention based mac protocol for cognitive radioDistributed contention based mac protocol for cognitive radio
Distributed contention based mac protocol for cognitive radioIffat Anjum
 
On qo s provisioning in context aware wireless sensor networks for healthcare
On qo s provisioning in context aware wireless sensor networks for healthcareOn qo s provisioning in context aware wireless sensor networks for healthcare
On qo s provisioning in context aware wireless sensor networks for healthcareIffat Anjum
 
Data link control
Data link controlData link control
Data link controlIffat Anjum
 
Pnp mac preemptive slot allocation and non preemptive transmission for provid...
Pnp mac preemptive slot allocation and non preemptive transmission for provid...Pnp mac preemptive slot allocation and non preemptive transmission for provid...
Pnp mac preemptive slot allocation and non preemptive transmission for provid...Iffat Anjum
 
Qo s based mac protocol for medical wireless body area sensor networks
Qo s based mac protocol for medical wireless body area sensor networksQo s based mac protocol for medical wireless body area sensor networks
Qo s based mac protocol for medical wireless body area sensor networksIffat Anjum
 
A reinforcement learning based routing protocol with qo s support for biomedi...
A reinforcement learning based routing protocol with qo s support for biomedi...A reinforcement learning based routing protocol with qo s support for biomedi...
A reinforcement learning based routing protocol with qo s support for biomedi...Iffat Anjum
 
Data centric multiobjective qo s-aware routing protocol (dm-qos) for body are...
Data centric multiobjective qo s-aware routing protocol (dm-qos) for body are...Data centric multiobjective qo s-aware routing protocol (dm-qos) for body are...
Data centric multiobjective qo s-aware routing protocol (dm-qos) for body are...Iffat Anjum
 
Quality of service aware mac protocol for body sensor networks
Quality of service aware mac protocol for body sensor networksQuality of service aware mac protocol for body sensor networks
Quality of service aware mac protocol for body sensor networksIffat Anjum
 

Mais de Iffat Anjum (20)

Cognitive radio network_MS_defense_presentation
Cognitive radio network_MS_defense_presentationCognitive radio network_MS_defense_presentation
Cognitive radio network_MS_defense_presentation
 
Lecture 15 run timeenvironment_2
Lecture 15 run timeenvironment_2Lecture 15 run timeenvironment_2
Lecture 15 run timeenvironment_2
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generation
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
 
Lecture 13 intermediate code generation 2.pptx
Lecture 13 intermediate code generation 2.pptxLecture 13 intermediate code generation 2.pptx
Lecture 13 intermediate code generation 2.pptx
 
Lecture 09 syntax analysis 05
Lecture 09 syntax analysis 05Lecture 09 syntax analysis 05
Lecture 09 syntax analysis 05
 
Lecture 07 08 syntax analysis-4
Lecture 07 08 syntax analysis-4Lecture 07 08 syntax analysis-4
Lecture 07 08 syntax analysis-4
 
Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysis
 
Lecture 04 syntax analysis
Lecture 04 syntax analysisLecture 04 syntax analysis
Lecture 04 syntax analysis
 
Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysis
 
Compiler Design - Introduction to Compiler
Compiler Design - Introduction to CompilerCompiler Design - Introduction to Compiler
Compiler Design - Introduction to Compiler
 
Distributed contention based mac protocol for cognitive radio
Distributed contention based mac protocol for cognitive radioDistributed contention based mac protocol for cognitive radio
Distributed contention based mac protocol for cognitive radio
 
On qo s provisioning in context aware wireless sensor networks for healthcare
On qo s provisioning in context aware wireless sensor networks for healthcareOn qo s provisioning in context aware wireless sensor networks for healthcare
On qo s provisioning in context aware wireless sensor networks for healthcare
 
Data link control
Data link controlData link control
Data link control
 
Pnp mac preemptive slot allocation and non preemptive transmission for provid...
Pnp mac preemptive slot allocation and non preemptive transmission for provid...Pnp mac preemptive slot allocation and non preemptive transmission for provid...
Pnp mac preemptive slot allocation and non preemptive transmission for provid...
 
Qo s based mac protocol for medical wireless body area sensor networks
Qo s based mac protocol for medical wireless body area sensor networksQo s based mac protocol for medical wireless body area sensor networks
Qo s based mac protocol for medical wireless body area sensor networks
 
A reinforcement learning based routing protocol with qo s support for biomedi...
A reinforcement learning based routing protocol with qo s support for biomedi...A reinforcement learning based routing protocol with qo s support for biomedi...
A reinforcement learning based routing protocol with qo s support for biomedi...
 
Data centric multiobjective qo s-aware routing protocol (dm-qos) for body are...
Data centric multiobjective qo s-aware routing protocol (dm-qos) for body are...Data centric multiobjective qo s-aware routing protocol (dm-qos) for body are...
Data centric multiobjective qo s-aware routing protocol (dm-qos) for body are...
 
Quality of service aware mac protocol for body sensor networks
Quality of service aware mac protocol for body sensor networksQuality of service aware mac protocol for body sensor networks
Quality of service aware mac protocol for body sensor networks
 

Último

Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 

Último (20)

LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 

Lecture 10 semantic analysis 01

  • 2. • Semantic Analysis computes additional information related to the meaning of the program once the syntactic structure is known. • In typed languages as C, semantic analysis involves • adding information to the symbol table and • performing type checking. • The information to be computed is beyond the capabilities of standard parsing techniques, therefore it is not regarded as syntax. • As for Lexical and Syntax analysis, also for Semantic Analysis we need both a Representation Formalism and an Implementation Mechanism.
  • 3. • The Principle of Syntax Directed Translation states that the meaning of an input sentence is related to its syntactic structure, i.e., to its Parse-Tree. • By Syntax Directed Translations we indicate those formalisms for specifying translations for programming language constructs guided by context-free grammars. – We associate Attributes to the grammar symbols representing the language constructs. – Values for attributes are computed by Semantic Rules associated with grammar productions.
  • 4. • Evaluation of Semantic Rules may: – Generate Code; – Insert information into the Symbol Table; – Perform Semantic Check; – Issue error messages; etc. • There are two notations for attaching semantic rules: 1. Syntax Directed Definitions.High-level specification hiding many implementation details (also called Attribute Grammars). 2. Translation Schemes. More implementation oriented: Indicate the order in which semantic rules are to be evaluated.
  • 5. • Syntax Directed Definitions are a generalization of context-free grammars in which: 1. Grammar symbols have an associated set of Attributes; 2. Productions are associated with Semantic Rules for computing the values of attributes. • Such formalism generates Annotated Parse-Trees where each node of the tree is a record with a field for each attribute (e.g., X.a indicates the attribute a of the grammar symbolX).
  • 6. • The value of an attribute of a grammar symbol at a given parse- tree node is defined by a semantic rule associated with the production used at that node. • We distinguish between two kinds of attributes: 1. Synthesized Attributes.They are computed from the values of the attributes of the children nodes. 2. Inherited Attributes. They are computed from the values of the attributes of both the siblings and the parent nodes.
  • 7. • Each production, A → α, is associated with a set of semantic rules: b : = f (c1, c2, . . . , ck), where f is a function and either 1. b is a synthesized attribute of A, and c1, c2, . . . , ck are attributes of the grammar symbols of the production, or 2. b is an inherited attribute of a grammar symbol in α, and c1, c2, . . . , ck are attributes of grammar symbols in α or attributes of A. • Note. Terminal symbols are assumed to have synthesized attributes supplied by the lexical analyzer. • Procedure calls (e.g. print in the next slide) define values of Dummy synthesized attributes of the non terminal on the left- hand side of the production.
  • 8. • Example. Let us consider the Grammar for arithmetic expressions. The Syntax Directed Definition associates to each non terminal a synthesized attribute called val. PRODUCTION L → En E → E1 + T E → T T → T1 ∗F T → F F → ( E ) F → digit SEMANTIC RULE print(E.val) E.val : = E1.val + T.val E.val : = T.val T.val : = T1.val ∗F.val T.val : = F.val F.val : = E.val F.val :=digit.lexval
  • 9. Definition. An S-Attributed Definition is a Syntax Directed Definition that uses only synthesized attributes. • Evaluation Order.Semantic rules in a S-Attributed Definition can be evaluated by a bottom-up, or PostOrder, traversal of the parse-tree.
  • 10. • Example. The above arithmetic grammar is an example of an S-Attributed Definition. The annotated parse-tree for the input 3*5+4n is: E.val = 19 n + T.val = 4E.val = 15 T.val = 15 T.val = 3 * F.val = 4 digit.lexval= 4F.val = 5 digit.lexval= 5F.val = 3 digit.lexval= 3 L