Interpreter.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Paul Rovner, July 25, 1983 10:25 am
Russ Atkinson (RRA) February 12, 1985 3:00:02 pm PST
DIRECTORY
AMTypes USING [TV],
AMModel USING [Context],
Rope USING [ROPE],
SymTab USING [Ref];
Interpreter: CEDAR DEFINITIONS
= BEGIN OPEN AMModel, Rope, AMTypes;
AbortClosure: TYPE = RECORD [proc: AbortProc, data: REFNIL];
... called by Evaluate at intervals to ask whether it should abort its task and return.
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.