Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

Compiler Design

Dr.K.Suresh
CSE,SVEC
Compiler
Why Interpretation?
• Compiler: Large overhead before the code can
be run
• Alternative: Direct interpretation of the code
(immediate execution, no time-consuming
compilation)
Two Kinds of Interpreters
• Iterative interpretation: Well suited for quite
simple languages, and fast (at most 10 times
slower than compiled languages)
• Recursive interpretation: Well suited for more
complex languages, but slower (up to 100
times slower than compiled languages)
Applications:
• – Interactive systems (SQL, shell, etc)
• – Simple programming languages (Basic, etc)
• – Scripting languages (Perl, Python, etc)
• – Programming languages with special
requirements (Scheme,Prolog, Smalltalk, etc)
• – Write once, run once
Compilation and Interpretation
• Due to the slow speed of recursive
interpretation, complex languages (such as
Java) are often compiled to simpler languages
(such as JVM) that can be interpreted
iteratively
Lexical Analysis
Input buffering
• Buffer Pairs
Because of the amount of time taken to process
characters and the large number of characters
that must be processed during the
compilation of a large source program,
specialized buffering techniques have been
developed to reduce the amount of overhead
required to process a single input character.
Fig. Using a pair of input buffers
Specification of Tokens

You might also like