User:Dhruvmahajan2

COMPILER

A compiler is a computer program (or set of programs) that translates text written in a computer language (the source language) into another computer language (the target language). The original sequence is usually called the source code and the output called object code.

The types of compilers are classified in: >- one-pass compilers >- multi-pass compilers >- load and go compiler >- optimizing compilers

One pass compiler: a compiler that translates the source unit in a single pass

Multi pass compiler: a compiler that translates the source unit in two or more passes

Load and go compiler: not sure, never seen this terminology, unless you're talking about an interpreter

Optimizing compiler: a compiler that optimizes the translated code, usually during the code generation phase

Compilation process Here is an overview as to what goes on inside a compiler:

In several steps input characters are turned into a sequence of terminal symbols and a symbol table and then into a tree representing the program expressed by the input characters.

The tree can then be converted into something that is more or less executable and will produce the effect expected by the program.

The compilation phases run more or less in parallel, i.e., the intermediate data may or may not be available explicitly.

How compilation progresses depends on the implemented language, e.g., if declare before use is required (as in C) or not (as in Java).


 * 1) Compilation in general is split into roughly 5 stages: Preprocessing, Parsing, Translation, Assembling, and Linking.

The compilation Process

Implementation examples

A macro instruction (macro) It is simply a notational convenience for the programmer to write a shorthand version of a program. It represents a commonly used group of statements in the source program. It is replaced by the macro processor with the corresponding group of source language statements. This operation is called "expanding the macro" For example: Suppose it is necessary to save the contents of all registers before calling a subroutine. This requires a sequence of instructions. We can define and use a macro, SAVEREGS, to represent this sequence of instructions.

Macro Instructions

A macro processor Its functions essentially involve the substitution of one group of characters or lines for another. Normally, it performs no analysis of the text it handles. It doesn't concern the meaning of the involved statements during macro expansion. Therefore, the design of a macro processor generally is machine independent. Macro processors are used in assembly language high-level programming languages, e.g., C or C++ OS command languages general purpose