SlideShare ist ein Scribd-Unternehmen logo
1 von 79
CS40106 Compiler Design Compiler Design 40106
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
Course Outline ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
COMPILERS ,[object Object],[object Object],[object Object],Compiler Design 40106 ( Normally a program written in  a high-level programming language) ( Normally the equivalent program in machine code – relocatable object file)
Other Applications ,[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
Major Parts of Compilers ,[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
Phases of A Compiler Compiler Design 40106 Lexical  Analyzer Semantic  Analyzer Syntax  Analyzer Intermediate Code Generator Code  Optimizer Code Generator Target Program Source Program ,[object Object],[object Object],[object Object]
1. Lexical Analyzer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
2. Syntax Analyzer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106 ,[object Object],[object Object],[object Object]
Syntax Analyzer (CFG) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
Syntax Analyzer versus Lexical Analyzer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
Parsing Techniques ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
3. Semantic Analyzer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
4. Intermediate Code Generation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
Intermediate Code Generation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
5. Code Optimizer (for Intermediate Code Generator) ,[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
6. Code Generator ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
Phases of compiler Compiler Design 40106
Compiler Design 40106
The Structure of a Compiler  (8) Scanner  [Lexical Analyzer] Parser  [Syntax Analyzer] Semantic Process  [Semantic analyzer] Code Generator [Intermediate Code Generator] Code Optimizer Parse tree Abstract Syntax Tree w/ Attributes Non-optimized Intermediate Code Optimized Intermediate Code Code Genrator Target machine code Compiler Design 40106 Tokens
The input program as you see it. main () {    int i,sum;   sum = 0;   for (i=1; i<=10; i++);   sum = sum + i;   printf(&quot;%d&quot;,sum); }   Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Introducing Basic Terminology ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
Introducing Basic Terminology Compiler Design 40106 Token Sample Lexemes Informal Description of Pattern const if relation id num literal const if <, <=, =, < >, >, >= pi,  count ,  D2 3.1416,  0,  6.02E23 “ core dumped” const if < or <= or = or < > or >= or > letter followed by letters and digits any numeric constant any characters between “ and “ except “ Classifies Pattern ,[object Object],[object Object],[object Object],[object Object]
Attributes for Tokens Tokens influence parsing decision; the attributes influence the translation of tokens. Example: E = M * C ** 2 <id, pointer to symbol-table entry for E> <assign_op, > <id, pointer to symbol-table entry for M> <mult_op, > <id, pointer to symbol-table entry for C> <exp_op, > <num, integer value 2> Compiler Design 40106
Role of the Lexical Analyzer Compiler Design 40106
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
Compiler Design 40106
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106
 
Compiler Design 40106
Compiler Design 40106
Compiler Design 40106

Weitere ähnliche Inhalte

Was ist angesagt?

Compiler Design
Compiler DesignCompiler Design
Compiler Design
Mir Majid
 

Was ist angesagt? (20)

Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
 
Compiler design syntax analysis
Compiler design syntax analysisCompiler design syntax analysis
Compiler design syntax analysis
 
Compiler design
Compiler designCompiler design
Compiler design
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsing
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Yacc
YaccYacc
Yacc
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
 
Compilers
CompilersCompilers
Compilers
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design
 
Predictive parser
Predictive parserPredictive parser
Predictive parser
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
The role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler designThe role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler design
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler Design
 
Bootstrapping in Compiler
Bootstrapping in CompilerBootstrapping in Compiler
Bootstrapping in Compiler
 
Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)
 

Andere mochten auch

Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
rawan_z
 

Andere mochten auch (20)

Role-of-lexical-analysis
Role-of-lexical-analysisRole-of-lexical-analysis
Role-of-lexical-analysis
 
Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler design
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
Optimization of dfa
Optimization of dfaOptimization of dfa
Optimization of dfa
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsing
 
Programming languages,compiler,interpreter,softwares
Programming languages,compiler,interpreter,softwaresProgramming languages,compiler,interpreter,softwares
Programming languages,compiler,interpreter,softwares
 
NFA to DFA
NFA to DFANFA to DFA
NFA to DFA
 
DFA Minimization
DFA MinimizationDFA Minimization
DFA Minimization
 
optimization of DFA
optimization of DFAoptimization of DFA
optimization of DFA
 
Dfa vs nfa
Dfa vs nfaDfa vs nfa
Dfa vs nfa
 
Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFA
 
Nfa vs dfa
Nfa vs dfaNfa vs dfa
Nfa vs dfa
 
Programming Languages / Translators
Programming Languages / TranslatorsProgramming Languages / Translators
Programming Languages / Translators
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
 
Language translator
Language translatorLanguage translator
Language translator
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Code generation
Code generationCode generation
Code generation
 

Ähnlich wie Lexical analyzer

Chapter One
Chapter OneChapter One
Chapter One
bolovv
 
1 - Introduction to Compilers.ppt
1 - Introduction to Compilers.ppt1 - Introduction to Compilers.ppt
1 - Introduction to Compilers.ppt
Rakesh Kumar
 
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
venkatapranaykumarGa
 

Ähnlich wie Lexical analyzer (20)

lec00-Introduction.pdf
lec00-Introduction.pdflec00-Introduction.pdf
lec00-Introduction.pdf
 
Chapter One
Chapter OneChapter One
Chapter One
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
 
1._Introduction_.pptx
1._Introduction_.pptx1._Introduction_.pptx
1._Introduction_.pptx
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 
Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
 
unit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdfunit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdf
 
LANGUAGE TRANSLATOR
LANGUAGE TRANSLATORLANGUAGE TRANSLATOR
LANGUAGE TRANSLATOR
 
Chapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdf
 
Assignment1
Assignment1Assignment1
Assignment1
 
role of lexical anaysis
role of lexical anaysisrole of lexical anaysis
role of lexical anaysis
 
Compiler
Compiler Compiler
Compiler
 
Compiler design and lexical analyser
Compiler design and lexical analyserCompiler design and lexical analyser
Compiler design and lexical analyser
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
 
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
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
 
1 - Introduction to Compilers.ppt
1 - Introduction to Compilers.ppt1 - Introduction to Compilers.ppt
1 - Introduction to Compilers.ppt
 
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
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 

Kürzlich hochgeladen

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 

Kürzlich hochgeladen (20)

psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 

Lexical analyzer

Hinweis der Redaktion

  1. lec00-outline August 9, 2011