InternalExpr.mesa
Mcisaac, July 20, 1987 4:03:21 pm PDT
Definitions for Mathematics Expressions
DIRECTORY
IO,
Rope USING [ROPE],
Vector USING [VEC],
BigInts,
BigReals;
InternalExpr: CEDAR DEFINITIONS ~
Type Abbreviations from Imported Interfaces
ROPE: TYPE ~ Rope.ROPE;
VEC: TYPE ~ Vector.VEC;
Expression Type Definitions
ATOMIC:
TYPE ~
RECORD[
SELECT type:* FROM
integer => [val: BigInts.BigInt],
real => [val: BigReals.BigReal],
symbol => [val: ATOM],
ENDCASE
];
EXPR: TYPE ~ REF InternalExprRep;
InternalExprRep:
TYPE ~
RECORD [
SELECT type:*
FROM
atomic => [val: ATOMIC], -- non recursive part of expression
function => [
-- recursive part of expression
name: EXPR,
subExprs: LIST OF EXPR ← NIL
],
ENDCASE
];
Parse/UnParse Routines
RopeFromExpr:
PROC[expr:
EXPR]
RETURNS[
ROPE];
effects: Returns a ROPE in a canonical format which can be parsed
by ExprFromRope[].
ExprFromRope:
PROC[r:
ROPE]
RETURNS[
EXPR];
effects: Parses r as an EXPR in canonical format output by RopeFromExpr[].
SIGNALS parseError if r is malformed.
ExprFromStream:
PROC[stream:
IO.
STREAM]
RETURNS[
EXPR];
effects: Parses r as an EXPR in canonical format output by RopeFromExpr[].
SIGNALS parseError if r is malformed.