SlideShare una empresa de Scribd logo
1 de 19
Introduction of
Compiler
UNIT I & II
UNIT I Compiling TAMILSELVI T 2
COMPILERS
 Compilers are basically a Translators
 A compiler is a program takes a program written in a source
language and translates it into an equivalent program in a target
language.
UNIT I Compiling TAMILSELVI T 3
Analysis of Source Program
 Analysis consists of three phases:
 Linear Analysis (Lexical Analysis or Scanning)

Group the source string into Tokens
 Hierarchical Analysis (Syntax Analysis or Parsing)

Tokens are grouped into nested collections
 Semantic Analysis

Ensure the correctness of the source program
UNIT I Compiling TAMILSELVI T 4
Phases of Compiler
UNIT I Compiling TAMILSELVI T 5
Lexical Analysis
 Linear Analysis (Lexical Analysis or Scanning)
 Scan the complete source code
 Source program is broken up into group of strings called tokens
Example: position := initial+rate*60

The identifier position

The Assignment Symbol

The identifier initial

The plus sign

The identifier rate

The multiplication sign

The constant 60
UNIT I Compiling TAMILSELVI T 6
Syntax Analysis
 Hierarchical Analysis (Parsing)
 Grouping the tokens into grammatical Phrases
 Grammatical Phrases are represented by Parse Tree or Syntax
Tree
UNIT I Compiling TAMILSELVI T 7
Semantic Analysis
 Type checking
 checks the source program for semantic errors
 collects the type information
UNIT I Compiling TAMILSELVI T 8
Intermediate Code Generation
 Three Address Code
 Sequence of instructions each of which has atmost three
operands
 Properties:
 Easy to produce
 Easy to translate into target program
Example
t1 := inttoreal(60)
t2 := id3*t1
t3 := id2+t2
id1 := t3
UNIT I Compiling TAMILSELVI T 9
Code Optimization
 Improve the intermediate code (Improve the running time of the
target program)
Example
t1 := id3*60.0
id1 := id2+t1
UNIT I Compiling TAMILSELVI T 10
Code Generation
 Intermediate code instruction are translated into sequence of
machine instruction
 Example
MOVF id3,R2
MULF #60.0,R2
MOVF id2,R1
ADDF R2,R1
MOVF R1,id1
UNIT I Compiling TAMILSELVI T 11
Symbol Table Management
 A data structure containing a record for each identifier
 Stores the information about the attributes of all identifiers
 Attributes : name, type, size etc.
Error Detection and Handling
 It detects and handle the errors (Syntax error, Semantic errors)
 Errors are reported in the form of messages
UNIT I Compiling TAMILSELVI T 12
Cousins of Compiler
 Preprocessors
 Macro processing
 File inclusion
 Assemblers
 Loaders and Link-Editors
UNIT I Compiling TAMILSELVI T 13
Grouping of Phases
 Front end
 Primarily depends on the source language and independent
on the target language
 It includes lexical analysis, Syntax analysis and semantic
analysis
 Back end
 Primarily depends on the target language and independent
on the source language
 It includes code generation and code optimization
UNIT I Compiling TAMILSELVI T 14
Compiler Construction Tools
 Parser Generator
 Scanner Generator
 Syntax directed translation Engine
 Automatic code generator
 Data flow engine
UNIT I Compiling TAMILSELVI T 15
Lexical Analysis
 Input is scanned completely to identify the tokens
 Tokens (Logical unit)
 Identifier, Keywords, operators etc.
UNIT I Compiling TAMILSELVI T 16
Specification of Tokens
 Strings and Languages

Finite sequence of Symbols is called Strings

Set of strings over some alphabet is called Language
 Operation on Languages

Concatenation:
 L1L2 = { s1s2| s1∈ L1 and s2∈ L2}

Union
 L1 ∪ L2 = { s| s∈ L1 or s∈ L2}

Kleene Closure
 L* =

Positive Closure
 L+ =
 Regular Expressions

∞
=1i
i
L

∞
=0i
i
L
UNIT I Compiling TAMILSELVI T 17
Regular Expression
 Notation for representing Tokens
 Ex: Identifiers in Pascal
letter → A | B | ... | Z | a | b | ... | z
digit → 0 | 1 | ... | 9
id → letter (letter | digit ) *
UNIT I Compiling TAMILSELVI T 18
Recognition of Tokens
 Finite Automata
 DFA –
 NFA –
