SlideShare a Scribd company logo
2
Most read
10
Most read
21
Most read
Analysis of the Source Program: In compiling, analysis consists of three phases: Linear Analysis : Hierarchical Analysis: Semantic Analysis:
Analysis of the Source Program: Linear Analysis : In which the stream of characters making up the source program is read from left-to-right and grouped into tokens that are sequences of characters having a collective meaning.
Analysis of the Source Program: Hierarchical Analysis : In which characters or tokens are grouped hierarchically into nested collections with collective meaning.
Analysis of the Source Program: Semantic Analysis : In which certain checks are performed to ensure that the components of a program fit together meaningfully.
 
Scanning or Lexical Analysis (Linear Analysis):   In a compiler, linear analysis is called lexical analysis or scanning. For example, in lexical analysis the characters in the assignment statement Position: = initial + rate * 60 Would be grouped into the following tokens:
Scanning or Lexical Analysis (Linear Analysis):   The identifier, position. The assignment symbol := The identifier initial. The plus sign. The identifier rate. The multiplication sign. The number 60.
Scanning or Lexical Analysis (Linear Analysis):   The blanks separating the characters of these tokens would normally be eliminated during the lexical analysis.
 
Syntax Analysis or Hierarchical Analysis (Parsing):   Hierarchical analysis is called parsing or syntax analysis. It involves grouping the tokens of the source program into grammatical phases that are used by the compiler to synthesize output.
Syntax Analysis or Hierarchical Analysis (Parsing):   The grammatical phrases of the source program are represented by a parse tree.
Syntax Analysis or Hierarchical Analysis (Parsing):   In the expression  initial + rate * 60 , the phrase rate * 60 is a logical unit because the usual conventions of arithmetic expressions tell us that the multiplication is performed before addition.  Because the expression  initial + rate  is followed by a *, it is not grouped into a single phrase by itself
Syntax Analysis or Hierarchical Analysis (Parsing):   The hierarchical structure of a program is usually expressed by recursive rules. For example, we might have the following rules, as part of the definition of expression:
Syntax Analysis or Hierarchical Analysis (Parsing):   Any identifier is an expression. Any number is an expression If expression 1  and expression 2  are expressions, then so are Expression 1  + expression 2 Expression 1  * expression 2 (Expression 1  )
 
Semantic Analysis :  The semantic analysis phase checks the source program for semantic errors and gathers type information for the subsequent code-generation phase.
Semantic Analysis :  It uses the hierarchical structure determined by the syntax-analysis phase to identify the operators and operand of expressions and statements.
Semantic Analysis :  An important component of semantic analysis is type checking.  Here are the compiler checks that each operator has operands that are permitted by the source language specification.
Semantic Analysis :  For example, when a binary arithmetic operator is applied to an integer and real. In this case, the compiler may need to be converting the integer to a real. As shown in figure given below
Semantic Analysis :
Ref: Compilers Principles, Techniques and Tools by Alfred V. Aho, Ravi Sethi, Jeffrey D. Ullman Tayyab Arif Allama Iqbal Open University [email_address] [email_address]

More Related Content

PPTX
Means End Analysis (MEA) in Artificial.pptx
PDF
Syntax directed translation
PPTX
Specification-of-tokens
PDF
Lexical Analysis - Compiler design
PPTX
Error Detection & Recovery
PPTX
Design of a two pass assembler
PPTX
Syntax Analysis in Compiler Design
PDF
Token, Pattern and Lexeme
Means End Analysis (MEA) in Artificial.pptx
Syntax directed translation
Specification-of-tokens
Lexical Analysis - Compiler design
Error Detection & Recovery
Design of a two pass assembler
Syntax Analysis in Compiler Design
Token, Pattern and Lexeme

What's hot (20)

