public abstract class Expression
extends java.lang.Object
Value
.Modifier and Type | Class and Description |
---|---|
static class |
Expression.Application
A Function application (e1 e2), where
e1 must evaluate to a
Function . |
static class |
Expression.Binary
(e1 op e2); yes it's just a
special kind of
Expression.Application . |
static class |
Expression.Block
let <
Decs > in e. |
static class |
Expression.Const
|
static class |
Expression.Ident
|
static class |
Expression.IfExp
(if e1 then e2 else e3); yes it's
just a special kind of
Expression.Application -- of
cond = \x1.\x2.\x3.x1 x2 x3 |
static class |
Expression.LambdaExp
λ x.e denotes a
Function . |
static class |
Expression.Tuple
(e0, e1, ...); also see
Value.Tuple . |
static class |
Expression.Unary
(op e); yes it's just a
special kind of
Expression.Application . |
Modifier and Type | Field and Description |
---|---|
static int |
APPLICATION
A tag; see
n() . |
static int |
BINARY
A tag; see
n() . |
static int |
BLOCK
A tag; see
n() . |
static int |
CONST
A tag; see
n() . |
static Expression.Const |
ffalse
Expression.Const ant false; see Value.ffalse . |
static int |
IDENT
A tag; see
n() . |
static int |
IFEXP
A tag; see
n() . |
static int |
LAMBDAEXP
A tag; see
n() . |
static Expression.Const |
nilCon
Expression.Const ant nil; see Value.nilVal . |
static Expression.Const |
triv
Expression.Const ant triv; see Value.triv . |
static Expression.Const |
ttrue
Expression.Const ant true; see Value.ttrue . |
static int |
TUPLE
A tag; see
n() . |
static int |
UNARY
A tag; see
n() . |
Constructor and Description |
---|
Expression() |
Modifier and Type | Method and Description |
---|---|
abstract void |
appendSB(java.lang.StringBuffer sb)
The use of a StringBuffer, sb, gives linear complexity when
printing large Values; also see
toString() . |
Value |
defer(Environment r)
In general, create a
Defer(this,r) ,
a "thunk", to evaluate 'this' Expression later, but also
see Expression.Const.defer(la.la.Environment) and Expression.LambdaExp.defer(la.la.Environment) . |
void |
error(java.lang.String msg)
Throw a RuntimeException.
|
Value |
eval(Environment r)
EVALuate 'this'
Expression , using Environment 'r',
to produce a Value . |
abstract int |
n()
n(), the numerical code (tag) of a subclass of Expression,
for example, for switch-ing.
|
java.lang.String |
toString()
The use of
appendSB(java.lang.StringBuffer) , and hence a StringBuffer,
gives linear rather than quadratic complexity. |
public static final int IDENT
n()
.public static final int CONST
n()
.public static final int TUPLE
n()
.public static final int LAMBDAEXP
n()
.public static final int APPLICATION
n()
.public static final int UNARY
n()
.public static final int BINARY
n()
.public static final int IFEXP
n()
.public static final int BLOCK
n()
.public static final Expression.Const ttrue
Expression.Const
ant true; see Value.ttrue
.public static final Expression.Const ffalse
Expression.Const
ant false; see Value.ffalse
.public static final Expression.Const triv
Expression.Const
ant triv; see Value.triv
.public static final Expression.Const nilCon
Expression.Const
ant nil; see Value.nilVal
.public abstract void appendSB(java.lang.StringBuffer sb)
toString()
.public java.lang.String toString()
appendSB(java.lang.StringBuffer)
, and hence a StringBuffer,
gives linear rather than quadratic complexity.toString
in class java.lang.Object
public abstract int n()
public Value defer(Environment r)
Defer(this,r)
,
a "thunk", to evaluate 'this' Expression later, but also
see Expression.Const.defer(la.la.Environment)
and Expression.LambdaExp.defer(la.la.Environment)
.public Value eval(Environment r)
Expression
, using Environment 'r',
to produce a Value
. Implements the tail-recursion
optimisation. Acts directly for Expression.Application
,
Expression.Block
and Expression.IfExp
.public void error(java.lang.String msg)