10 2
a b
start
a
b
10 2
ba
b
b a
UNIT I Compiling TAMILSELVI T 19
Questions
Part -A
 What are the issues of Lexical analyzer?
 Define compiler.
 What is preprocessor?
 What is finite automata?
 Draw the transition diagram to represent relational operators.
 Define Lexeme, pattern.
Part -B
 Explain the various phases of compiler.
 Explain the compiler construction tools.
 Explain input buffering in detail
 Write and explain about specification of tokens
 Construct NFA from the regular expression.

Más contenido relacionado

La actualidad más candente

Compiler Construction
Compiler ConstructionCompiler Construction
Compiler ConstructionSarmad Ali
 
phases of compiler-analysis phase
phases of compiler-analysis phasephases of compiler-analysis phase
phases of compiler-analysis phaseSuyash Srivastava
 
Phases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingPhases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingMukesh Tekwani
 
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
 
Different phases of a compiler
Different phases of a compilerDifferent phases of a compiler
Different phases of a compilerSumit Sinha
 
Compiler design
Compiler designCompiler design
Compiler designsanchi29
 
7 compiler lab
7 compiler lab 7 compiler lab
7 compiler lab MashaelQ
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compilerSudhaa Ravi
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler designJanani Parthiban
 
Compiler designs presentation final
Compiler designs presentation  finalCompiler designs presentation  final
Compiler designs presentation finalilias ahmed
 
Cs6660 compiler design
Cs6660 compiler designCs6660 compiler design
Cs6660 compiler designhari2010
 
Compiler Engineering Lab#1
Compiler Engineering Lab#1Compiler Engineering Lab#1
Compiler Engineering Lab#1MashaelQ
 
Workshop Assembler
Workshop AssemblerWorkshop Assembler
Workshop AssemblerTuhin_Das
 

La actualidad más candente (20)

P code
P codeP code
P code
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
phases of compiler-analysis phase
phases of compiler-analysis phasephases of compiler-analysis phase
phases of compiler-analysis phase
 
Phases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingPhases of the Compiler - Systems Programming
Phases of the Compiler - Systems Programming
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
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
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 
Compiler1
Compiler1Compiler1
Compiler1
 
Unit 1 cd
Unit 1 cdUnit 1 cd
Unit 1 cd
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Different phases of a compiler
Different phases of a compilerDifferent phases of a compiler
Different phases of a compiler
 
Compiler design
Compiler designCompiler design
Compiler design
 
7 compiler lab
7 compiler lab 7 compiler lab
7 compiler lab
 
Compiler unit 1
Compiler unit 1Compiler unit 1
Compiler unit 1
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compiler
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler design
 
Compiler designs presentation final
Compiler designs presentation  finalCompiler designs presentation  final
Compiler designs presentation final
 
Cs6660 compiler design
Cs6660 compiler designCs6660 compiler design
Cs6660 compiler design
 
Compiler Engineering Lab#1
Compiler Engineering Lab#1Compiler Engineering Lab#1
Compiler Engineering Lab#1
 
Workshop Assembler
Workshop AssemblerWorkshop Assembler
Workshop Assembler
 

Destacado (20)

Chapter one
Chapter oneChapter one
Chapter one
 
IS 151 Lecture 3
IS 151 Lecture 3IS 151 Lecture 3
IS 151 Lecture 3
 
Chap 10(structure and unions)
Chap 10(structure and unions)Chap 10(structure and unions)
Chap 10(structure and unions)
 
IS 139 Lecture 7
IS 139 Lecture 7IS 139 Lecture 7
IS 139 Lecture 7
 
IS 151 - Lecture 3
IS 151 - Lecture 3IS 151 - Lecture 3
IS 151 - Lecture 3
 
Truth table analysis
Truth table analysisTruth table analysis
Truth table analysis
 
IS 151 Lecture 2
IS 151 Lecture 2IS 151 Lecture 2
IS 151 Lecture 2
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
 
aaالمملكة العربية السعودية
aaالمملكة العربية السعوديةaaالمملكة العربية السعودية
aaالمملكة العربية السعودية
 
Compiler interpreter and_bootstrapping
Compiler interpreter and_bootstrappingCompiler interpreter and_bootstrapping
Compiler interpreter and_bootstrapping
 
Logical and Conditional Operator In C language
Logical and Conditional Operator In C languageLogical and Conditional Operator In C language
Logical and Conditional Operator In C language
 
C Structures and Unions
C Structures and UnionsC Structures and Unions
C Structures and Unions
 
