尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
LEXICAL
ANALYSIS
Lexical Analysis
Lexical analysis is the process of converting a
sequence of characters from source program into a
sequence of tokens.
Role of Lexical Analyzer
Lexical analyzer performs the following tasks:
• Reads the source program, scans the input characters,
group them into lexemes and produce the token as output.
• Enters the identified token into the symbol table.
• Strips out white spaces and comments from source
program.
• Correlates error messages with the source program i.e.,
displays error message with its occurrence by specifying the
line number.
• Expands the macros if it is found in the source program.
Need of Lexical Analyzer
Simplicity of design of compiler The removal of white
spaces and comments enables the syntax analyzer for
efficient syntactic constructs.
Compiler efficiency is improved Specialized buffering
techniques for reading characters speed up the
compiler process
TYPES OF LEXICAL
ANALYSIS
A program which performs lexical analysis is termed as a
lexical analyzer (lexer), tokenizer or scanner.
Lexical analysis consists of two stages of processing which
are as follows:
• Scanning
• Tokenization
Token
Token is a valid sequence of characters which are given by lexeme.
In a programming language :
• keywords,
• constant,
• identifiers,
• numbers,
• operators and
• punctuations symbols
are possible tokens to be identified.
Pattern
Pattern describes a rule that must be matched by
sequence of characters (lexemes) to form a token. It
can be defined by regular expressions or grammar
rules.
Lexeme
Lexeme is a sequence of characters that matches
the pattern for a token i.e., instance of a token.
Example
C = a + b*5;
Tasks of lexical analyzer can be divided into two
processes:
Scanning: Performs reading of input characters, removal
of white spaces and comments.
Lexical Analysis: Produce tokens as the output.
Task
Lexical analysis is the process of producing tokens from the
source program. It has the following issues:
• Lookahead
• Ambiguities
ISSUES
Lookahead
Lookahead is required to decide when one token will end
and the next token will begin. The simple example which
has lookahead.
Ambiguities
If a language or syntax by when we can produce two or
more parse tree then that is ambiguity and this grammar is
called ambiguity grammar.
When more than one expression can match the current
input chooses as follows:
• The longest match is preferred.
• Among rules which matched the same number of
characters, the rule given first is preferred.
Lexical Errors
1. A character sequence that cannot be scanned into any valid
token is a lexical error.
2.Lexical errors are uncommon, but they still must be handled by a
scanner.
3.Misspelling of identifiers, keyword, or operators are considered
as lexical errors.
Usually, a lexical error is caused by the appearance of some illegal
character, mostly at the beginning of a token.
THANK
YOU

More Related Content

What's hot

Direct linking loaders
Direct linking loadersDirect linking loaders
Direct linking loaders
Satyamevjayte Haxor
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
Radhika Talaviya
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
Huawei Technologies
 
Language processing activity
Language processing activityLanguage processing activity
Language processing activity
Dhruv Sabalpara
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
Tanzeela_Hussain
 
Compilers
CompilersCompilers
Compilers
Bense Tony
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
Aman Sharma
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
shah zeb
 
Lex
LexLex
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLR
Riazul Islam
 
Compiler design and lexical analyser
Compiler design and lexical analyserCompiler design and lexical analyser
Compiler design and lexical analyser
abhishek gupta
 
Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysis
Iffat Anjum
 
Compiler construction
Compiler constructionCompiler construction
Compiler construction
Muhammed Afsal Villan
 
Parse Tree
Parse TreeParse Tree
Parse Tree
A. S. M. Shafi
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & Recovery
Akhil Kaushik
 
Compiler Design Introduction
Compiler Design IntroductionCompiler Design Introduction
Compiler Design Introduction
Richa Sharma
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
raosir123
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
Munni28
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
desta_gebre
 
Parsing LL(1), SLR, LR(1)
Parsing LL(1), SLR, LR(1)Parsing LL(1), SLR, LR(1)
Parsing LL(1), SLR, LR(1)
Nitin Mohan Sharma
 

