You are on page 1of 23

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Compiler Design
KCS502
by
DR PARUL YADAV

Institute of Engineering and Technology, Lucknow


Lecture 1:
LANGUAGE PROCESSING SYSTEM
AND TRANSLATORS
Contents
• Language Processing System
• Translators
• Brief Introduction to Compiler
Computer: Hardware + Software
Language Processing System
Language Processing System
Preprocessor:

• Generally considered as part of


compiler

• Generates preprocessed code

• Produces input for compiler

• Expands macros
Language Processing System
Compiler:
• Translates source code written in HLL
into target code written in assembly
language or low level language
•Reports user about error(s) in source
program, if any

•Example: C/ C++, BASIC, COBOL,


FORTRAN, Ada compiler
Language Processing System
Assembler:
•Translates source code in
assembly language and target
code in machine language

•Example: MASM, NASM, gas,


as86, TASM, a86 and Terse
etc.
Language Processing System:
Linker and Loader
Translators
Compiler
Compiler v/s Interpreter
• Compiler
usually
produces
faster target
program.
• Interpreter
usually gives
better error
diagnostics.
• Example:
LIST, PHP,
PERL, ASP
etc.
• Interpreter: Executes source program statement by statement.
• Instead producing a target program, interpreter directly executes the operations
specified in the source program on inputs supplied by the user.
Decompiler

• Decompiler: Translates from low-level language to a high-level language


• Example: Data Flex Decompiler, .NET Decompiler etc.
• Used for recovery of lost source code
• Also useful in some cases of security, interoperability and error diagnostics
Assembler

• Translates source code in assembly language and target code in


machine language
• Example: MASM, NASM, gas, as86, TASM, a86 and Terse etc.
Disassembler

• Translates executable program into assembly language


• Reverse engineering tool (accepts commands from you for examining, if
stopped, for continuing program execution)
• Example: objdump, PVDasm, OllyDbg, SIMON, gdb etc.
Hybrid Compiler

• Combines compilation and interpretation


• Advantage: Intermediate code (byte code) compiled on one machine can be
interpreted on another machine, perhaps across the network
• In order to achieve faster processing of inputs to outputs, some JAVA compiler
called just-in-time compilers, translates the bytecode into machine language
immediately before they run the intermediate program to process the input.
Language Translator
• Translates between HLLs
• Source to source translator
• Language converter
• Used to add extension to
existing languages
• Used to good and portable
implementation of other
languages (eg. C)
• Sometimes for simplifying
development
Language Rewritter

• Translates form of
expressions without a
change in language
Compiler
Phases of Compiler
Single Pass Compiler
Two Pass Compiler
Multi Pass Compiler
Thank you

You might also like