Logic gates
Logic gatesLogic gates
Logic gates
 
Hierarchical Memory System
Hierarchical Memory SystemHierarchical Memory System
Hierarchical Memory System
 
C Structures & Unions
C Structures & UnionsC Structures & Unions
C Structures & Unions
 
Memory Hierarchy
Memory HierarchyMemory Hierarchy
Memory Hierarchy
 
Truth tables
Truth tablesTruth tables
Truth tables
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
C pointer
C pointerC pointer
C pointer
 
Introduction to compilers
Introduction to compilersIntroduction to compilers
Introduction to compilers
 

Similar a Cd unit i

1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdfSemsemSameer1
 
33-Procedures-Switch Case Statements-27-03-2024.pdf
33-Procedures-Switch Case Statements-27-03-2024.pdf33-Procedures-Switch Case Statements-27-03-2024.pdf
33-Procedures-Switch Case Statements-27-03-2024.pdfYash218469
 
Cs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer KeyCs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer Keyappasami
 
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
 
COMPILER DESIGN.pdf
COMPILER DESIGN.pdfCOMPILER DESIGN.pdf
COMPILER DESIGN.pdfManishBej3
 
Chapter One
Chapter OneChapter One
Chapter Onebolovv
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docxvenkatapranaykumarGa
 
Compiler design important questions
Compiler design   important questionsCompiler design   important questions
Compiler design important questionsakila viji
 
Compiler design and lexical analyser
Compiler design and lexical analyserCompiler design and lexical analyser
Compiler design and lexical analyserabhishek gupta
 
Chapter1 Introduction of compiler
Chapter1 Introduction of compiler Chapter1 Introduction of compiler
Chapter1 Introduction of compiler Danish Alam
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical AnalysisMunni28
 
Intermediate code representations
Intermediate code representationsIntermediate code representations
Intermediate code representationsahmed51236
 
New compiler design 101 April 13 2024.pdf
New compiler design 101 April 13 2024.pdfNew compiler design 101 April 13 2024.pdf
New compiler design 101 April 13 2024.pdfeliasabdi2024
 

Similar a Cd unit i (20)

Compilers Design
Compilers DesignCompilers Design
Compilers Design
 
Pcd question bank
Pcd question bank Pcd question bank
Pcd question bank
 
1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf
 
33-Procedures-Switch Case Statements-27-03-2024.pdf
33-Procedures-Switch Case Statements-27-03-2024.pdf33-Procedures-Switch Case Statements-27-03-2024.pdf
33-Procedures-Switch Case Statements-27-03-2024.pdf
 
Cs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer KeyCs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer Key
 
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
 
COMPILER DESIGN.pdf
COMPILER DESIGN.pdfCOMPILER DESIGN.pdf
COMPILER DESIGN.pdf
 
Chapter 6 Intermediate Code Generation
Chapter 6   Intermediate Code GenerationChapter 6   Intermediate Code Generation
Chapter 6 Intermediate Code Generation
 
Chapter One
Chapter OneChapter One
Chapter One
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 
Compiler design important questions
Compiler design   important questionsCompiler design   important questions
Compiler design important questions
 
Compiler design and lexical analyser
Compiler design and lexical analyserCompiler design and lexical analyser
Compiler design and lexical analyser
 
Chapter1 Introduction of compiler
Chapter1 Introduction of compiler Chapter1 Introduction of compiler
Chapter1 Introduction of compiler
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
 
Language processors
Language processorsLanguage processors
Language processors
 
Lecture 21 22
Lecture 21 22Lecture 21 22
Lecture 21 22
 
C-PROGRAM
C-PROGRAMC-PROGRAM
C-PROGRAM
 
Intermediate code representations
Intermediate code representationsIntermediate code representations
Intermediate code representations
 
New compiler design 101 April 13 2024.pdf
New compiler design 101 April 13 2024.pdfNew compiler design 101 April 13 2024.pdf
New compiler design 101 April 13 2024.pdf
 