What's hot (20)

Direct linking loaders
Direct linking loadersDirect linking loaders
Direct linking loaders
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
 
Language processing activity
Language processing activityLanguage processing activity
Language processing activity
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Compilers
CompilersCompilers
Compilers
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Lex
LexLex
Lex
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLR
 
Compiler design and lexical analyser
Compiler design and lexical analyserCompiler design and lexical analyser
Compiler design and lexical analyser
 
Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysis
 
Compiler construction
Compiler constructionCompiler construction
Compiler construction
 
Parse Tree
Parse TreeParse Tree
Parse Tree
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & Recovery
 
Compiler Design Introduction
Compiler Design IntroductionCompiler Design Introduction
Compiler Design Introduction
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
 
Assemblers: Ch03
Assemblers: Ch03Assemblers: Ch03
Assemblers: Ch03
 
Parsing LL(1), SLR, LR(1)
Parsing LL(1), SLR, LR(1)Parsing LL(1), SLR, LR(1)
Parsing LL(1), SLR, LR(1)
 

Similar to Lexical Analysis

Lexical Analysis.pdf
Lexical Analysis.pdfLexical Analysis.pdf
Lexical Analysis.pdf
BiswanathSethi2
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
ElakkiaU
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
A. S. M. Shafi
 
Cd ch2 - lexical analysis
Cd   ch2 - lexical analysisCd   ch2 - lexical analysis
Cd ch2 - lexical analysis
mengistu23
 
automata theroy and compiler designc.pptx
automata theroy and compiler designc.pptxautomata theroy and compiler designc.pptx
automata theroy and compiler designc.pptx
YashaswiniYashu9555
 
Compilers in computer programming
Compilers in computer programmingCompilers in computer programming
Compilers in computer programming
Chetan Pandey
 
A Role of Lexical Analyzer
A Role of Lexical AnalyzerA Role of Lexical Analyzer
A Role of Lexical Analyzer
Archana Gopinath
 
Compiler Design.pptx
Compiler Design.pptxCompiler Design.pptx
Compiler Design.pptx
SouvikRoy149
 
11700220036.pdf
11700220036.pdf11700220036.pdf
11700220036.pdf
SouvikRoy149
 
Module 2
Module 2 Module 2
Module 2
ShwetaNirmanik
 
SS & CD Module 3
SS & CD Module 3 SS & CD Module 3
SS & CD Module 3
ShwetaNirmanik
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Anujashejwal
 
Module4 lex and yacc.ppt
Module4 lex and yacc.pptModule4 lex and yacc.ppt
Module4 lex and yacc.ppt
ProddaturNagaVenkata
 
compiler introduction vtu syllabus 1st chapter.pptx
compiler introduction vtu syllabus 1st chapter.pptxcompiler introduction vtu syllabus 1st chapter.pptx
compiler introduction vtu syllabus 1st chapter.pptx
ranjan317165
 
Plc part 2
Plc  part 2Plc  part 2
Plc part 2
Taymoor Nazmy
 
Compiler lec 8
Compiler lec 8Compiler lec 8
Compiler lec 8
Ramadan Babers, PhD
 
Compiler lecture 04
Compiler lecture 04Compiler lecture 04
Compiler lecture 04
University of Chitral
 
Compiler lecture 04
Compiler lecture 04Compiler lecture 04
Compiler lecture 04
University of Chitral
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
Rossy719186
 
1._Introduction_.pptx
1._Introduction_.pptx1._Introduction_.pptx
1._Introduction_.pptx
Anbarasan Radhakrishnan R
 

Similar to Lexical Analysis (20)

Lexical Analysis.pdf
Lexical Analysis.pdfLexical Analysis.pdf
Lexical Analysis.pdf
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
 
Cd ch2 - lexical analysis
Cd   ch2 - lexical analysisCd   ch2 - lexical analysis
Cd ch2 - lexical analysis
 
