SlideShare a Scribd company logo
Compiler Construction
By Noor Wali Khan
UOCH
Continue
From
Previous
Lecture
Lexical Analyzer
• Specifications of Tokens
• Let us understand how the language theory undertakes the following terms:
• Alphabets
• Any finite set of symbols {0,1} is a set of binary alphabets,
{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F} is a set of Hexadecimal alphabets, {a-z, A-Z} is
a set of English language alphabets.
• Strings
• Any finite sequence of alphabets is called a string. Length of the string is the
total number of occurrence of alphabets, e.g., the length of the string Noor is
4 and is denoted by |Noor| = 4.
• A string having no alphabets, i.e. a string of zero length is known as an empty
string and is denoted by ε (epsilon).
Lexical Analyzer
• Special Symbols
• A typical high-level language contains the following symbols:
Lexical Analyzer
• Language
• A language is considered as a finite set of strings over some finite set of
alphabets.
• Computer languages are considered as finite sets, and mathematically set
operations can be performed on them.
• Finite languages can be described by means of regular expressions.
• Longest Match Rule
• When the lexical analyzer read the source-code, it scans the code letter by
letter; and when it encounters a whitespace, operator symbol, or special
symbols, it decides that a word is completed.
Lexical Analyzer
• Input Buffering
• The lexical analyzer scans the input from left to right one character at a time.
It uses two pointers begin ptr(bp) and forward to keep track of the pointer of
the input scanned.
Lexical Analyzer
• Input Buffering
• Initially both the pointers point to the first character of the input string as
shown below:
Lexical Analyzer
• The forward ptr moves ahead to search for end of lexeme.
• As soon as the blank space is encountered, it indicates
end of lexeme.
• In above example as soon as ptr (fp) encounters a blank
space the lexeme “int” is identified.
• The fp will be moved ahead at white space, when fp
encounters white space, it ignore and moves ahead. then
both the begin ptr(bp) and forward ptr(fp) are set at next
token.
Compiler lecture 05

More Related Content

PPTX
Compiler Design
PPT
static dictionary technique
ODP
LVEE 2014: Text parsing with Python and PLY
DOCX
Python Programming Language
PPTX
SS UII Lecture 1
ODP
ANTLR4 and its testing
ODP
Using ANTLR on real example - convert "string combined" queries into paramete...
Compiler Design
static dictionary technique
LVEE 2014: Text parsing with Python and PLY
Python Programming Language
SS UII Lecture 1
ANTLR4 and its testing
Using ANTLR on real example - convert "string combined" queries into paramete...

What's hot (17)

PPTX
Computational model language and grammar bnf
PDF
Python tutorial
PPT
Syntax analysis
PPTX
Shallow parser for hindi language with an input from a transliterator
PPT
3 describing syntax
PPTX
6. describing syntax and semantics
PPTX
Experiments with Different Models of Statistcial Machine Translation
PPTX
Summer Training Project On Python Programming
PDF
part of speech tagger for ARABIC TEXT
PPTX
PPTX
1910 JK27
PPTX
Part of speech tagging for Arabic
PDF
Python syntax
PDF
lempel_ziv
PDF
Lecture5 syntax analysis_1
DOC
Toc syllabus updated
Computational model language and grammar bnf
Python tutorial
Syntax analysis
Shallow parser for hindi language with an input from a transliterator
3 describing syntax
6. describing syntax and semantics
Experiments with Different Models of Statistcial Machine Translation
Summer Training Project On Python Programming
part of speech tagger for ARABIC TEXT
1910 JK27
Part of speech tagging for Arabic
Python syntax
lempel_ziv
Lecture5 syntax analysis_1
Toc syllabus updated
Ad

Similar to Compiler lecture 05 (20)

PPTX
LexicalAnalysis chapter2 i n compiler design.pptx
PPTX
Ch03-LexicalAnalysis chapter2 in compiler design.pptx
PPTX
Lexical Analysis - Compiler Design
PPTX
Lecture 02 lexical analysis
PPTX
Compiler Construction ( lexical analyzer).pptx
PPT
PPTX
Unitiv 111206005201-phpapp01
PPTX
Compiler Lexical Analyzer to analyze lexemes.pptx
PDF
Lecture3 lexical analysis
PPTX
Role-of-lexical-analysis
PDF
Lexical analysis - Compiler Design
PPTX
Compiler Design_Lexical Analysis phase.pptx
PDF
Ch03-LexicalAnalysis in compiler design subject.pdf
PDF
Lexical analysis Compiler design pdf to read
PDF
Lexical analysis compiler design to read and study
PDF
Control structure
PPTX
BCS503 TOC Module 1 PPT.pptx VTU academic Year 2024-25 ODD SEM
PPTX
Lecture 1 of automata theory where .pptx
PPTX
Chapter One - Introduction to automata and complexity theory
LexicalAnalysis chapter2 i n compiler design.pptx
Ch03-LexicalAnalysis chapter2 in compiler design.pptx
Lexical Analysis - Compiler Design
Lecture 02 lexical analysis
Compiler Construction ( lexical analyzer).pptx
Unitiv 111206005201-phpapp01
Compiler Lexical Analyzer to analyze lexemes.pptx
Lecture3 lexical analysis
Role-of-lexical-analysis
Lexical analysis - Compiler Design
Compiler Design_Lexical Analysis phase.pptx
Ch03-LexicalAnalysis in compiler design subject.pdf
Lexical analysis Compiler design pdf to read
Lexical analysis compiler design to read and study
Control structure
BCS503 TOC Module 1 PPT.pptx VTU academic Year 2024-25 ODD SEM
Lecture 1 of automata theory where .pptx
Chapter One - Introduction to automata and complexity theory
Ad

