COUSINS OF COMPILER
1. Preprocessor 2. Assembler 3. Loader and Link-editor
Preprocessor
A preprocessor is a program that processes its input data to produce output that is used as input to another program. The output is said to be a preprocessed form of the input data, which is often used by some subsequent programs like compilers.
They may perform the following functions :
1. Macro processing 3. Rational Preprocessors
2. File Inclusion 4. Language extension
1. Macro processing:
A macro is a rule or pattern that specifies how a certain input sequence should be mapped to an output sequence according to a defined procedure. The mapping process that instantiates a macro into a specific output sequence is known as macro expansion.
2. File Inclusion:
Preprocessor includes header files into the program text. When the preprocessor finds an #include directive it replaces it by the entire content of the specified file.
3. Rational Preprocessors:
These processors change older languages with more modern flow-of-control and data-structuring facilities.
4. Language extension :
These processors attempt to add capabilities to the language by what amounts to built-in macros. For example, the language Equel is a database query language embedded in C.
Assembler
Assembler creates object code by translating assembly instruction mnemonics into machine code. There are two types of assemblers:
· One-pass assemblers go through the source code once and assume that all symbols will be defined before any instruction that references them.
· Two-pass assemblers create a table with all symbols and their values in the first pass, and then use the table in a second pass to generate code
Fig. 1.7 Translation of a statement
Linker and Loader
A linker or link editor is a program that takes one or more objects generated by a compiler and combines them into a single executable program. Three tasks of the linker are
1.Searches the program to find library routines used by program, e.g. printf(), math routines.
2. Determines the memory locations that code from each module will occupy and relocates its instructions by adjusting absolute references 3. Resolves references among files.
A loader is the part of an operating system that is responsible for loading programs in memory, one of the essential stages in the process of starting a program.
Translators
A software system which converts the source code from one form of language to another form of language is known as translator.
There are three types of translator:
- Assembler
- Compiler
- Interpreter
Compiler
It is a translator which converts the source code from high level of language to low level language.
Assembler
It is software which converts assembly code into object code, is called assembler.
Cousins of Compiler

1) Preprocessor
It converts the HLL (high level language) into pure high level language. It includes all the header files and also evaluates if any macro is included. It is the optional because if any language which does not support #include and macro preprocessor is not required.
2) Compiler
It takes pure high level language as a input and convert into assembly code.
3) Assembler
It takes assembly code as an input and converts it into assembly code.
4) Linking and loading
It has four functions
- Allocation:
It means get the memory portions from operating system and storing the object data. - Relocation:
It maps the relative address to the physical address and relocating the object code. - Linker:
It combines all the executable object module to pre single executable file. - Loader:
It loads the executable file into permanent storage.