automata theroy and compiler designc.pptx
automata theroy and compiler designc.pptxautomata theroy and compiler designc.pptx
automata theroy and compiler designc.pptx
 
Compilers in computer programming
Compilers in computer programmingCompilers in computer programming
Compilers in computer programming
 
A Role of Lexical Analyzer
A Role of Lexical AnalyzerA Role of Lexical Analyzer
A Role of Lexical Analyzer
 
Compiler Design.pptx
Compiler Design.pptxCompiler Design.pptx
Compiler Design.pptx
 
11700220036.pdf
11700220036.pdf11700220036.pdf
11700220036.pdf
 
Module 2
Module 2 Module 2
Module 2
 
SS & CD Module 3
SS & CD Module 3 SS & CD Module 3
SS & CD Module 3
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Module4 lex and yacc.ppt
Module4 lex and yacc.pptModule4 lex and yacc.ppt
Module4 lex and yacc.ppt
 
compiler introduction vtu syllabus 1st chapter.pptx
compiler introduction vtu syllabus 1st chapter.pptxcompiler introduction vtu syllabus 1st chapter.pptx
compiler introduction vtu syllabus 1st chapter.pptx
 
Plc part 2
Plc  part 2Plc  part 2
Plc part 2
 
Compiler lec 8
Compiler lec 8Compiler lec 8
Compiler lec 8
 
Compiler lecture 04
Compiler lecture 04Compiler lecture 04
Compiler lecture 04
 
Compiler lecture 04
Compiler lecture 04Compiler lecture 04
Compiler lecture 04
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
 
1._Introduction_.pptx
1._Introduction_.pptx1._Introduction_.pptx
1._Introduction_.pptx
 

Recently uploaded

🔥Premium Call Girls In Bangalore 💯Call Us 🔝 9352988975 🔝💃Top Class Call Girl ...
🔥Premium Call Girls In Bangalore 💯Call Us 🔝 9352988975 🔝💃Top Class Call Girl ...🔥Premium Call Girls In Bangalore 💯Call Us 🔝 9352988975 🔝💃Top Class Call Girl ...
🔥Premium Call Girls In Bangalore 💯Call Us 🔝 9352988975 🔝💃Top Class Call Girl ...
Sanjna Singh
 
Pune Call Girls ♠ 9352988975 ♠ Beautiful Call Girls In Pune
Pune Call Girls  ♠ 9352988975 ♠ Beautiful Call Girls In PunePune Call Girls  ♠ 9352988975 ♠ Beautiful Call Girls In Pune
Pune Call Girls ♠ 9352988975 ♠ Beautiful Call Girls In Pune
meenusingh4354543
 
一比一原版加拿大瑞尔森大学毕业证如何办理
一比一原版加拿大瑞尔森大学毕业证如何办理一比一原版加拿大瑞尔森大学毕业证如何办理
一比一原版加拿大瑞尔森大学毕业证如何办理
oydykuz
 
一比一原版(范莎毕业证书)加拿大范莎学院毕业证如何办理
一比一原版(范莎毕业证书)加拿大范莎学院毕业证如何办理一比一原版(范莎毕业证书)加拿大范莎学院毕业证如何办理
一比一原版(范莎毕业证书)加拿大范莎学院毕业证如何办理
0dtluq4l
 
Call Girls Jaipur 📞 8445551418 🌟Door Step Delivery We Offering You 100% Genuine
Call Girls Jaipur 📞 8445551418 🌟Door Step Delivery We Offering You 100% GenuineCall Girls Jaipur 📞 8445551418 🌟Door Step Delivery We Offering You 100% Genuine
Call Girls Jaipur 📞 8445551418 🌟Door Step Delivery We Offering You 100% Genuine
parulsinha
 
