SlideShare uma empresa Scribd logo
1 de 9
TOPIC
COMPILER DESIGN OPTIONS
BY:SONALI KAHARADE
INTRODUCTION
 A compiler is a translator that converts the high-level language into the machine language.
 High-level language is written by a developer and machine language can be understood by the processor.
 Compiler is used to show errors to the programmer.
 The main purpose of compiler is to change the code written in one language without changing the meaning of the
program.
 When you execute a program which is written in HLL programming language then it executes into two parts.
 In the first part, the source program compiled and translated into the object program (low level language).
 In the second part, object program translated into the target program through the assembler.
 A compiler is a language processor that converts a users program written in a programming language into a machine
language program which can execute on the computer, while an Interpreter is a language processor that itself performs
the action indicated in a user program without generating a machine language program.
 We have learnt that any computer system is made of hardware and
software. The hardware understands a language, which humans cannot
understand. So we write programs in high-level language, which is easier
for us to understand and remember. These programs are then fed into a
series of tools and OS components to get the desired code that can be used
by the machine. This is known as Language Processing System.
 Let us first understand how a program, using C compiler, is executed on a
host machine.
 User writes a program in C language (high-level language).
 The C compiler, compiles the program and translates it to assembly
program (low-level language).
 An assembler then translates the assembly program into machine code
(object).
 A linker tool is used to link all the parts of the program together for
execution (executable machine code).
 A loader loads all of them into memory and then the program is executed.
LANGUAGE PROCESSING SYSTEM
Pre
Processor
Compiler
Assembler
Linker
Loader
Memory
A compiler can broadly be divided into two phases based on the way they compile.
1. Analysis Phase
Known as the front-end of the compiler, the analysis phase of the compiler reads the source program, divides it into core parts
and then checks for lexical, grammar and syntax errors. The analysis phase generates an intermediate representation of the
source program and symbol table, which should be fed to the Synthesis phase as input.
2. Synthesis Phase
Known as the back-end of the compiler, the synthesis phase generates the target program with the help of intermediate source
code representation and symbol table.
COMPILER DESIGN- ARCHITECTURE
Analysis
Phase
Synthesis
Phase
Intermediate code
Source code Machine code
INTERPRETER
 An interpreter is a computer program that is used to directly execute program instructions written using one of the many
high-level programming languages.
 The interpreter transforms the high-level program into an intermediate language that it then executes, or it could parse the
high-level source code and then performs the commands directly, which is done line by line or statement by statement.
 The interpreter reads each statement of code and then converts or executes it directly. In contrast, an assembler or a
compiler converts a high-level source code into native (compiled) code that can be executed directly by the operating
system (e.g. by creating a .exe program).
 This feature makes easy for programmers to check any particular line at the time of debugging, but slows down the overall
time of execution of the entire program.
Data
Interpreter
Source
code
Machine
code
Advantage Disadvantage
The program code is already translat
ed into machine code. Thus, it code
execution time is less.
Interpreters are easier to use, especially
for beginners.
You can't change the program withou
t going back to the source code.
Interpreted programs can run on compu
ters that have the
corresponding interpreter.
Role of Compiler
•Compliers reads the source code, outputs executable code
•Translates software written in a higher-level language into instructions that computer can understand. It
converts the text that a programmer writes into a format the CPU can understand.
•The process of compilation is relatively complicated. It spends a lot of time analyzing and processing the
program.
•The executable result is some form of machine-specific binary code.
Role of Interpreter
•The interpreter converts the source code line-by-line during RUN Time.
•Interpret completely translates a program written in a high-level language into machine level language.
•Interpreter allows evaluation and modification of the program while it is executing.
•Relatively less time spent for analyzing and processing the program
•Program execution is relatively slow compared to compiler
ROLE OF COMPILER & INTERPRETER
Interpreter Compiler
Translates program one statement at a time.
Scans the entire program and translates it as a whole into
machine code.
Interpreters usually take less amount of time to analyze the
source code. However, the overall execution time is
comparatively slower than compilers.
Compilers usually take a large amount of time to analyze the
source code. However, the overall execution time is
comparatively faster than interpreters.
No intermediate object code is generated, hence are memory
efficient.
Generates intermediate object code which further requires
linking, hence requires more memory.
Errors are displayed for every instruction interpreted. Errors are displayed after entire program is checked.
Programming languages like JavaScript, Python, Ruby use
interpreters.
Programming languages like C, C++, Java use compilers.
COMPARISION OF INTERPRETER & COMPILER
1. Pure Interpreters:
 In a pure interpreter, the source program is maintained in the source form throughout its interpretation. Each
