4. Interpreter
An interpreter is system software that translates a
given High-Level Language (HLL) program into a
low-level one, but it differs from compilers.
Interpretation is a real-time activity where an
interpreter takes the program, one statement at a
time, and translates each line before executing it.
5. Toy Interpreter
It is language processor that bridges execution
gap of a program without generating a target
program.
The interpreter is itself a program in a
programming language , which is compiled by a
compiler of that language.
The interpreter uses the symbol table and the
data stores are as follows: The symbol table has
entries for all the variables used in the program .
Each entry holds the name , type and address of
the variable.
6. Toy Interpreter
The data store that holds values of all program
variables and partial results during interpretation.
It consists of two large arrays named rvar and ivar
which are used to store values of types real and
integer respectively.
Last few locations in the array rvar and ivar are
used to stacks for expression evaluation with the
help of pointers r_tos and i_ios respectively. The
stack grows upward in the array.
7. Toy Interpreter
Each entry in the symbol table is a variable of
type symmetry. The type field of the entry is a
variable of enumerated type which takes either
real_type or int_type as its values.
8. Toy Interpreter
The interpreter program contains a set of routines
for use in expression evaluations one routine for
each kind of legal sub expression.
real a, b
integer c
let c=7
let b=1.2
a = b + c
9. Toy Interpreter
It implements the meaning by invoking
appropriate routines.
ivar[5] :=7
Similarly rvar[13] :=1.2
For interpretation of a=b+c procedure add is
called with the symbol table entries of b and c.
add analyzes the type of b and c and decides that
procedure addrealint will have to be called to
realize the addition.
10. Toy Interpreter
Addrealint executes rvar[r_tos] :=rvar[13] +
ivar[5];
So while compiling the expression rvar[addr1] +
ivar[addr2]
Thus , the interpreter simply arranges to execute
this statement under the right conditions.
12. References
Inspiration from Prof. Shrina Patel and Prof. Rimi
Gupta
Notes of SP
System Programming By D M Dhamdhere
Images from Google Images
Some My Own Knowledge