Interpreter.mesa
Paul Rovner, July 25, 1983 10:25 am
DIRECTORY
AMTypes USING [TV],
AMModel USING [Context],
Rope USING [ROPE],
SymTab USING [Ref];
Interpreter: CEDAR DEFINITIONS
= BEGIN OPEN AMModel, Rope, AMTypes;
This is called by Evaluate at intervals to ask whether it should abort its task and return.
AbortClosure: TYPE = RECORD [proc: AbortProc, data: REFNIL];
nilAbortClosure: AbortClosure = [NIL, NIL];
AbortProc: TYPE = PROC [data: REF] RETURNS [abort: BOOLFALSE];
USING THE INTERPRETER
Evaluate: PROC
[rope: ROPE,
context: Context ← NIL, -- NIL means use AMModel.RootContext[LocalWorld[]]
symTab: SymTab.Ref ← NIL, -- look here first for name to TV lookup
abort: AbortClosure ← nilAbortClosure -- default is to never abort
]
RETURNS[result: TV, errorRope: ROPE, noResult: BOOL];
... parses and interprets the given rope as a Mesa expression, returning a TV for the result (noResult is TRUE if there is no result).
EvaluateToRope: PROC
[rope: ROPE,
context: Context ← NIL, -- NIL means use AMModel.RootContext[LocalWorld[]]
symTab: SymTab.Ref ← NIL, -- look here first for name to TV lookup
abort: AbortClosure ← [NIL, NIL] -- default is to never abort
]
RETURNS[result: ROPE, errorRope: ROPE, noResult: BOOL];
... is just like Evaluate, except that the result is a ROPE produced by IO.PutTV with defaulted arguments.
END.