statement of source program is analyzed while interpreting. This arrangement acquires substantial analysis
overheads when interpreting a statement.
2. Impure Interpreters:
 An impure interpreter carries out some preliminary processing of the source program to decrease the
analysis overheads during interpretation. To reduce the analysis overhead, some initial processing of the
source program is done by the impure interpreter during interpretation.
 The source program is given to the preprocessor and the preprocessor transforms the program to an
intermediate representation (IR) that is used during interpretation.
 This speeds up interpretation since the code component of the IR that is the IC, can be analyzed more
resourcefully than the source form of the program.
PURE AND IMPUTER INTERPRETER
 Like interpreter, p-code compilers are also analyzed and convert
source program into an intermediate code(IC).
 P-code compilers are also called bytecode compilers & are very
similar in concept to interpreter. The source program is analyzed and
converted into an intermediate form, which is then executed
interpretively.
 With a P-Code compiler, this intermediate forms is the machine
language for a hypothetical machine, often call pseudo-machine. P-
code object programs can be executed on any machine that has a P-
Code interpreter.
P-CODE COMPILERS
Compiler
Object Program
p-code
P-code
interpreter
Source Program
Advantage Disadvantage
1. Portability 1. Slower execution of program
2. Saves memory

Mais conteúdo relacionado

Mais procurados

contiguous memory allocation.pptx
contiguous memory allocation.pptxcontiguous memory allocation.pptx
contiguous memory allocation.pptxRajapriya82
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite AutomataRatnakar Mikkili
 
Operating system deign and implementation
Operating system deign and implementationOperating system deign and implementation
Operating system deign and implementationsangrampatil81
 
Regular Expression to Finite Automata
Regular Expression to Finite AutomataRegular Expression to Finite Automata
Regular Expression to Finite AutomataArchana Gopinath
 
Designing Techniques in Software Engineering
Designing Techniques in Software EngineeringDesigning Techniques in Software Engineering
Designing Techniques in Software Engineeringkirupasuchi1996
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.Ravi Kumar Patel
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler designRiazul Islam
 
Passes of compilers
Passes of compilersPasses of compilers
Passes of compilersVairavel C
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithmsPiyush Rochwani
 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programmingsonalikharade3
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating SystemsRitu Ranjan Shrivastwa
 

Mais procurados (20)

contiguous memory allocation.pptx
contiguous memory allocation.pptxcontiguous memory allocation.pptx
contiguous memory allocation.pptx
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Operating system deign and implementation
Operating system deign and implementationOperating system deign and implementation
Operating system deign and implementation
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
 
Regular Expression to Finite Automata
Regular Expression to Finite AutomataRegular Expression to Finite Automata
Regular Expression to Finite Automata
 
Designing Techniques in Software Engineering
Designing Techniques in Software EngineeringDesigning Techniques in Software Engineering
Designing Techniques in Software Engineering
 
Cpu scheduling in operating System.
Cpu scheduling in operating System.Cpu scheduling in operating System.
Cpu scheduling in operating System.
 
Unit 3 sp assembler
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assembler
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 
Cohesion and coupling
Cohesion and couplingCohesion and coupling
Cohesion and coupling
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Language processors
Language processorsLanguage processors
Language processors
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler design
 
Passes of compilers
Passes of compilersPasses of compilers
Passes of compilers
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programming
 
Swapping | Computer Science
Swapping | Computer ScienceSwapping | Computer Science
Swapping | Computer Science
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 

Semelhante a Compiler Design Options Explained

Compiler design slide share
Compiler design slide shareCompiler design slide share
Compiler design slide shareSudhaa Ravi
 
Language processing system.pdf
Language processing system.pdfLanguage processing system.pdf
Language processing system.pdfRakibRahman19
 
