Java Reference
In-Depth Information
Interpreter
Output
Input
Source Program
Encoding
Data
Figure 1.3: An interpreter.
that are subsequently subjected to interpretation or dynamic compilation to
native machine code. The bytecodes are in a sense another source format, but
their encoding is a standard and relatively compact binary format. Java has a
native interface that is designed to allow Java code to interoperate with code
written in other languages. Java also requires dynamic linking of classes used
by an application, so that the origin of such classes can be controlled when an
application is invoked. When a class is first referenced, a class definition may
be remotely fetched, checked, and loaded during program execution.
1.3
Interpreters
Another kind of language processor is the interpreter . Interpreters share some
of the functionality found in compilers, such as syntactic and semantic analy-
ses. However, interpreters di
er from compilers in that they execute programs
without explicitly performingmuch translation. Figure 1.3 illustrates schemat-
ically how interpreters work. To an interpreter, a program is merely data that
can be arbitrarily manipulated, just like any other data. The locus of control
during execution resides in the interpreter, not
ff
in the user program (i.e., the
user program is passive rather than active).
Interpreters provide a number of capabilities not usually found in compil-
ers, as follows:
Programs can be easily modified as execution proceeds. This provides a
straightforward interactive debugging capability, since a programcan be
modified to pause at points of interest or to display the value of program
variables. Depending on programstructure, programmodifications may
require reparsing or repeating semantic analysis.
Languages in which the type of an object is developed dynamically
(e.g., Lisp and Scheme) are easily supported in an interpreter. Some
 
 
 
 
Search WWH ::




Custom Search