jaipur Call Girls service 8445551418 Call Girl service in jaipur Call Girls S...
jaipur Call Girls service 8445551418 Call Girl service in jaipur Call Girls S...jaipur Call Girls service 8445551418 Call Girl service in jaipur Call Girls S...
jaipur Call Girls service 8445551418 Call Girl service in jaipur Call Girls S...
dayajeetsingh776
 
Call Girls Varanasi 8824825030 Escort In Varanasi service 24X7
Call Girls Varanasi 8824825030 Escort In Varanasi service 24X7Call Girls Varanasi 8824825030 Escort In Varanasi service 24X7
Call Girls Varanasi 8824825030 Escort In Varanasi service 24X7
sexytaniya455
 
Value based approach to heritae conservation -.docx
Value based approach to heritae conservation -.docxValue based approach to heritae conservation -.docx
Value based approach to heritae conservation -.docx
JIT KUMAR GUPTA
 
SPICE PARK JUN2024 ( 6,826 SPICE Models )
SPICE PARK JUN2024 ( 6,826 SPICE Models )SPICE PARK JUN2024 ( 6,826 SPICE Models )
SPICE PARK JUN2024 ( 6,826 SPICE Models )
Tsuyoshi Horigome
 
Call Girls in Kolkata (7426014248) call me [🔝Kolkata🔝] Escort In Kolkata serv...
Call Girls in Kolkata (7426014248) call me [🔝Kolkata🔝] Escort In Kolkata serv...Call Girls in Kolkata (7426014248) call me [🔝Kolkata🔝] Escort In Kolkata serv...
Call Girls in Kolkata (7426014248) call me [🔝Kolkata🔝] Escort In Kolkata serv...
zoyat9250
 
Update 33 models(General Diode ) in SPICE PARK(JUN2024)
Update 33 models(General Diode ) in SPICE PARK(JUN2024)Update 33 models(General Diode ) in SPICE PARK(JUN2024)
Update 33 models(General Diode ) in SPICE PARK(JUN2024)
Tsuyoshi Horigome
 
World trade center in kerala proposal- AR. DEEKSHITH MAROLI 724519251008 REPORT
World trade center in kerala proposal- AR. DEEKSHITH MAROLI 724519251008 REPORTWorld trade center in kerala proposal- AR. DEEKSHITH MAROLI 724519251008 REPORT
World trade center in kerala proposal- AR. DEEKSHITH MAROLI 724519251008 REPORT
deekshithmaroli666
 
Call Girls jaipur ☎️ +91-8445551418 😍 jaipur Call Girl Beauty Girls @ Afforda...
Call Girls jaipur ☎️ +91-8445551418 😍 jaipur Call Girl Beauty Girls @ Afforda...Call Girls jaipur ☎️ +91-8445551418 😍 jaipur Call Girl Beauty Girls @ Afforda...
Call Girls jaipur ☎️ +91-8445551418 😍 jaipur Call Girl Beauty Girls @ Afforda...
VipTaniya Dubay
 
Future Deep Strike Aircraft Thor Design Study Stage 1.pdf
Future Deep Strike Aircraft Thor Design Study Stage 1.pdfFuture Deep Strike Aircraft Thor Design Study Stage 1.pdf
Future Deep Strike Aircraft Thor Design Study Stage 1.pdf
Geoffrey Wardle. MSc. MSc. Snr.MAIAA
 
Call Girls Ahmedabad( 🤑 7488326553 🤑) Vip Call Girl Ahmedabad
Call Girls Ahmedabad( 🤑 7488326553 🤑) Vip Call Girl AhmedabadCall Girls Ahmedabad( 🤑 7488326553 🤑) Vip Call Girl Ahmedabad
Call Girls Ahmedabad( 🤑 7488326553 🤑) Vip Call Girl Ahmedabad
babesbookhot
 