Compliers and interpreters
Compliers and interpretersCompliers and interpreters
Compliers and interpretersshivasdhtsvmic
 
La 5 Pl Translator
La 5   Pl TranslatorLa 5   Pl Translator
La 5 Pl TranslatorCma Mohd
 
Computer assignment for grade 9
Computer assignment for grade  9Computer assignment for grade  9
Computer assignment for grade 9nahomyitbarek
 
compilervsinterpreter-161008074915.pdf
compilervsinterpreter-161008074915.pdfcompilervsinterpreter-161008074915.pdf
compilervsinterpreter-161008074915.pdfHarshaVardhan196987
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreterParas Patel
 
Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution pptKeerty Smile
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler designPreeti Katiyar
 
Programming Languages
Programming LanguagesProgramming Languages
Programming LanguagesMohamed Omar
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxdawod yimer
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compilerA. S. M. Shafi
 
Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Md Hossen
 
design intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdfdesign intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdfadvRajatSharma
 
lce1 مترجمات.pptx
lce1 مترجمات.pptxlce1 مترجمات.pptx
lce1 مترجمات.pptxSamiAAli44
 

Semelhante a Compiler Design Options Explained (20)

Compiler design slide share
Compiler design slide shareCompiler design slide share
Compiler design slide share
 
COMPILER DESIGN.docx
COMPILER DESIGN.docxCOMPILER DESIGN.docx
COMPILER DESIGN.docx
 
Assembler
AssemblerAssembler
Assembler
 
Language processing system.pdf
Language processing system.pdfLanguage processing system.pdf
Language processing system.pdf
 
Compliers and interpreters
Compliers and interpretersCompliers and interpreters
Compliers and interpreters
 
La 5 Pl Translator
La 5   Pl TranslatorLa 5   Pl Translator
La 5 Pl Translator
 
Computer assignment for grade 9
Computer assignment for grade  9Computer assignment for grade  9
Computer assignment for grade 9
 
Presentation
PresentationPresentation
Presentation
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
 
compilervsinterpreter-161008074915.pdf
compilervsinterpreter-161008074915.pdfcompilervsinterpreter-161008074915.pdf
compilervsinterpreter-161008074915.pdf
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
 
Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution ppt
 
basics of compiler design
basics of compiler designbasics of compiler design
basics of compiler design
 
Programming Languages
Programming LanguagesProgramming Languages
Programming Languages
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptx
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
Compiler vs interpreter
Compiler vs interpreter Compiler vs interpreter
Compiler vs interpreter
 
Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.
 
design intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdfdesign intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdf
 
lce1 مترجمات.pptx
lce1 مترجمات.pptxlce1 مترجمات.pptx
lce1 مترجمات.pptx
 

Último

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
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 17Celine George
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
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.pdfJayanti Pande
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
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.pdfQucHHunhnh
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
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 ModeThiyagu K
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 

Último (20)

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
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
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
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
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
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"
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
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
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 

