0% found this document useful (1 vote)
2K views6 pages

Cousins of Compiler

The document discusses the cousins of compilers, which are software tools that assist compilers. It describes preprocessors, which collect source code and perform tasks like macro processing and file inclusion. Assemblers convert assembly code to relocatable machine code by translating operations and identifiers to binary. Loaders and link editors take relocatable code and place instructions and data in memory, allowing programs to include library files. Compiler construction tools that help generate compilers are also outlined, such as parser generators, scanner generators, and code generators.

Uploaded by

syeda rabia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
2K views6 pages

Cousins of Compiler

The document discusses the cousins of compilers, which are software tools that assist compilers. It describes preprocessors, which collect source code and perform tasks like macro processing and file inclusion. Assemblers convert assembly code to relocatable machine code by translating operations and identifiers to binary. Loaders and link editors take relocatable code and place instructions and data in memory, allowing programs to include library files. Compiler construction tools that help generate compilers are also outlined, such as parser generators, scanner generators, and code generators.

Uploaded by

syeda rabia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

8/5/2020

Compiler Construction
[SWE-310]
Cousins of a Compiler

Compiler Construction [SWE-310] Cousins of a Compiler


Cousins of a Compiler

 The following softwares are called


cousins of compiler.

 Preprocessors

 Assemblers

 Loaders & Link Editors

1
8/5/2020

Compiler Construction [SWE-310] Cousins of a Compiler


Preprocessor

a) Preprocessor:

A source program may be divided into


modules stored in separate files.

 The preprocessor is a program which


collects source program.

Compiler Construction [SWE-310] Cousins of a Compiler


Preprocessor

A preprocessor may perform following


functions:

 Macro Processing:
• Define macros that are short hands for larger
constructs.
• E.g. #define PI 3.14

2
8/5/2020

Compiler Construction [SWE-310] Cousins of a Compiler


Preprocessor

 File Inclusion:
• Inclusion of header files into program text.
• i.e. #include <stdio.h>

 Rational Preprocessors:
• Augment older languages with more modern
flow of control and data structuring facilities.

Compiler Construction [SWE-310] Cousins of a Compiler


Preprocessor

 Language Extensions:
• Attempts to add capabilities to the language
by associating more built-in macros.
• E.g.#1 Inclusion of Assembly code by using
asm: directive.
• E.g.#2 Inclusion of database query language
Equel by using ##: directive in C language.

3
8/5/2020

Compiler Construction [SWE-310] Cousins of a Compiler


Assembler

 The Assembler converts Assembly language code


into reloctable machine code.
 The simplest form of Assembler incorporates two
passes.
 A pass consists of reading an input file once.
 In first pass all the identifiers that denote storage
location are found and stored in a symbol table.
 E.g. float a , b;
identifier address
a 0
b 4

Compiler Construction [SWE-310] Cousins of a Compiler


Assembler

 In second pass, the Assembler:


• Translates each operation code into the sequence
of bits representing operation in machine
language.
• Translates each identifier representing a location
into the address given for that identifier in the
symbol table.
 The output of second pass is reloctable machine
code
 i.e. it can be loaded starting at any location ‘L’ in
memory. (if ‘L’ is added to all addresses in the
code, then all references will be correct.

4
8/5/2020

Compiler Construction [SWE-310] Cousins of a Compiler


Loaders/Link Editors

 A loader performs;
• Loading
• Link-editing
 The loading refers to taking relocatable machine
code, altering it and placing the altered instruction
and data in memory at proper locations.
 The link-editor allows to make a single program
from several files of relocatable machine code.
 i.e. The inclusion of library files (<stdio.h> or
<conio.h>) or external routines.

Compiler Construction [SWE-310] Cousins of a Compiler


Compiler Construction Tools

 The following tools may be used for compiler


generation;
Parser generators
Scanner generators
Syntax-directed translation engine
Automatic code generators
Data flow engines

5
8/5/2020

Compiler Construction [SWE-310] Cousins of a Compiler


Compiler Construction Tools

 Parser Generators:
 Produce Syntax Analyzers based on context
free grammar.
 Scanner Generators:
 Generates lexical analyzers from a specification
based on regular expression.
 The resulting lexical analyzer is basically a finite
automaton.

Compiler Construction [SWE-310] Cousins of a Compiler


Compiler Construction Tools
 Syntax-directed Translation Engine:
 Produce collection of routines that walk the parse
tree.
 The result is the generation of intermediate code.
 Automatic Code Generators:
 Translates intermediate language into the machine
language.
 The translation mechanism is based on rules that
define each operation.
 Follows “template matching” technique.
 Data-flow Engines:
 Performs data-flow analysis for code optimization.

You might also like