All Packages Class Hierarchy This Package Previous Next Index
Class jie.Interpreter
java.lang.Object
|
+----jie.Interpreter
- public class Interpreter
- extends Object
Interpreter for the Java interactive environment.
The Interpreter executes a tokent tree by recursive descent and returns
a value.
The Interpeter supports the following java constructs:
- Variable declarations. Jie maintains a hashtable of local
variables for use in local expressions. Jie supports the full java
declaration syntax, with one exception: arrays must be declared as,
"
type[] variable
", not "type variable[]
".
Jie supports (multidimensional) array initializers, but they are currently
limited to initializing arrays of Integer, Float, and String. Jie does
not support primitive types as local variables, so all primitives must be
wrapped in their corresponding abstract type. When Jie is initialized, it
preloads a reference to its own instance under the name "jie". This
variable name can be used to reference the Jie fields and methods.
- Expressions. Jie currently supports the following operators:
- Assignment ("
=
")
- Construction ("
new
")
- Addition/string concatenation ("
+
")
- Subtraction, multiplication, division, mod ("-", "*", "/", "%")
- Comparison ("!=", "==", "<", ">", "<=", ">=")
- Control flow. Jie currently supports the following control flow
statements:
- while (Boolean) statement
- if (Boolean) statement [currently broken]
- if (Boolean) statement else statement
- Method calls. Jie supports both static and instance method calls.
Instance method calls may either dereference a local variable, or an
expression which returns an object of the appropriate type (e.g. method
call chaining). Jie will automatically unwrap parameters to the
corresponding primitive type if appropriate.
- Field references. Jie supports both static and instance
field references. Instance field references may either dereference a
local variable, or an expression which returns an object of the appropriate
type.
- Array references. Jie supports multidimensional arrays of any
abstract type. Indices can be any expression that evaluates to an Integer
object.
- Constants. Jie automatically converts string, integer, and float
constants to appropriate wrapped objects.
- Compound statement blocks. Normally, Jie interprets statements
one at a time. Statements enclosed within a pair of curly braces will be
parsed into a single token tree, and executed together.
- Labeled statements The Jie parser has a facility to store a
parsed statement for later recall. This is done with the following syntax:
label#statement
. Any future occurences of "label" will be
substituted with the token tree generated by "statement". This can be used
as a primitive macro facility or for aliasing frequently typed statements.
- Comments. Comments are useful for Jie script files
(see:
read()
)
The Interpreter does not support the following java constructs:
- Class declaration.
- Try/catch.
- Nested variable scopes
- Method declaration.
- Package importing.
- Version:
- 0.1.0
- Author:
- Michael Robinson (robinson@public.bta.net.cn)
- See Also:
- Shell
Interpreter(PrintStream, Context)
- Create a new Interpreter instance
Interpreter
public Interpreter(PrintStream err,
Context context) throws Exception
- Create a new Interpreter instance
All Packages Class Hierarchy This Package Previous Next Index