Compiler Design Options Explained

  • 2. INTRODUCTION  A compiler is a translator that converts the high-level language into the machine language.  High-level language is written by a developer and machine language can be understood by the processor.  Compiler is used to show errors to the programmer.  The main purpose of compiler is to change the code written in one language without changing the meaning of the program.  When you execute a program which is written in HLL programming language then it executes into two parts.  In the first part, the source program compiled and translated into the object program (low level language).  In the second part, object program translated into the target program through the assembler.  A compiler is a language processor that converts a users program written in a programming language into a machine language program which can execute on the computer, while an Interpreter is a language processor that itself performs the action indicated in a user program without generating a machine language program.
  • 3.  We have learnt that any computer system is made of hardware and software. The hardware understands a language, which humans cannot understand. So we write programs in high-level language, which is easier for us to understand and remember. These programs are then fed into a series of tools and OS components to get the desired code that can be used by the machine. This is known as Language Processing System.  Let us first understand how a program, using C compiler, is executed on a host machine.  User writes a program in C language (high-level language).  The C compiler, compiles the program and translates it to assembly program (low-level language).  An assembler then translates the assembly program into machine code (object).  A linker tool is used to link all the parts of the program together for execution (executable machine code).  A loader loads all of them into memory and then the program is executed. LANGUAGE PROCESSING SYSTEM Pre Processor Compiler Assembler Linker Loader Memory
  • 4. A compiler can broadly be divided into two phases based on the way they compile. 1. Analysis Phase Known as the front-end of the compiler, the analysis phase of the compiler reads the source program, divides it into core parts and then checks for lexical, grammar and syntax errors. The analysis phase generates an intermediate representation of the source program and symbol table, which should be fed to the Synthesis phase as input. 2. Synthesis Phase Known as the back-end of the compiler, the synthesis phase generates the target program with the help of intermediate source code representation and symbol table. COMPILER DESIGN- ARCHITECTURE Analysis Phase Synthesis Phase Intermediate code Source code Machine code
  • 5. INTERPRETER  An interpreter is a computer program that is used to directly execute program instructions written using one of the many high-level programming languages.  The interpreter transforms the high-level program into an intermediate language that it then executes, or it could parse the high-level source code and then performs the commands directly, which is done line by line or statement by statement.  The interpreter reads each statement of code and then converts or executes it directly. In contrast, an assembler or a compiler converts a high-level source code into native (compiled) code that can be executed directly by the operating system (e.g. by creating a .exe program).  This feature makes easy for programmers to check any particular line at the time of debugging, but slows down the overall time of execution of the entire program. Data Interpreter Source code Machine code Advantage Disadvantage The program code is already translat ed into machine code. Thus, it code execution time is less. Interpreters are easier to use, especially for beginners. You can't change the program withou t going back to the source code. Interpreted programs can run on compu ters that have the corresponding interpreter.
  • 6. Role of Compiler •Compliers reads the source code, outputs executable code •Translates software written in a higher-level language into instructions that computer can understand. It converts the text that a programmer writes into a format the CPU can understand. •The process of compilation is relatively complicated. It spends a lot of time analyzing and processing the program. •The executable result is some form of machine-specific binary code. Role of Interpreter •The interpreter converts the source code line-by-line during RUN Time. •Interpret completely translates a program written in a high-level language into machine level language. •Interpreter allows evaluation and modification of the program while it is executing. •Relatively less time spent for analyzing and processing the program •Program execution is relatively slow compared to compiler ROLE OF COMPILER & INTERPRETER
  • 7. Interpreter Compiler Translates program one statement at a time. Scans the entire program and translates it as a whole into machine code. Interpreters usually take less amount of time to analyze the source code. However, the overall execution time is comparatively slower than compilers. Compilers usually take a large amount of time to analyze the source code. However, the overall execution time is comparatively faster than interpreters. No intermediate object code is generated, hence are memory efficient. Generates intermediate object code which further requires linking, hence requires more memory. Errors are displayed for every instruction interpreted. Errors are displayed after entire program is checked. Programming languages like JavaScript, Python, Ruby use interpreters. Programming languages like C, C++, Java use compilers. COMPARISION OF INTERPRETER & COMPILER
  • 8. 1. Pure Interpreters:  In a pure interpreter, the source program is maintained in the source form throughout its interpretation. Each statement of source program is analyzed while interpreting. This arrangement acquires substantial analysis overheads when interpreting a statement. 2. Impure Interpreters:  An impure interpreter carries out some preliminary processing of the source program to decrease the analysis overheads during interpretation. To reduce the analysis overhead, some initial processing of the source program is done by the impure interpreter during interpretation.  The source program is given to the preprocessor and the preprocessor transforms the program to an intermediate representation (IR) that is used during interpretation.  This speeds up interpretation since the code component of the IR that is the IC, can be analyzed more resourcefully than the source form of the program. PURE AND IMPUTER INTERPRETER
  • 9.  Like interpreter, p-code compilers are also analyzed and convert source program into an intermediate code(IC).  P-code compilers are also called bytecode compilers & are very similar in concept to interpreter. The source program is analyzed and converted into an intermediate form, which is then executed interpretively.  With a P-Code compiler, this intermediate forms is the machine language for a hypothetical machine, often call pseudo-machine. P- code object programs can be executed on any machine that has a P- Code interpreter. P-CODE COMPILERS Compiler Object Program p-code P-code interpreter Source Program Advantage Disadvantage 1. Portability 1. Slower execution of program 2. Saves memory