Último

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Último (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Cd unit i

  • 2. UNIT I Compiling TAMILSELVI T 2 COMPILERS  Compilers are basically a Translators  A compiler is a program takes a program written in a source language and translates it into an equivalent program in a target language.
  • 3. UNIT I Compiling TAMILSELVI T 3 Analysis of Source Program  Analysis consists of three phases:  Linear Analysis (Lexical Analysis or Scanning)  Group the source string into Tokens  Hierarchical Analysis (Syntax Analysis or Parsing)  Tokens are grouped into nested collections  Semantic Analysis  Ensure the correctness of the source program
  • 4. UNIT I Compiling TAMILSELVI T 4 Phases of Compiler
  • 5. UNIT I Compiling TAMILSELVI T 5 Lexical Analysis  Linear Analysis (Lexical Analysis or Scanning)  Scan the complete source code  Source program is broken up into group of strings called tokens Example: position := initial+rate*60  The identifier position  The Assignment Symbol  The identifier initial  The plus sign  The identifier rate  The multiplication sign  The constant 60
  • 6. UNIT I Compiling TAMILSELVI T 6 Syntax Analysis  Hierarchical Analysis (Parsing)  Grouping the tokens into grammatical Phrases  Grammatical Phrases are represented by Parse Tree or Syntax Tree
  • 7. UNIT I Compiling TAMILSELVI T 7 Semantic Analysis  Type checking  checks the source program for semantic errors  collects the type information
  • 8. UNIT I Compiling TAMILSELVI T 8 Intermediate Code Generation  Three Address Code  Sequence of instructions each of which has atmost three operands  Properties:  Easy to produce  Easy to translate into target program Example t1 := inttoreal(60) t2 := id3*t1 t3 := id2+t2 id1 := t3
  • 9. UNIT I Compiling TAMILSELVI T 9 Code Optimization  Improve the intermediate code (Improve the running time of the target program) Example t1 := id3*60.0 id1 := id2+t1
  • 10. UNIT I Compiling TAMILSELVI T 10 Code Generation  Intermediate code instruction are translated into sequence of machine instruction  Example MOVF id3,R2 MULF #60.0,R2 MOVF id2,R1 ADDF R2,R1 MOVF R1,id1
  • 11. UNIT I Compiling TAMILSELVI T 11 Symbol Table Management  A data structure containing a record for each identifier  Stores the information about the attributes of all identifiers  Attributes : name, type, size etc. Error Detection and Handling  It detects and handle the errors (Syntax error, Semantic errors)  Errors are reported in the form of messages
  • 12. UNIT I Compiling TAMILSELVI T 12 Cousins of Compiler  Preprocessors  Macro processing  File inclusion  Assemblers  Loaders and Link-Editors
  • 13. UNIT I Compiling TAMILSELVI T 13 Grouping of Phases  Front end  Primarily depends on the source language and independent on the target language  It includes lexical analysis, Syntax analysis and semantic analysis  Back end  Primarily depends on the target language and independent on the source language  It includes code generation and code optimization
  • 14. UNIT I Compiling TAMILSELVI T 14 Compiler Construction Tools  Parser Generator  Scanner Generator  Syntax directed translation Engine  Automatic code generator  Data flow engine
  • 15. UNIT I Compiling TAMILSELVI T 15 Lexical Analysis  Input is scanned completely to identify the tokens  Tokens (Logical unit)  Identifier, Keywords, operators etc.
  • 16. UNIT I Compiling TAMILSELVI T 16 Specification of Tokens  Strings and Languages  Finite sequence of Symbols is called Strings  Set of strings over some alphabet is called Language  Operation on Languages  Concatenation:  L1L2 = { s1s2| s1∈ L1 and s2∈ L2}  Union  L1 ∪ L2 = { s| s∈ L1 or s∈ L2}  Kleene Closure  L* =  Positive Closure  L+ =  Regular Expressions  ∞ =1i i L  ∞ =0i i L
  • 17. UNIT I Compiling TAMILSELVI T 17 Regular Expression  Notation for representing Tokens  Ex: Identifiers in Pascal letter → A | B | ... | Z | a | b | ... | z digit → 0 | 1 | ... | 9 id → letter (letter | digit ) *
  • 18. UNIT I Compiling TAMILSELVI T 18 Recognition of Tokens  Finite Automata  DFA –  NFA – 10 2 a b start a b 10 2 ba b b a
  • 19. UNIT I Compiling TAMILSELVI T 19 Questions Part -A  What are the issues of Lexical analyzer?  Define compiler.  What is preprocessor?  What is finite automata?  Draw the transition diagram to represent relational operators.  Define Lexeme, pattern. Part -B  Explain the various phases of compiler.  Explain the compiler construction tools.  Explain input buffering in detail  Write and explain about specification of tokens  Construct NFA from the regular expression.

Notas del editor

  1. Module 1.3 – Data Protection: RAID