<> <> <> DIRECTORY MathRules USING [AtomBoxProc, AtomPaintProc, CompoundBoxProc, CompositionProc, AtomToASRopeProc, Size], MathBox USING [BOX], MathTypes USING [Style, FormatClass], Vector USING [VEC], IO, Rope USING [ROPE]; MathExpr: CEDAR DEFINITIONS ~ BEGIN <> ROPE: TYPE ~ Rope.ROPE; VEC: TYPE ~ Vector.VEC; BOX: TYPE ~ MathBox.BOX; Style: TYPE ~ MathTypes.Style; FormatClass: TYPE ~ MathTypes.FormatClass; AtomBoxProc: TYPE ~ MathRules.AtomBoxProc; AtomPaintProc: TYPE ~ MathRules.AtomPaintProc; AtomToASRopeProc: TYPE ~ MathRules.AtomToASRopeProc; CompoundBoxProc: TYPE ~ MathRules.CompoundBoxProc; CompositionProc: TYPE ~ MathRules.CompositionProc; Size: TYPE ~ MathRules.Size; <> Argument: TYPE ~ RECORD [ name: ATOM, -- unique (within enclosing class) identifier for argument aliases: LIST OF ATOM, -- aliases for name using convention $aliasFoo, $aliasBar size: Size -- relative sizing information (big, script, etc.) ]; Symbol: TYPE ~ RECORD[ name: ATOM, -- unique (within enclosing class) identifier for symbol aliases: LIST OF ATOM, -- aliases for name using convention $aliasFoo, $aliasBar size: Size, -- relative sizing information (big, script, etc.) value: EXPR -- a symbol is an expression ]; AtomFlavor: TYPE ~ {symbol, argument, placeholder}; AtomClass: TYPE ~ REF AtomClassRep; AtomClassRep: TYPE ~ RECORD [ name: ATOM, -- class identifier, e.g. $integer formatClass: FormatClass, -- e.g. atom flavor: AtomFlavor, -- type of atom: symbol, argument, placeholder style: Style, -- font info boxRule: MathRules.AtomBoxProc, -- returns info about atom size paintRule: MathRules.AtomPaintProc, -- paints atom onto imager context cvtASRope: MathRules.AtomToASRopeProc, -- converts atom for AlgebraStructures cvtReduceRope: MathRules.AtomToASRopeProc _ NIL, -- converts atom for Reduce cvtSMPRope: MathRules.AtomToASRopeProc _ NIL, -- converts atom for SMP cvtOtherRope: MathRules.AtomToASRopeProc _ NIL -- converts atom for Other ]; CompoundClass: TYPE ~ REF CompoundClassRep; CompoundClassRep: TYPE ~ RECORD [ name: ATOM, -- class identifier, e.g. $product formatClass: FormatClass, -- e.g. binaryOp description: ROPE, -- for menu buttons, etc. to describe how expr looks, e.g. "a + b" arguments: LIST OF Argument, symbols: LIST OF Symbol, boxRule: MathRules.CompoundBoxProc, compBox: MathRules.CompositionProc, cvtAS: ROPE _ NIL, -- conversion specification to AlgebraStructures cvtReduce: ROPE _ NIL, -- conversion specification to Reduce cvtSMP: ROPE _ NIL, -- conversion specification to SMP cvtOther: ROPE _ NIL -- conversion specification to Other ]; MatrixClass: TYPE ~ REF MatrixClassRep; MatrixClassRep: TYPE ~ RECORD [ name: ATOM, -- class identifier, e.g. $matrix or $determinant formatClass: FormatClass, -- e.g. matrix openSym, closeSym, space: EXPR -- expressions to use for (, ), and inter-elt spacing ]; <> <> <<>> EXPR: TYPE ~ REF MathExprRep; -- external abstract type <<-------------- commented out 3/2/87 ------->> <> <<--------------------------->> <<>> <<>> <<-------------- copied in from MathExprImpl 3/2/87 ------->> <> MathExprRep: TYPE ~ RECORD [ SELECT type:* FROM atom => [ class: AtomClass, -- atomic data type value: ROPE -- atomic value, e.g. integer as rope ], compound => [ class: CompoundClass, -- compound operation class, e.g. summation or product subExprs: LIST OF TaggedMathExpr _ NIL -- class operation arguments ], matrix => [ class: MatrixClass, -- type of matrix op, e.g. determinant or matrix, etc. nRows, nCols: INT, -- matrix size as rows x cols elements: LIST OF TaggedMathExpr _ NIL -- matrix elements ], ENDCASE ]; <<--------------------------->> <<---- commented out 3/2/87>> <> <> <> <> <> <> <<--------------------->> <<>> <<>> <<-------------- copied in from MathExprImpl 3/2/87 ------->> AtomExprRep: PUBLIC TYPE ~ atom MathExprRep; CompoundExprRep: PUBLIC TYPE ~ compound MathExprRep; MatrixExprRep: PUBLIC TYPE ~ matrix MathExprRep; <> <> AtomEXPR: TYPE ~ REF AtomExprRep; CompoundEXPR: TYPE ~ REF CompoundExprRep; MatrixEXPR: TYPE ~ REF MatrixExprRep; <<--------------------->> <<>> ExprFlavors: TYPE ~ {atom, compound, matrix}; TaggedMathExpr: TYPE ~ RECORD [ id: ATOM, expression: EXPR ]; <> MakeArgument: PROC[name: ATOM, aliases: LIST OF ATOM, size: Size] RETURNS[Argument]; <> MakeSymbol: PROC[name: ATOM, aliases: LIST OF ATOM, size: Size, value: EXPR] RETURNS[Symbol]; <> MakeAtomClass: PROC[name: ATOM, formatClass: FormatClass, flavor: AtomFlavor, style: Style, boxRule: AtomBoxProc, paintRule: AtomPaintProc, cvtASRule: AtomToASRopeProc _ NIL] RETURNS[AtomClass]; <> MakeCompoundClass: PROC[name: ATOM, formatClass: FormatClass, description: ROPE, args: LIST OF Argument, syms: LIST OF Symbol, boxRule: CompoundBoxProc, compBox: CompositionProc, cvtAS: ROPE _ NIL] RETURNS[CompoundClass]; <> <<>> MakeMatrixClass: PROC[name: ATOM, formatClass: FormatClass, openSym, closeSym, space: EXPR] RETURNS[MatrixClass]; <> <> MakeAtomicExpr: PROC[class: ATOM, value: ROPE] RETURNS[EXPR]; <> << SIGNALS badAtomClass if class is unrecognized>> MakeCompoundExpr: PROC[class: ATOM, args: LIST OF TaggedMathExpr] RETURNS[EXPR]; <> << SIGNALS badCompoundClass if class is unrecognized>> << SIGNALS badExprs if exprs has the wrong number or wrong type of elements>> <<>> MakeMatrixExpr: PROC[class: ATOM, nRows, nCols: NAT, elements: LIST OF TaggedMathExpr] RETURNS[EXPR]; <> << SIGNALS badMatrixClass if class is unrecognized>> << SIGNALS badMatrixSize if nRows or nCols is invalid>> << SIGNALS badMatrix if rows has the wrong number or wrong type of elements>> <> RopeFromExpr: PROC[expr: EXPR] RETURNS[ROPE]; <> << by ExprFromRope[].>> <<>> ExprFromRope: PROC[r: ROPE] RETURNS[EXPR]; <> << SIGNALS parseError if r is malformed.>> <<>> ExprFromStream: PROC[stream: IO.STREAM] RETURNS[EXPR]; <> << SIGNALS parseError if r is malformed.>> <> GetType: PROC[expr: EXPR] RETURNS[ExprFlavors]; <> << Returns compound if expr is a CompoundEXPR>> <<>> GetAtomClass: PROC[expr: AtomEXPR] RETURNS[AtomClass]; <> <<>> GetAtomExpr: PROC[expr: EXPR] RETURNS[AtomEXPR]; <> << Otherwise SIGNALS wrongExprType>> GetValue: PROC[expr: AtomEXPR] RETURNS[ROPE]; <> <<>> GetCompoundClass: PROC[expr: CompoundEXPR] RETURNS[CompoundClass]; <> <<>> GetCompoundExpr: PROC[expr: EXPR] RETURNS[CompoundEXPR]; <> << Otherwise SIGNALS wrongExprType>> <<>> GetMatrixExpr: PROC[expr: EXPR] RETURNS[MatrixEXPR]; <> << Otherwise SIGNALS wrongExprType>> GetSubExprs: PROC[expr: CompoundEXPR] RETURNS[LIST OF TaggedMathExpr]; <> <<>> GetMatrixElements: PROC[expr: MatrixEXPR] RETURNS[LIST OF TaggedMathExpr]; <> <<>> GetMatrixSize: PROC[expr: MatrixEXPR] RETURNS[NAT, NAT]; <> <<>> GetMatrixClass: PROC[expr: MatrixEXPR] RETURNS[MatrixClass]; <> <<>> <> GetTaggedExpr: PROC[tag: ATOM, exprs: LIST OF TaggedMathExpr] RETURNS[TaggedMathExpr]; <> << SIGNALS exprNotFound if no association exists.>> <> badAtomClass: ERROR; badCompoundClass: ERROR; badMatrixClass: ERROR; badExprs: ERROR[reason: ATOM]; exprNotFound: ERROR; wrongExprType: ERROR; parseError: ERROR; <<>> END.