PPTX
Routing algorithm
PDF
Operator precedence
PDF
Production System in AI
PPTX
First and follow set
PPTX
Minmax Algorithm In Artificial Intelligence slides
PPTX
Role-of-lexical-analysis
PPTX
knowledge representation using rules
PPTX
Cs419 lec10 left recursion and left factoring
PDF
Problem Characteristics in Artificial Intelligence
PPTX
Recognition-of-tokens
PPTX
Issues in knowledge representation
PPTX
Phases of compiler
PPTX
Control Strategies in AI
PPTX
Pci,usb,scsi bus
PPTX
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
PPTX
Congestion control
PPTX
Unit 4 sp macro
PPTX
Code Optimization
PPTX
Unit 3 sp assembler
PPTX
Introduction TO Finite Automata
Routing algorithm
Operator precedence
Production System in AI
First and follow set
Minmax Algorithm In Artificial Intelligence slides
Role-of-lexical-analysis
knowledge representation using rules
Cs419 lec10 left recursion and left factoring
Problem Characteristics in Artificial Intelligence
Recognition-of-tokens
Issues in knowledge representation
Phases of compiler
Control Strategies in AI
Pci,usb,scsi bus
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Congestion control
Unit 4 sp macro
Code Optimization
Unit 3 sp assembler
Introduction TO Finite Automata
Ad

Viewers also liked (6)

PPT
Top down parsing
PPTX
Phases of Compiler
PPTX
ASSIGNMENT STATEMENTS AND
PPTX
Parsing
PPTX
Compiler Chapter 1
PPTX
Top down and botttom up Parsing
Top down parsing
Phases of Compiler
ASSIGNMENT STATEMENTS AND
Parsing
Compiler Chapter 1
Top down and botttom up Parsing
Ad

Similar to Analysis of the source program (20)

PPTX
PPTX
phases of compiler-analysis phase
PPT
Compiler Construction
PPTX
Comiler construction Notes
PPTX
Principles of Compiler Design - Introduction
PPTX
phase of compiler
PPTX
Compiler Construction-2 for bs computer science.pptx
PDF
PDF
PDF
Principles of Compiler Design
PPT
what is compiler and five phases of compiler
PDF
Lecture 2.1 - Phase of a Commmmpiler.pdf
PPSX
Spr ch-05-compilers
PPTX
Compiler Design Unit1 PPT Phases of Compiler.pptx
PPTX
Compiler lecture 07
PPTX
COMPILER CONSTRUCTION KU 1.pptx
PDF
Assignment1
PPTX
Ss ui lecture 2
PDF
Using Static Analysis in Program Development
PPTX
CD.pptx
phases of compiler-analysis phase
Compiler Construction
Comiler construction Notes
Principles of Compiler Design - Introduction
phase of compiler
Compiler Construction-2 for bs computer science.pptx
Principles of Compiler Design
what is compiler and five phases of compiler
Lecture 2.1 - Phase of a Commmmpiler.pdf
Spr ch-05-compilers
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler lecture 07
COMPILER CONSTRUCTION KU 1.pptx
Assignment1
Ss ui lecture 2
Using Static Analysis in Program Development
CD.pptx

More from Huawei Technologies (11)

PPT
Mian Nawaz Sharif PMLN
PPT
Mian nawaz sharif pmln
PPTX
Biography of nawaz sharif
PPTX
The analysis synthesis model of compilation
PPT
What is Compiler?
PPT
Binary signal, Uni-polar,
PPT
Data encryption, Description, DES
PPT
Error correction, ARQ, FEC
PPT
Error control, parity check, check sum, vrc
PPT
Asynchronous and synchronous operation
PPT
Binary Codes
Mian Nawaz Sharif PMLN
Mian nawaz sharif pmln
Biography of nawaz sharif
The analysis synthesis model of compilation
What is Compiler?
Binary signal, Uni-polar,
Data encryption, Description, DES
Error correction, ARQ, FEC
Error control, parity check, check sum, vrc
Asynchronous and synchronous operation
Binary Codes

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Electronic commerce courselecture one. Pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation theory and applications.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
cuic standard and advanced reporting.pdf
Approach and Philosophy of On baking technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Programs and apps: productivity, graphics, security and other tools
Advanced methodologies resolving dimensionality complications for autism neur...
Chapter 3 Spatial Domain Image Processing.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Network Security Unit 5.pdf for BCA BBA.
sap open course for s4hana steps from ECC to s4
Building Integrated photovoltaic BIPV_UPV.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
MIND Revenue Release Quarter 2 2025 Press Release
Electronic commerce courselecture one. Pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Cloud computing and distributed systems.
Encapsulation theory and applications.pdf
Machine learning based COVID-19 study performance prediction
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
cuic standard and advanced reporting.pdf