More from University of Chitral (15)

PPTX
Compiler lecture 07
PPTX
Compiler lecture 06
PPTX
Compiler lecture 04
PPTX
Compiler lecture 05
PPTX
Oop lecture 06
PPTX
Oop lecture 05
PPTX
OOP lecture 04
PPTX
Compiler lecture 04
PPTX
Compiler lecture 03
PPTX
Compiler lecture 01
PPTX
Compiler lecture 02
PPTX
O op lecture 04
PPTX
Oop lecture 03
PPTX
Oop lecture 02
PPTX
Oop lecture 01
Compiler lecture 07
Compiler lecture 06
Compiler lecture 04
Compiler lecture 05
Oop lecture 06
Oop lecture 05
OOP lecture 04
Compiler lecture 04
Compiler lecture 03
Compiler lecture 01
Compiler lecture 02
O op lecture 04
Oop lecture 03
Oop lecture 02
Oop lecture 01

Recently uploaded (20)

PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
RMMM.pdf make it easy to upload and study
PDF
01-Introduction-to-Information-Management.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Lesson notes of climatology university.
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Basic Mud Logging Guide for educational purpose
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
Institutional Correction lecture only . . .
Pharmacology of Heart Failure /Pharmacotherapy of CHF
O7-L3 Supply Chain Operations - ICLT Program
PPH.pptx obstetrics and gynecology in nursing
RMMM.pdf make it easy to upload and study
01-Introduction-to-Information-Management.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
VCE English Exam - Section C Student Revision Booklet
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Final Presentation General Medicine 03-08-2024.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
Lesson notes of climatology university.
102 student loan defaulters named and shamed – Is someone you know on the list?
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Renaissance Architecture: A Journey from Faith to Humanism
Basic Mud Logging Guide for educational purpose
Abdominal Access Techniques with Prof. Dr. R K Mishra
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Sports Quiz easy sports quiz sports quiz
Institutional Correction lecture only . . .

Compiler lecture 05

  • 1. Compiler Construction By Noor Wali Khan UOCH Continue From Previous Lecture
  • 2. Lexical Analyzer • Specifications of Tokens • Let us understand how the language theory undertakes the following terms: • Alphabets • Any finite set of symbols {0,1} is a set of binary alphabets, {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F} is a set of Hexadecimal alphabets, {a-z, A-Z} is a set of English language alphabets. • Strings • Any finite sequence of alphabets is called a string. Length of the string is the total number of occurrence of alphabets, e.g., the length of the string Noor is 4 and is denoted by |Noor| = 4. • A string having no alphabets, i.e. a string of zero length is known as an empty string and is denoted by ε (epsilon).
  • 3. Lexical Analyzer • Special Symbols • A typical high-level language contains the following symbols:
  • 4. Lexical Analyzer • Language • A language is considered as a finite set of strings over some finite set of alphabets. • Computer languages are considered as finite sets, and mathematically set operations can be performed on them. • Finite languages can be described by means of regular expressions. • Longest Match Rule • When the lexical analyzer read the source-code, it scans the code letter by letter; and when it encounters a whitespace, operator symbol, or special symbols, it decides that a word is completed.
  • 5. Lexical Analyzer • Input Buffering • The lexical analyzer scans the input from left to right one character at a time. It uses two pointers begin ptr(bp) and forward to keep track of the pointer of the input scanned.
  • 6. Lexical Analyzer • Input Buffering • Initially both the pointers point to the first character of the input string as shown below:
  • 7. Lexical Analyzer • The forward ptr moves ahead to search for end of lexeme. • As soon as the blank space is encountered, it indicates end of lexeme. • In above example as soon as ptr (fp) encounters a blank space the lexeme “int” is identified. • The fp will be moved ahead at white space, when fp encounters white space, it ignore and moves ahead. then both the begin ptr(bp) and forward ptr(fp) are set at next token.