DIRECTORY MathRules USING [AtomBoxProc, AtomPaintProc, CompoundBoxProc, CompositionProc, AtomToRopeProc, Size], MathBox USING [BOX], MathTypes USING [Style, AtomValue], ImagerFont USING [Extents], Vector USING [VEC], Rope USING [ROPE]; MathExpr: CEDAR DEFINITIONS ~ BEGIN ROPE: TYPE ~ Rope.ROPE; VEC: TYPE ~ Vector.VEC; BOX: TYPE ~ MathBox.BOX; Style: TYPE ~ MathTypes.Style; AtomValue: TYPE ~ MathTypes.AtomValue; AtomBoxProc: TYPE ~ MathRules.AtomBoxProc; AtomPaintProc: TYPE ~ MathRules.AtomPaintProc; CompoundBoxProc: TYPE ~ MathRules.CompoundBoxProc; CompositionProc: TYPE ~ MathRules.CompositionProc; AtomToRopeProc: TYPE ~ MathRules.AtomToRopeProc; Size: TYPE ~ MathRules.Size; EXPR: TYPE ~ REF MathExprRep; -- external abstract type MathExprRep: TYPE; -- internal concrete rep AtomEXPR: TYPE ~ REF AtomExprRep; -- abstract AtomExprRep: TYPE; -- concrete CompoundEXPR: TYPE ~ REF CompoundExprRep; -- abstract CompoundExprRep: TYPE; -- concrete MatrixEXPR: TYPE ~ REF MatrixExprRep; -- abstract MatrixExprRep: TYPE; -- concrete ExprFlavors: TYPE ~ {atom, compound, matrix}; MatrixFlavor: TYPE ~ RECORD [ class: ATOM -- type of matrix expr, e.g. matrix or determinant ]; TaggedMathExpr: TYPE ~ RECORD [ id: ATOM, expression: EXPR ]; AtomFlavor: TYPE ~ {symbol, argument, placeholder}; AtomClass: TYPE ~ REF AtomClassRep; AtomClassRep: TYPE ~ RECORD [ name: ATOM, -- class identifier, e.g. $integer 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 cvtRope: MathRules.AtomToRopeProc -- returns value as rope ]; CompoundClass: TYPE ~ REF CompoundClassRep; CompoundClassRep: TYPE ~ RECORD [ name: ATOM, -- class identifier, e.g. $product 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 Dennis Arnon's AlgebraSystem ]; 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 ]; 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, flavor: AtomFlavor, style: Style, boxRule: AtomBoxProc, paintRule: AtomPaintProc, cvtRope: AtomToRopeProc] RETURNS[AtomClass]; MakeCompoundClass: PROC[name: ATOM, description: ROPE, args: LIST OF Argument, syms: LIST OF Symbol, boxRule: CompoundBoxProc, compBox: CompositionProc, cvtAS: ROPE _ NIL] RETURNS[CompoundClass]; MakeAtomChar: PROC[c: CHAR] RETURNS[AtomValue]; MakeAtomRope: PROC[r: ROPE] RETURNS[AtomValue]; MakeAtomBox: PROC[b: ImagerFont.Extents] RETURNS[AtomValue]; MakeAtomOther: PROC[other: REF ANY] RETURNS[AtomValue]; MakeAtomicExpr: PROC[class: ATOM, value: AtomValue] RETURNS[EXPR]; MakeCompoundExpr: PROC[class: ATOM, args: LIST OF TaggedMathExpr] RETURNS[EXPR]; MakeMatrixExpr: PROC[flavor: MatrixFlavor, nRows, nCols: NAT, elements: LIST OF TaggedMathExpr, openSym, closeSym, space: EXPR] RETURNS[EXPR]; GetType: PROC[expr: EXPR] RETURNS[ExprFlavors]; GetAtomClass: PROC[expr: AtomEXPR] RETURNS[AtomClass]; GetAtomExpr: PROC[expr: EXPR] RETURNS[AtomEXPR]; GetValue: PROC[expr: AtomEXPR] RETURNS[AtomValue]; GetCompoundClass: PROC[expr: CompoundEXPR] RETURNS[CompoundClass]; GetCompoundExpr: PROC[expr: EXPR] RETURNS[CompoundEXPR]; GetMatrixExpr: PROC[expr: EXPR] RETURNS[MatrixEXPR]; GetSubExprs: PROC[expr: CompoundEXPR] RETURNS[LIST OF TaggedMathExpr]; GetMatrixElements: PROC[expr: MatrixEXPR] RETURNS[LIST OF TaggedMathExpr]; GetMatrixSize: PROC[expr: MatrixEXPR] RETURNS[NAT, NAT]; GetMatrixFlavor: PROC[expr: MatrixEXPR] RETURNS[MatrixFlavor]; GetMatrixOpenSym: PROC[expr: MatrixEXPR] RETURNS[EXPR]; GetMatrixCloseSym: PROC[expr: MatrixEXPR] RETURNS[EXPR]; GetMatrixSpace: PROC[expr: MatrixEXPR] RETURNS[EXPR]; GetTaggedExpr: PROC[tag: ATOM, exprs: LIST OF TaggedMathExpr] RETURNS[TaggedMathExpr]; badAtomClass: ERROR; badCompoundClass: ERROR; badExprs: ERROR[reason: ATOM]; exprNotFound: ERROR; wrongExprType: ERROR; invalidReplacement: ERROR; END. ΨMathExpr.mesa Carl Waldspurger, August 13, 1986 9:09:50 pm PDT Definitions for Mathematics Expressions Abbreviations from Imported Interfaces Mathematics Expressions An EXPR is an IMMUTABLE mathematical expression with formatting information. Expression Class Type Definitions Other Types Constructors Primitive Constructors effects: constructs and returns an argument object effects: constructs and returns a symbol object effects: constructs and returns a new atom class object effects: constructs and returns a new compound class object effects: Constructs and returns a new atom value of type char effects: Constructs and returns a new atom value of type rope effects: Constructs and returns a new atom value of type box. effects: COnstructs and returns a new atom value of type other Math Expression Constructors effects: constructs and returns a new atomic expression object SIGNALS badAtomClass if class is unrecognized effects: constructs and returns a new compound expression object SIGNALS badCompoundClass if class is unrecognized SIGNALS badExprs if exprs has the wrong number or wrong type of elements effects: constructs and returns a new matrix expression object SIGNALS badMatrixSize if nRows or nCols is invalid SIGNALS badMatrix if rows has the wrong number or wrong type of elements Selectors effect: Returns atom if expr is an AtomEXPR, Returns compound if expr is a CompoundEXPR effects: Returns the class of atomic expression expr. effects: If expr.Type = atom, returns atomic expression. Otherwise SIGNALS wrongExprType effects: Returns the value of atomic expression expr. effects: Returns the class of compound expression expr. effects: If expr.Type = compound, returns compound expression. Otherwise SIGNALS wrongExprType effects: IF expr.Type[] = matrix, returns matrix expression Otherwise SIGNALS wrongExprType effects: Returns the subexpressions for compound expression expr. effects: Returns the rows of expression for matrix expression expr. effects: Returns the size (dimensions) of expr as [nRows, nCols] effects: Returns the flavor of expr. effects: Returns open symbol expression of expr effects: Returns close symbol expression of expr effects: Returns space expression of expr List Selectors effects: Returns the TaggedMathExpr in exprs associated with tag. SIGNALS exprNotFound if no association exists. Signals & Errors Κ ˜Jšœ ™ Jšœ0™0J˜JšΟn'™'J˜codešΟk ˜ Kšœ žœV˜eKšœžœžœ˜Kšœ žœ˜#Kšœ žœ ˜Kšœžœžœ˜Kšœžœžœ˜—K˜K˜šœžœž œ˜K˜šž˜K˜—Kš&œ™'˜Kšžœžœžœ˜Kšžœžœ žœ˜K˜Kšžœžœ žœ˜Kšœžœ˜Kšœ žœ˜&Kšœ žœ˜*Kšœžœ˜.Kšœžœ˜2Kšœžœ˜2Kšœžœ˜0Kšœžœ˜—K™K™Kš™™KšœL™L—˜KšžœžœžœΟc˜8Kšœ žœŸ˜,K˜Kšœ žœžœŸ ˜.Kšœ žœŸ ˜KšœžœžœŸ ˜6KšœžœŸ ˜#Kšœ žœžœŸ ˜2KšœžœŸ ˜!K˜Kšœ žœ˜-šœžœž˜KšœžœŸ2˜>K˜K˜—K˜šœžœ˜šžœ˜Kšœžœ˜ Kšœ ž˜K˜—K˜—K˜—Kš!™!˜Jšœ žœ#˜3Jšœ žœžœ˜#šœžœ˜šžœ˜KšœžœŸ"˜/KšœŸ/˜DKšœŸ ˜Kšœ!Ÿ˜@Kšœ%Ÿ"˜GKšœ"Ÿ˜:K˜—K˜—Kšœžœžœ˜+šœžœ˜šžœ˜KšœžœŸ"˜/Kšœ žœŸB˜VKšœ žœžœ ˜Kšœ žœžœ˜K˜#K˜#KšœžœžœŸ;˜NK˜—K˜K˜—K˜—š ™ K™šœ žœžœ˜KšœžœŸ;˜HKšœ žœžœžœŸ9˜PKšœ Ÿ2˜=K˜K˜—šœžœžœ˜KšœžœŸ8˜EKšœ žœžœžœŸ9˜PKšœ Ÿ1œ˜>KšœžœŸ˜(Kšœ˜—K˜K˜˜K˜——Kš ™ ˜Kš™K™š œžœžœ žœžœžœžœ ˜TKšœ3™3—K˜š œžœžœ žœžœžœžœžœ ˜]Kšœ0™0K˜—š œžœžœmžœ ˜žKšœ8™8—K˜šœžœžœžœžœžœžœžœDžœžœžœ˜ΓKšœ=™=—K™š œžœžœžœ ˜/Kšœ>™>K˜—š œžœžœžœ ˜/Kšœ>™>—K™š œžœžœ ˜™>—K˜š  œžœžœžœžœ ˜7Kšœ?™?—K˜K˜Kš™K˜š œžœžœžœžœ˜BKšœ?™?Kšœ7™7K˜—šœžœžœžœžœžœžœ˜PKšœA™AKšœ;™;KšœR™R—K™šœžœ%žœ žœžœ+žœžœžœ˜ŽKšœ?™?Kšœ<™Kšœ%™%—K™šœžœžœžœ˜7Kšœ0™0K˜—šœžœžœžœ˜8Kšœ1™1—K™šœžœžœžœ˜5Kšœ*™*—K˜™K™——K™Kš™˜š  œžœžœ žœžœžœ˜VKšœB™BKšœ8™8——K™K™Kš™˜Kšœžœ˜Kšœžœ˜Kšœ žœ žœ˜Kšœžœ˜Kšœžœ˜Kšœžœ˜K˜—™K˜—šžœ˜˜K˜K˜˜K˜—————…—Ό%4