🔥Mumbai Call Girls Contact Number 🔝👉 9833363713 👈🔝High Calass Call Girl Mumbai
🔥Mumbai Call Girls Contact Number 🔝👉 9833363713 👈🔝High Calass Call Girl Mumbai🔥Mumbai Call Girls Contact Number 🔝👉 9833363713 👈🔝High Calass Call Girl Mumbai
🔥Mumbai Call Girls Contact Number 🔝👉 9833363713 👈🔝High Calass Call Girl Mumbai
Sifa Khan#i11
 
(Introduction to canva and canva strategies) CANVA PPT.pptx
(Introduction to canva and canva strategies) CANVA PPT.pptx(Introduction to canva and canva strategies) CANVA PPT.pptx
(Introduction to canva and canva strategies) CANVA PPT.pptx
KristeleJoyRaralio1
 
Call Girls Vijayawada 8824825030 Escort In Vijayawada service 24X7
Call Girls Vijayawada 8824825030 Escort In Vijayawada service 24X7Call Girls Vijayawada 8824825030 Escort In Vijayawada service 24X7
Call Girls Vijayawada 8824825030 Escort In Vijayawada service 24X7
Poonam Singh
 
Call Girls In Jaipur {8445551418} ❤️VVIP JIYA Call Girl in Jaipur Rajasthan
Call Girls In Jaipur {8445551418} ❤️VVIP JIYA Call Girl in Jaipur RajasthanCall Girls In Jaipur {8445551418} ❤️VVIP JIYA Call Girl in Jaipur Rajasthan
Call Girls In Jaipur {8445551418} ❤️VVIP JIYA Call Girl in Jaipur Rajasthan
ishu38418
 
一比一原版(brunel毕业证书)布鲁内尔大学毕业证如何办理
一比一原版(brunel毕业证书)布鲁内尔大学毕业证如何办理一比一原版(brunel毕业证书)布鲁内尔大学毕业证如何办理
一比一原版(brunel毕业证书)布鲁内尔大学毕业证如何办理
aprhf21y
 

Recently uploaded (20)

🔥Premium Call Girls In Bangalore 💯Call Us 🔝 9352988975 🔝💃Top Class Call Girl ...
🔥Premium Call Girls In Bangalore 💯Call Us 🔝 9352988975 🔝💃Top Class Call Girl ...🔥Premium Call Girls In Bangalore 💯Call Us 🔝 9352988975 🔝💃Top Class Call Girl ...
🔥Premium Call Girls In Bangalore 💯Call Us 🔝 9352988975 🔝💃Top Class Call Girl ...
 
Pune Call Girls ♠ 9352988975 ♠ Beautiful Call Girls In Pune
Pune Call Girls  ♠ 9352988975 ♠ Beautiful Call Girls In PunePune Call Girls  ♠ 9352988975 ♠ Beautiful Call Girls In Pune
Pune Call Girls ♠ 9352988975 ♠ Beautiful Call Girls In Pune
 
一比一原版加拿大瑞尔森大学毕业证如何办理
一比一原版加拿大瑞尔森大学毕业证如何办理一比一原版加拿大瑞尔森大学毕业证如何办理
一比一原版加拿大瑞尔森大学毕业证如何办理
 
一比一原版(范莎毕业证书)加拿大范莎学院毕业证如何办理
一比一原版(范莎毕业证书)加拿大范莎学院毕业证如何办理一比一原版(范莎毕业证书)加拿大范莎学院毕业证如何办理
一比一原版(范莎毕业证书)加拿大范莎学院毕业证如何办理
 
Call Girls Jaipur 📞 8445551418 🌟Door Step Delivery We Offering You 100% Genuine
Call Girls Jaipur 📞 8445551418 🌟Door Step Delivery We Offering You 100% GenuineCall Girls Jaipur 📞 8445551418 🌟Door Step Delivery We Offering You 100% Genuine
Call Girls Jaipur 📞 8445551418 🌟Door Step Delivery We Offering You 100% Genuine
 
