- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between One-Pass Compiler and Multi-Pass Compiler?
One-Pass Compiler
One pass compiler reads the code only once and then translates it. The one-pass compiler passes only once through the parts of each compilation unit. It can translate each part into its final machine program. In the one-pass compiler, when the line source is processed, it is scanned and the token is extracted. This is in contrast to a multi-pass compiler which modifies the program into one or more intermediate representations in steps between source program and machine program, and which convert the whole compilation unit in each sequential pass.
A one-pass compiler is fast since all the compiler code is loaded in the memory at once. It can process the source text without the overhead of the operating system having to shut down one process and start another. A one-pass tends to impose some restrictions upon the program constants, types, variables, and procedures that must be defined before they are used.
Multi-Pass Compiler
A multi-pass compiler can process the source code of a program multiple times. In the first pass, the compiler can read the source code, scan it, extract the tokens and save the result in an output file.
In the second pass, the compiler can read the output file produced by the first pass, build the syntactic tree and implement the syntactical analysis. The output of this phase is a file that includes the syntactical tree.
In the third pass, the compiler can read the output file produced by the second pass and check that the tree follows the rules of language or not. The output of the semantic analysis phase is the annotated tree syntax. This pass continues until the target output is produced.
Let us see the comparison between One-Pass and Multi-Pass Compiler.
One-Pass Compiler | Multi-Pass Compiler |
---|---|
It reads the code only once and translates it at a similar time. | It reads the code multiple times, each time changing it into numerous forms. |
They are faster. | They are "slower." As more number of passes means more execution time. |
Less efficient code optimization and code generation. | Better code optimization and code generation. |
It is also called a "Narrow compiler." It has limited scope. | It is also called a "wide compiler." As they can scan every portion of the program. |
The compiler requires large memory. | The memory occupied by one pass can be reused by a subsequent pass; therefore, small memory is needed by the compiler. |
Example − Pascal & C languages use one-pass compilation. | Example − Modula -2 languages use multi-pass compilation. |
- Related Articles
- What is the difference between Compiler and Interpreter?
- Difference between Compiler and Assembler
- Difference Between Compiler and Interpreter
- What is the difference between Definitions and Declarations in Compiler design?
- What is the difference between DFA and NFA in compiler design?
- What is the difference between SLR, CLR, and LALR Parser in compiler design?
- What is the difference between Procedural and Non-Procedural Languages in compiler design?
- What is the difference between Imperative languages and Functional languages in compiler design?
- What is Compiler Design?
- What is Compiler Passes?
- What is Compiler Bootstrapping?
- What is the difference between pass by value and reference parameters in C#?
- How is JIT compiler different from normal compiler?
- Which one is better in between pass by value or pass by reference in C++?
- What is Pass By Reference and Pass By Value in PHP?
