The traversal of the source code is referred to as pass of a compiler. The two passes of compiler are One-pass compiler and Multi-pass compiler.
One Pass Compiler:
In one-pass compiler, each line of the source code is scanned to extract the tokens, and the parse tree is built. After the semantic check, intermediate code is represented and is optimized to generate the final target code.
The same process is repeated for every line of the code till the complete program is compiled.
Thus the one-pass compiler traverses the program only once to obtain its final machine code.
Multi pass Compiler:
In the first pass, the entire source program is scanned to extract the tokens and the result is stored in an output file.
In the second pass, the output file of the first pass is read to build the parse tree and the result is stored in a file.
In the third pass, the output file of the second pass is checked for semantic consistency and is stored.
The above process continues till the target code is reached.
Thus, multi-pass compiler processes the source program several times to obtain the target code.