SlideShare a Scribd company logo
Topic – Compiler and Interpreter, Lexical
Analysis
Name : Souvik Roy
Class Roll: IT2020/025
Uni Roll : 11700220036
College Name : RCC Institute Of Information
Technology
Interpreter And Compiler
An interpreter is a program that
executes the programming code
directly instead of just translating it into
another format. It translates and
executes programming language
statements one by one. An interpreter
takes less time to interpret a source
program as distinguished by a compiler.
A compiler is a computer program that
reads a program written in a high-level
language such as FORTRAN, PL/I,
COBOL, etc. It can translate it into the
same program in a low-level language
including machine language. The
compiler also finds out the various
errors encountered during the
compilation of a
2 ->
3 ->
4 ->
5 ->
6 ->
7 ->
9 ->
1 ->
8 ->
Differences Between Compiler and Interpreter
1 ->
2 ->
4 ->
5 ->
6 ->
7 ->
9 ->
1 ->
8 ->
Compiler Interpreter
A compiler translates the entire source
code in a single run.
An interpreter translates the entire source
code line by line.
It consumes less time i.e., it is faster than
an interpreter.
It consumes much more time than the
compiler i.e., it is slower than the
compiler.
It is more efficient. It is less efficient.
CPU utilization is more. CPU utilization is less as compared to the
compiler.
Both syntactic and semantic errors can be
checked simultaneously.
Only syntactic errors are checked.
The compiler is larger. Interpreters are often smaller than
compilers.
It is not flexible. It is flexible.
The localization of errors is difficult. The localization of error is easier than the
compiler.
A presence of an error can cause the
whole program to be re-organized.
A presence of an error causes only a part
of the program to be re-organized.
The compiler is used by the language such
as C, C++.
An interpreter is used by languages such
as Java.
2 ->
3 ->
1 ->
4 ->
5 ->
6 ->
7 ->
9 ->
8 ->
2 ->
3 ->
1 ->
Compiler – Design and Phases
T
O
P
I
C
Terms To Be Familiar With Before Starting Out
With Lexical Analysis
• Lexeme
Lexeme can be defined as a sequence of characters
that forms a pattern and can be recognized as a token.
• Pattern
After identifying the pattern of lexeme one can
describe what kind of token can be formed. Such as
the pattern of some lexeme forms a keyword, the
pattern of some lexemes forms an identifier.
• Token
A lexeme with a valid pattern forms a token. In lexical
analysis, a valid token can be identifiers, keywords,
separators, special characters, constants and
operators.
• Symbol Table is an important data structure created
and maintained by the compiler in order to keep track
of semantics of variables i.e. it stores information
about the scope and binding information about
names, information about instances of various entities
such as variable and function names, classes, objects,
etc.
• Scope Management - A compiler maintains two types
of symbol tables: a global symbol table which can be
accessed by all the procedures and scope symbol
tables that are created for each scope in the program.
4 ->
5 ->
6 ->
7 ->
9 ->
8 ->
2 ->
3 ->
1 ->
Symbol table breakdown example
Categorisation of tokens
Lexical Analysis
4 ->
5 ->
6 ->
7 ->
9 ->
8 ->
2 ->
3 ->
1 ->
Lexical analysis is the first phase of a compiler. It takes modified source code from
language preprocessors that are written in the form of sentences. The lexical
analyzer breaks these syntaxes into a series of tokens, by removing any whitespace
or comments in the source code.
If the lexical analyzer finds a token invalid, it generates an error. The lexical analyzer
works closely with the syntax analyzer. It reads character streams from the source
code, checks for legal tokens, and passes the data to the syntax analyzer when it
demands.
Lexical Analysis : Breaking Of Code
into Tokens
• #include <stdio.h>
• int maximum(int
x, int y)
• { // This will
compare 2
numbers
• if (x > y)
• return x;
• else {
• return y;
• }
• }
Lexeme Token
int Keyword
maximum Identifier
( Operator
int Keyword
x Identifier
, Operator
int Keyword
Y Identifier
) Operator
{ Operator
If Keyword
4 ->
5 ->
6 ->
7 ->
9 ->
8 ->
2 ->
3 ->
1 ->
Lexical Analyzer Parser
Output Input project
Carry out linguistic structure
examination
Recognize Tokens
Make a theoretical portrayal of the
program
Addition symbols into Symbol Table Better image table sections
It creates lexical blunders It create parse tree of the program
Comparison of Lexical Analyzer & Parse
ROLE OF LEXICAL ANALYSIS
Lexical analyzer likewise performs beneath given assignments:
This distinguishes the token in the image table
Remove place and remarks from the source code.
Associate blunder messages with the source code.
Help to create macros in the event that they are in the source code
Study input nature from the source program
4 ->
5 ->
6 ->
7 ->
9 ->
8 ->
2 ->
3 ->
1 ->
A Little Example To Remember
Lexical Analysis
4 ->
5 ->
6 ->
7 ->
9 ->
8 ->
2 ->
3 ->
1 ->
References
• Ada 95 Reference Manual. Intermetrics, Inc., 1995. ANSI/ISO/IEC-8652:1995.
• A.V. Aho and M.J. Corasick. Efficient String Matching: An Aid to Bibliographic
Search. Communications of the ACM, 18(6):333-340, June 1975
• Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffery D. Ullman Compilers : Principles,
Technique and Tools, 2nd ed. PEARSON Education 2009.
• P. Bumbulis and D.D. Cowan. RE2C: A More Versatile Scanner Generator. ACM
Letters on Programming Languages and Systems, 2(1-4):70–84, 1993.
• R.J. Cichelli. Minimal Perfect Hash Functions Made Simple. Communications of the
ACM, 23:17–19, 1980.
• A.V. Aho, R. Sethi, and J.D. Ullman. Compilers. Addison-Wesley, 1986.
• J. Barnes. Programming in Ada 95. Addison Wesley, 1995.
• https://www.ques10.com/p/21837/explain-role-of-lexical-analyser/
• https://www.guru99.com/compiler-design-lexical-analysis.html
• https://www.javatpoint.com/compiler-tutorial
• https://www.tutorialspoint.com/compiler_design/compiler_design_types_of_parsi
ng.htm
• https://en.wikibooks.org/wiki/Compiler_Construction/Lexical_analysis
HOME AGAIN

More Related Content

Similar to Compiler Design.pptx

Principles of Compiler Design
Principles of Compiler DesignPrinciples of Compiler Design
Principles of Compiler Design
Marimuthu M
 
Compier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.pptCompier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.ppt
Apoorv Diwan
 
Plc part 2
Plc  part 2Plc  part 2
Plc part 2
Taymoor Nazmy
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
NesredinTeshome1
 
Cd ch2 - lexical analysis
Cd   ch2 - lexical analysisCd   ch2 - lexical analysis
Cd ch2 - lexical analysis
mengistu23
 
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATORPSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
ijistjournal
 
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
DrIsikoIsaac
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
ssuser3b4934
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
Radhika Talaviya
 
1 compiler outline
1 compiler outline1 compiler outline
1 compiler outline
ASHOK KUMAR REDDY
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
abdulbaki3
 
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
DrIsikoIsaac
 
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
 
Assignment1
Assignment1Assignment1
Assignment1
Sunita Milind Dol
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
Rebaz Najeeb
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
Ashwini Sonawane
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
SuchandaBanerjee6
 
Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
guest5de1a5
 
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGESOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
IJCI JOURNAL
 

Similar to Compiler Design.pptx (20)

3.2
3.23.2
3.2
 
Principles of Compiler Design
Principles of Compiler DesignPrinciples of Compiler Design
Principles of Compiler Design
 
Compier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.pptCompier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.ppt
 
Plc part 2
Plc  part 2Plc  part 2
Plc part 2
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
 
Cd ch2 - lexical analysis
Cd   ch2 - lexical analysisCd   ch2 - lexical analysis
Cd ch2 - lexical analysis
 
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATORPSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
 
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
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
 
1 compiler outline
1 compiler outline1 compiler outline
1 compiler outline
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 
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
 
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
 
Assignment1
Assignment1Assignment1
Assignment1
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
 
Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
 
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGESOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
 

Recently uploaded

一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
dwreak4tg
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
vcaxypu
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
ocavb
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
jerlynmaetalle
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
2023240532
 
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
pchutichetpong
 
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationPredicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Boston Institute of Analytics
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
jerlynmaetalle
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
nscud
 
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdfSample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Linda486226
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
AbhimanyuSinha9
 

Recently uploaded (20)

一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
 
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
 
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationPredicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
 
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdfSample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
 

Compiler Design.pptx

  • 1. Topic – Compiler and Interpreter, Lexical Analysis Name : Souvik Roy Class Roll: IT2020/025 Uni Roll : 11700220036 College Name : RCC Institute Of Information Technology
  • 2. Interpreter And Compiler An interpreter is a program that executes the programming code directly instead of just translating it into another format. It translates and executes programming language statements one by one. An interpreter takes less time to interpret a source program as distinguished by a compiler. A compiler is a computer program that reads a program written in a high-level language such as FORTRAN, PL/I, COBOL, etc. It can translate it into the same program in a low-level language including machine language. The compiler also finds out the various errors encountered during the compilation of a 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 9 -> 1 -> 8 ->
  • 3. Differences Between Compiler and Interpreter 1 -> 2 -> 4 -> 5 -> 6 -> 7 -> 9 -> 1 -> 8 -> Compiler Interpreter A compiler translates the entire source code in a single run. An interpreter translates the entire source code line by line. It consumes less time i.e., it is faster than an interpreter. It consumes much more time than the compiler i.e., it is slower than the compiler. It is more efficient. It is less efficient. CPU utilization is more. CPU utilization is less as compared to the compiler. Both syntactic and semantic errors can be checked simultaneously. Only syntactic errors are checked. The compiler is larger. Interpreters are often smaller than compilers. It is not flexible. It is flexible. The localization of errors is difficult. The localization of error is easier than the compiler. A presence of an error can cause the whole program to be re-organized. A presence of an error causes only a part of the program to be re-organized. The compiler is used by the language such as C, C++. An interpreter is used by languages such as Java. 2 -> 3 -> 1 ->
  • 4. 4 -> 5 -> 6 -> 7 -> 9 -> 8 -> 2 -> 3 -> 1 -> Compiler – Design and Phases T O P I C
  • 5. Terms To Be Familiar With Before Starting Out With Lexical Analysis • Lexeme Lexeme can be defined as a sequence of characters that forms a pattern and can be recognized as a token. • Pattern After identifying the pattern of lexeme one can describe what kind of token can be formed. Such as the pattern of some lexeme forms a keyword, the pattern of some lexemes forms an identifier. • Token A lexeme with a valid pattern forms a token. In lexical analysis, a valid token can be identifiers, keywords, separators, special characters, constants and operators. • Symbol Table is an important data structure created and maintained by the compiler in order to keep track of semantics of variables i.e. it stores information about the scope and binding information about names, information about instances of various entities such as variable and function names, classes, objects, etc. • Scope Management - A compiler maintains two types of symbol tables: a global symbol table which can be accessed by all the procedures and scope symbol tables that are created for each scope in the program. 4 -> 5 -> 6 -> 7 -> 9 -> 8 -> 2 -> 3 -> 1 -> Symbol table breakdown example Categorisation of tokens
  • 6. Lexical Analysis 4 -> 5 -> 6 -> 7 -> 9 -> 8 -> 2 -> 3 -> 1 -> Lexical analysis is the first phase of a compiler. It takes modified source code from language preprocessors that are written in the form of sentences. The lexical analyzer breaks these syntaxes into a series of tokens, by removing any whitespace or comments in the source code. If the lexical analyzer finds a token invalid, it generates an error. The lexical analyzer works closely with the syntax analyzer. It reads character streams from the source code, checks for legal tokens, and passes the data to the syntax analyzer when it demands.
  • 7. Lexical Analysis : Breaking Of Code into Tokens • #include <stdio.h> • int maximum(int x, int y) • { // This will compare 2 numbers • if (x > y) • return x; • else { • return y; • } • } Lexeme Token int Keyword maximum Identifier ( Operator int Keyword x Identifier , Operator int Keyword Y Identifier ) Operator { Operator If Keyword 4 -> 5 -> 6 -> 7 -> 9 -> 8 -> 2 -> 3 -> 1 ->
  • 8. Lexical Analyzer Parser Output Input project Carry out linguistic structure examination Recognize Tokens Make a theoretical portrayal of the program Addition symbols into Symbol Table Better image table sections It creates lexical blunders It create parse tree of the program Comparison of Lexical Analyzer & Parse ROLE OF LEXICAL ANALYSIS Lexical analyzer likewise performs beneath given assignments: This distinguishes the token in the image table Remove place and remarks from the source code. Associate blunder messages with the source code. Help to create macros in the event that they are in the source code Study input nature from the source program 4 -> 5 -> 6 -> 7 -> 9 -> 8 -> 2 -> 3 -> 1 ->
  • 9. A Little Example To Remember Lexical Analysis 4 -> 5 -> 6 -> 7 -> 9 -> 8 -> 2 -> 3 -> 1 ->
  • 10. References • Ada 95 Reference Manual. Intermetrics, Inc., 1995. ANSI/ISO/IEC-8652:1995. • A.V. Aho and M.J. Corasick. Efficient String Matching: An Aid to Bibliographic Search. Communications of the ACM, 18(6):333-340, June 1975 • Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffery D. Ullman Compilers : Principles, Technique and Tools, 2nd ed. PEARSON Education 2009. • P. Bumbulis and D.D. Cowan. RE2C: A More Versatile Scanner Generator. ACM Letters on Programming Languages and Systems, 2(1-4):70–84, 1993. • R.J. Cichelli. Minimal Perfect Hash Functions Made Simple. Communications of the ACM, 23:17–19, 1980. • A.V. Aho, R. Sethi, and J.D. Ullman. Compilers. Addison-Wesley, 1986. • J. Barnes. Programming in Ada 95. Addison Wesley, 1995. • https://www.ques10.com/p/21837/explain-role-of-lexical-analyser/ • https://www.guru99.com/compiler-design-lexical-analysis.html • https://www.javatpoint.com/compiler-tutorial • https://www.tutorialspoint.com/compiler_design/compiler_design_types_of_parsi ng.htm • https://en.wikibooks.org/wiki/Compiler_Construction/Lexical_analysis HOME AGAIN