SlideShare une entreprise Scribd logo
1  sur  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.

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
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
 
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
 
[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
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
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
 
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
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 

Dernier (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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...
 
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)
 
[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
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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
 
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
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 

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.

Notes de l'éditeur

  1. Module 1.3 – Data Protection: RAID