Analysis of the source program

  • 1. Analysis of the Source Program: In compiling, analysis consists of three phases: Linear Analysis : Hierarchical Analysis: Semantic Analysis:
  • 2. Analysis of the Source Program: Linear Analysis : In which the stream of characters making up the source program is read from left-to-right and grouped into tokens that are sequences of characters having a collective meaning.
  • 3. Analysis of the Source Program: Hierarchical Analysis : In which characters or tokens are grouped hierarchically into nested collections with collective meaning.
  • 4. Analysis of the Source Program: Semantic Analysis : In which certain checks are performed to ensure that the components of a program fit together meaningfully.
  • 5.  
  • 6. Scanning or Lexical Analysis (Linear Analysis): In a compiler, linear analysis is called lexical analysis or scanning. For example, in lexical analysis the characters in the assignment statement Position: = initial + rate * 60 Would be grouped into the following tokens:
  • 7. Scanning or Lexical Analysis (Linear Analysis): The identifier, position. The assignment symbol := The identifier initial. The plus sign. The identifier rate. The multiplication sign. The number 60.
  • 8. Scanning or Lexical Analysis (Linear Analysis): The blanks separating the characters of these tokens would normally be eliminated during the lexical analysis.
  • 9.  
  • 10. Syntax Analysis or Hierarchical Analysis (Parsing): Hierarchical analysis is called parsing or syntax analysis. It involves grouping the tokens of the source program into grammatical phases that are used by the compiler to synthesize output.
  • 11. Syntax Analysis or Hierarchical Analysis (Parsing): The grammatical phrases of the source program are represented by a parse tree.
  • 12. Syntax Analysis or Hierarchical Analysis (Parsing): In the expression initial + rate * 60 , the phrase rate * 60 is a logical unit because the usual conventions of arithmetic expressions tell us that the multiplication is performed before addition. Because the expression initial + rate is followed by a *, it is not grouped into a single phrase by itself
  • 13. Syntax Analysis or Hierarchical Analysis (Parsing): The hierarchical structure of a program is usually expressed by recursive rules. For example, we might have the following rules, as part of the definition of expression:
  • 14. Syntax Analysis or Hierarchical Analysis (Parsing): Any identifier is an expression. Any number is an expression If expression 1 and expression 2 are expressions, then so are Expression 1 + expression 2 Expression 1 * expression 2 (Expression 1 )
  • 15.  
  • 16. Semantic Analysis : The semantic analysis phase checks the source program for semantic errors and gathers type information for the subsequent code-generation phase.
  • 17. Semantic Analysis : It uses the hierarchical structure determined by the syntax-analysis phase to identify the operators and operand of expressions and statements.
  • 18. Semantic Analysis : An important component of semantic analysis is type checking. Here are the compiler checks that each operator has operands that are permitted by the source language specification.
  • 19. Semantic Analysis : For example, when a binary arithmetic operator is applied to an integer and real. In this case, the compiler may need to be converting the integer to a real. As shown in figure given below
  • 21. Ref: Compilers Principles, Techniques and Tools by Alfred V. Aho, Ravi Sethi, Jeffrey D. Ullman Tayyab Arif Allama Iqbal Open University [email_address] [email_address]