jaipur Call Girls service 8445551418 Call Girl service in jaipur Call Girls S...
jaipur Call Girls service 8445551418 Call Girl service in jaipur Call Girls S...jaipur Call Girls service 8445551418 Call Girl service in jaipur Call Girls S...
jaipur Call Girls service 8445551418 Call Girl service in jaipur Call Girls S...
 
Call Girls Varanasi 8824825030 Escort In Varanasi service 24X7
Call Girls Varanasi 8824825030 Escort In Varanasi service 24X7Call Girls Varanasi 8824825030 Escort In Varanasi service 24X7
Call Girls Varanasi 8824825030 Escort In Varanasi service 24X7
 
Value based approach to heritae conservation -.docx
Value based approach to heritae conservation -.docxValue based approach to heritae conservation -.docx
Value based approach to heritae conservation -.docx
 
SPICE PARK JUN2024 ( 6,826 SPICE Models )
SPICE PARK JUN2024 ( 6,826 SPICE Models )SPICE PARK JUN2024 ( 6,826 SPICE Models )
SPICE PARK JUN2024 ( 6,826 SPICE Models )
 
Call Girls in Kolkata (7426014248) call me [🔝Kolkata🔝] Escort In Kolkata serv...
Call Girls in Kolkata (7426014248) call me [🔝Kolkata🔝] Escort In Kolkata serv...Call Girls in Kolkata (7426014248) call me [🔝Kolkata🔝] Escort In Kolkata serv...
Call Girls in Kolkata (7426014248) call me [🔝Kolkata🔝] Escort In Kolkata serv...
 
Update 33 models(General Diode ) in SPICE PARK(JUN2024)
Update 33 models(General Diode ) in SPICE PARK(JUN2024)Update 33 models(General Diode ) in SPICE PARK(JUN2024)
Update 33 models(General Diode ) in SPICE PARK(JUN2024)
 
World trade center in kerala proposal- AR. DEEKSHITH MAROLI 724519251008 REPORT
World trade center in kerala proposal- AR. DEEKSHITH MAROLI 724519251008 REPORTWorld trade center in kerala proposal- AR. DEEKSHITH MAROLI 724519251008 REPORT
World trade center in kerala proposal- AR. DEEKSHITH MAROLI 724519251008 REPORT
 
Call Girls jaipur ☎️ +91-8445551418 😍 jaipur Call Girl Beauty Girls @ Afforda...
Call Girls jaipur ☎️ +91-8445551418 😍 jaipur Call Girl Beauty Girls @ Afforda...Call Girls jaipur ☎️ +91-8445551418 😍 jaipur Call Girl Beauty Girls @ Afforda...
Call Girls jaipur ☎️ +91-8445551418 😍 jaipur Call Girl Beauty Girls @ Afforda...
 
Future Deep Strike Aircraft Thor Design Study Stage 1.pdf
Future Deep Strike Aircraft Thor Design Study Stage 1.pdfFuture Deep Strike Aircraft Thor Design Study Stage 1.pdf
Future Deep Strike Aircraft Thor Design Study Stage 1.pdf
 
Call Girls Ahmedabad( 🤑 7488326553 🤑) Vip Call Girl Ahmedabad
Call Girls Ahmedabad( 🤑 7488326553 🤑) Vip Call Girl AhmedabadCall Girls Ahmedabad( 🤑 7488326553 🤑) Vip Call Girl Ahmedabad
Call Girls Ahmedabad( 🤑 7488326553 🤑) Vip Call Girl Ahmedabad
 
🔥Mumbai Call Girls Contact Number 🔝👉 9833363713 👈🔝High Calass Call Girl Mumbai
🔥Mumbai Call Girls Contact Number 🔝👉 9833363713 👈🔝High Calass Call Girl Mumbai🔥Mumbai Call Girls Contact Number 🔝👉 9833363713 👈🔝High Calass Call Girl Mumbai
🔥Mumbai Call Girls Contact Number 🔝👉 9833363713 👈🔝High Calass Call Girl Mumbai
 
