Interpreter.mesa
Paul Rovner, April 13, 1983 4:36 pm
Russ Atkinson, April 13, 1983 2:49 pm
DIRECTORY
AMModel USING [Context],
Rope USING [ROPE],
RTBasic USING [TV],
SymTab USING [Ref],
WorldVM USING [World];
Interpreter: CEDAR DEFINITIONS
= BEGIN OPEN AMModel, Rope, RTBasic, WorldVM;
AbortClosure: TYPE = RECORD [proc: AbortProc, data: REFNIL];
AbortProc: TYPE = PROC [data: REF] RETURNS [abort: BOOL ← FALSE];
USING THE INTERPRETER
Evaluate: PROC
[rope: ROPE,
context: Context ← NIL, -- NIL means use ContextForWorld[LocalWorld[]]
global: Context ← NIL, -- NIL means no global context
symTab: SymTab.Ref ← NIL, -- look here first for name to TV lookup
abort: AbortClosure ← [NIL, NIL] -- 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 ContextForWorld[LocalWorld[]]
global: Context ← NIL, -- NIL means no global context
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.
NAME-LOOKUP CONTEXTS
ContextForLocalFrame: PROC [lf: TV] RETURNS [Context];
returns context for the given local frame
the world and gf components are inherited
ContextForGlobalFrame: PROC [gf: TV] RETURNS [Context];
returns context for the given global frame
the world component is inherited
ContextForWorld: PROC [world: World ← NIL] RETURNS [Context];
returns context for the given world (NIL => LocalWorld[])
END.