- 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 Compiler Passes?
The whole source program can be processed several times before generating the assembly/machine code.
Pass − One complete scan or processing of the source program. Various phases can be arranged into one pass. Lexical, syntax & semantic analysis are often grouped in a single pass. Each pass reads the source program and writes output into an intermediate file, which then can be read by subsequent passes, i.e., the output of one pass will be input to the next pass.
Single-Pass Compiler − In a single-pass compiler, when a line source is processed it is scanned and the tokens are extracted. Then the syntax of the line is analyzed and the tree structure and some tables including data about each token are constructed.
Finally, after the semantical part is checked for correctness, the code is produced. The equivalent process is repeated for each line of the program until the whole program is compiled. Usually, the entire compiler is built around the parser, which will call procedures that will perform different functions.
A single-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 single-pass tends to impose some restrictions upon the program constants, types, variables, and procedures that must be defined before they are used.
The component of a single-pass compiler is inter-related, much closer than the components of a multi-pass compiler. This requires all the programmers working on the project to know about the entire project.
Multi-Pass Compiler − The compiler scans the input source once and makes the first modified form, then scans the first-produced form and produces a second modified form, etc., until the object form is produced. Such a compiler is known as a multi-pass compiler.
In the case of the multi-pass compiler, each function of the compiler can be performed by one pass of the compiler. For instance, the first pass can read the input source, scan and extract the tokens and save the result in an output file.
The second pass can read the file which was produced in the first pass, do the syntactical analysis by building a syntactical tree and associate all the information relating to each node of the tree. The output of the second pass then is a file containing the syntactical tree.
The third pass can read the output file created by the second pass and perform the optimization by restructuring the tree structure.
- Related Articles
- What is Compiler Design?
- What is Compiler Bootstrapping?
- What is Just-In-Time compiler?
- What is the difference between One-Pass Compiler and Multi-Pass Compiler?
- What is Chomsky Hierarchy in compiler design?
- What is error handling in compiler design?
- What is Input Buffering in Compiler Design?
- What is Finite Automata in Compiler Design?
- How is JIT compiler different from normal compiler?
- What is the difference between Compiler and Interpreter?
- What is Language Processing Systems in Compiler Design?
- What is the role of Compiler Construction Tools?
- What is minimizing of DFA in compiler design?
- What is the Representation of DFA in compiler design?
- What is Operator Precedence Parsing Algorithm in compiler design?