(Introduction to canva and canva strategies) CANVA PPT.pptx
(Introduction to canva and canva strategies) CANVA PPT.pptx(Introduction to canva and canva strategies) CANVA PPT.pptx
(Introduction to canva and canva strategies) CANVA PPT.pptx
 
Call Girls Vijayawada 8824825030 Escort In Vijayawada service 24X7
Call Girls Vijayawada 8824825030 Escort In Vijayawada service 24X7Call Girls Vijayawada 8824825030 Escort In Vijayawada service 24X7
Call Girls Vijayawada 8824825030 Escort In Vijayawada service 24X7
 
Call Girls In Jaipur {8445551418} ❤️VVIP JIYA Call Girl in Jaipur Rajasthan
Call Girls In Jaipur {8445551418} ❤️VVIP JIYA Call Girl in Jaipur RajasthanCall Girls In Jaipur {8445551418} ❤️VVIP JIYA Call Girl in Jaipur Rajasthan
Call Girls In Jaipur {8445551418} ❤️VVIP JIYA Call Girl in Jaipur Rajasthan
 
一比一原版(brunel毕业证书)布鲁内尔大学毕业证如何办理
一比一原版(brunel毕业证书)布鲁内尔大学毕业证如何办理一比一原版(brunel毕业证书)布鲁内尔大学毕业证如何办理
一比一原版(brunel毕业证书)布鲁内尔大学毕业证如何办理
 

Lexical Analysis

  • 2. Lexical Analysis Lexical analysis is the process of converting a sequence of characters from source program into a sequence of tokens.
  • 3. Role of Lexical Analyzer Lexical analyzer performs the following tasks: • Reads the source program, scans the input characters, group them into lexemes and produce the token as output. • Enters the identified token into the symbol table. • Strips out white spaces and comments from source program. • Correlates error messages with the source program i.e., displays error message with its occurrence by specifying the line number. • Expands the macros if it is found in the source program.
  • 4. Need of Lexical Analyzer Simplicity of design of compiler The removal of white spaces and comments enables the syntax analyzer for efficient syntactic constructs. Compiler efficiency is improved Specialized buffering techniques for reading characters speed up the compiler process
  • 5. TYPES OF LEXICAL ANALYSIS A program which performs lexical analysis is termed as a lexical analyzer (lexer), tokenizer or scanner. Lexical analysis consists of two stages of processing which are as follows: • Scanning • Tokenization
  • 6. Token Token is a valid sequence of characters which are given by lexeme. In a programming language : • keywords, • constant, • identifiers, • numbers, • operators and • punctuations symbols are possible tokens to be identified.
  • 7. Pattern Pattern describes a rule that must be matched by sequence of characters (lexemes) to form a token. It can be defined by regular expressions or grammar rules.
  • 8. Lexeme Lexeme is a sequence of characters that matches the pattern for a token i.e., instance of a token.
  • 9. Example C = a + b*5;
  • 10. Tasks of lexical analyzer can be divided into two processes: Scanning: Performs reading of input characters, removal of white spaces and comments. Lexical Analysis: Produce tokens as the output. Task
  • 11. Lexical analysis is the process of producing tokens from the source program. It has the following issues: • Lookahead • Ambiguities ISSUES
  • 12. Lookahead Lookahead is required to decide when one token will end and the next token will begin. The simple example which has lookahead.
  • 13. Ambiguities If a language or syntax by when we can produce two or more parse tree then that is ambiguity and this grammar is called ambiguity grammar. When more than one expression can match the current input chooses as follows: • The longest match is preferred. • Among rules which matched the same number of characters, the rule given first is preferred.
  • 14. Lexical Errors 1. A character sequence that cannot be scanned into any valid token is a lexical error. 2.Lexical errors are uncommon, but they still must be handled by a scanner. 3.Misspelling of identifiers, keyword, or operators are considered as lexical errors. Usually, a lexical error is caused by the appearance of some illegal character, mostly at the beginning of a token.
  翻译: