DIRECTORY MathExpr, MathRules, MathDB, MathTypes, MathBox, Imager, Rope, Vector, MathConstructors; MathExprClassesVector: CEDAR PROGRAM IMPORTS MathBox, MathRules, MathExpr, MathDB, MathConstructors ~ BEGIN EXPR: TYPE ~ MathExpr.EXPR; BOX: TYPE ~ MathBox.BOX; ROPE: TYPE ~ Rope.ROPE; VEC: TYPE ~ Vector.VEC; CompoundBoxProc: TYPE ~ MathRules.CompoundBoxProc; CompositionProc: TYPE ~ MathRules.CompositionProc; Alignment2D: TYPE ~ MathRules.Alignment2D; Offset: TYPE ~ MathRules.Offset; Size: TYPE ~ MathRules.Size; Argument: TYPE ~ MathExpr.Argument; Symbol: TYPE ~ MathExpr.Symbol; CompoundClass: TYPE ~ MathExpr.CompoundClass; FormatClass: TYPE ~ MathTypes.FormatClass; Style: TYPE ~ MathTypes.Style; MakeArgument: PROC[name: ATOM, aliases: LIST OF ATOM, size: Size] RETURNS[Argument] ~ MathExpr.MakeArgument; MakeSymbol: PROC[name: ATOM, aliases: LIST OF ATOM, size: Size, value: EXPR] RETURNS[Symbol] ~ MathExpr.MakeSymbol; MakeCompoundClass: PROC[name: ATOM, formatClass: FormatClass, description: ROPE, args: LIST OF Argument, syms: LIST OF Symbol, boxRule: CompoundBoxProc, compBox: CompositionProc, cvtAS, cvtReduce, cvtSMP, cvtOther: ROPE _ NIL] RETURNS[CompoundClass] ~ MathExpr.MakeCompoundClass; smallGap: REAL = 0.05; medGap: REAL = 0.10; bigGap: REAL = 0.25; FixedSizeBoxRule: CompoundBoxProc ~ { RETURN[boxes]; }; UnaryOpCompRule: CompositionProc ~ { tempBox: BOX; tempBoxes: LIST OF BOX; alignments: LIST OF Alignment2D _ LIST[ [$aliasSpace, [$aliasUnaryOp, [left], [right]], [$aliasUnaryOp, [origin], [origin]]], [$aliasA, [$aliasSpace, [left], [right]], [$aliasSpace, [origin], [origin]]]]; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$aliasUnaryOp, [origin]], [$aliasUnaryOp, [origin]]]; RETURN[tempBox, tempBoxes]; }; BinaryOpCompRule: CompositionProc ~ { tempBox: BOX; tempBoxes: LIST OF BOX; leftVertOffsetA, leftVertOffsetOp, rightVertOffsetB, rightVertOffsetOp: Offset; alignments: LIST OF Alignment2D; SELECT MathBox.GetBox[$aliasA, boxes].FormatClass[] FROM over => { leftVertOffsetA _ [origin]; leftVertOffsetOp _ [center]; }; matrix => { leftVertOffsetA _ [center]; leftVertOffsetOp _ [center]; }; ENDCASE => { leftVertOffsetA _ [origin]; leftVertOffsetOp _ [origin]; }; SELECT MathBox.GetBox[$aliasB, boxes].FormatClass[] FROM over => { rightVertOffsetB _ [origin]; rightVertOffsetOp _ [center]; }; matrix => { rightVertOffsetB _ [center]; rightVertOffsetOp _ [center]; }; ENDCASE => { rightVertOffsetB _ [origin]; rightVertOffsetOp _ [origin]; }; alignments _ LIST[ [$aliasLeftSpace, [$aliasBinOp, [right], [left]], [$aliasBinOp, [origin], [origin]]], [$aliasA, [$aliasLeftSpace, [right], [left]], [$aliasBinOp, leftVertOffsetA, leftVertOffsetOp]], [$aliasRightSpace, [$aliasBinOp, [left], [right]], [$aliasBinOp, [origin], [origin]]], [$aliasB, [$aliasRightSpace, [left], [right]], [$aliasBinOp, rightVertOffsetB, rightVertOffsetOp]]]; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$aliasA, [origin]], [$aliasBinOp, [origin]]]; RETURN[tempBox, tempBoxes]; }; MakeUnaryOpClass: PUBLIC PROC[class, op, arg: ATOM, operation: EXPR, description: ROPE, cvtAS, cvtReduce, cvtSMP, cvtOther: ROPE _ NIL] RETURNS[CompoundClass] ~ { argArg: Argument _ MakeArgument[arg, LIST[$aliasA, $aliasHot], normal]; spaceSym: Symbol _ MakeSymbol[$Space, LIST[$aliasSpace], normal, MathConstructors.MakeSpace[$medium]]; unaryOpSym: Symbol _ MakeSymbol[op, LIST[$aliasUnaryOp], normal, operation]; RETURN[MakeCompoundClass[class, unaryOp, description, LIST[argArg], LIST[unaryOpSym, spaceSym], FixedSizeBoxRule, UnaryOpCompRule, cvtAS, cvtReduce, cvtSMP, cvtOther]]; }; MakeBinOpClass: PUBLIC PROC[class, op, a, b: ATOM, operation: EXPR, description: ROPE, cvtAS, cvtReduce, cvtSMP, cvtOther: ROPE _ NIL] RETURNS[CompoundClass] ~ { aArg: Argument _ MakeArgument[a, LIST[$aliasA, $aliasHot], normal]; bArg: Argument _ MakeArgument[b, LIST[$aliasB], normal]; opSym: Symbol _ MakeSymbol[op, LIST[$aliasBinOp], normal, operation]; leftSpace: Symbol _ MakeSymbol[$leftThinSpace, LIST[$aliasLeftSpace], normal, MathConstructors.MakeSpace[$thin]]; rightSpace: Symbol _ MakeSymbol[$rightThinSpace, LIST[$aliasRightSpace], normal, MathConstructors.MakeSpace[$thin]]; RETURN[MakeCompoundClass[class, binaryOp, description, LIST[aArg, bArg], LIST[opSym, leftSpace, rightSpace], FixedSizeBoxRule, BinaryOpCompRule, cvtAS, cvtReduce, cvtSMP, cvtOther]]; }; wrongBoxType: PUBLIC ERROR = CODE; InstallVectorClassesAA: PROC [] ~ { cDotClass, crossProdClass, transposeClass, determinantClass: CompoundClass; cDotClass _ MakeBinOpClass[$cDot, $times, $multiplier, $multiplicand, MathConstructors.MakePlainSym['\267], "a . b", "$multiplier * $multiplicand"]; crossProdClass _ MakeBinOpClass[$crossProd, $times, $multiplier, $multiplicand, MathConstructors.MakePlainSym['\264], "a x b", "$multiplier * $multiplicand"]; determinantClass _ MakeUnaryOpClass[$det, $det, $a, MathConstructors.MakePlainRope["det"], "det a", "det $a"]; transposeClass _ MakeUnaryOpClass[$transp, $tr, $a, MathConstructors.MakePlainRope["transp"], "transp a", "transp $a"]; MathDB.InstallCompoundClass[determinantClass]; MathDB.AddOperator[determinantClass, $Vector]; MathDB.InstallCompoundClass[transposeClass]; MathDB.AddOperator[transposeClass, $Vector]; MathDB.InstallCompoundClass[cDotClass]; MathDB.AddOperator[cDotClass, $Vector]; MathDB.InstallCompoundClass[crossProdClass]; MathDB.AddOperator[crossProdClass, $Vector]; }; InstallVectorClassesAA[]; END. ΪMathExprClassesVector.mesa Carl Waldspurger, August 30, 1986 7:12:37 pm PDT Bier, November 20, 1986 2:02:38 pm PST Arnon, March 24, 1987 4:15:37 pm PST Type Abbreviations from Imported Interfaces Procedure Abbreviations from Imported Interfaces Constants Box Procs for Compound Expr Classes effects: Returns unaltered boxes (i.e. no resizing takes place) Class CompRules effects: Composes layout for expr of form ($aliasUnaryOp $aliasA). effects: Composes layout for expr of form ($aliasBinOp $aliasA $aliasB) with symbols $aliasLeftSpace & $aliasRightSpace. set vertical offset depending on format classes of A & B arguments Class Constructors effects: Creates and returns standard unary operation compound class named "class". The alignment is "operation arg"; alignment is thru baselines. Both op, arg are of fixed size "normal". effects: Creates and returns standard binary operation compound class named "class". The alignment is "a operation b"; alignment is thru baselines. All of a, b, op are of fixed size "normal". Signals & Errors Define & Install Expression Classes local declarations binary operations unary operations Install Classes Defined in this Module Κι˜Jšœ™šœ0™0Icode™&K™$—J˜J˜šΟk ˜ Kšœ ˜ Kšœ ˜ K˜K˜ K˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜K˜—J˜šΟnœœœ˜%šœ˜&Jšœ˜—Jšœ˜J˜Jš˜—J˜headšž+™+Jšœœ œ˜Jšœœ œ˜Jšœœœ˜Jšœœ œ˜Jšœœ˜2Jšœœ˜2Jšœ œ˜*Jšœœ˜ Jšœœ˜J˜Jšœ œ˜#Jšœœ˜Jšœœ˜-Jšœ œ˜*Jšœœ˜—šž0™0Jšž œœœ œœœœ#˜lJ˜Jšž œœœ œœœœœ˜sJ˜Jšžœœœ)œœœœœaœœœ-˜——šž ™ Jšœ œ˜Jšœœ˜Jšœœ˜—šž#™#šžœ˜%Kšœ@™@Kšœ˜K˜——šž™šžœ˜$KšœC™CK˜Kšœ œ˜ Kšœ œœœ˜šœ œœœ˜'˜ K˜!K˜%—˜ K˜K˜$K˜——K˜sK˜Kšœ˜˜K˜——šžœ˜%KšœM™MK™5K™Kšœ œ˜ Kšœ œœœ˜K˜OKšœ œœ ˜ K˜KšœB™Bšœ.˜8˜ K˜K˜K˜—˜ K˜K˜K˜—šœ˜ K˜K˜K˜K˜——šœ.˜8˜ K˜K˜K˜—˜ K˜K˜K˜—šœ˜ K˜K˜K˜——K˜šœ œ˜˜Kšœ˜K˜#—˜ K˜#K˜2—˜K˜K˜#—˜ K˜$K˜5K˜——K˜jK˜Kšœ˜K˜—L™—šž™šžœœœœ œœ&œœœ˜’KšœT™TKšœJ™JKšœ2™2K™Kšœ%œ˜GKšœ&œ<˜fKšœ$œ%˜MKšœ0œ œ`˜¨K˜K˜—K˜šžœœœœ œœ&œœœ˜’KšœU™UKšœJ™JKšœ5™5K˜Kšœ!œ˜CKšœ!œ˜8Kšœœ"˜EKšœ/œ>˜qKšœ1œ?˜tK˜Kšœ1œœi˜ΆK˜—K˜—šž™Kšœœœœ˜"—šž$™$šžœœ˜#K˜Kšœ™KšœK˜KK˜K™Kšœ™Kšœ”˜”Kšœž˜žK˜Kšœ™Kšœn˜nKšœw˜wK˜K˜Kšœ.˜.Kšœž œ˜.Kšœ,˜,Kšœž œ˜,K˜'Kšœž œ˜'K˜,Kšœž œ˜,K˜K˜K˜——šž&™&Kšœ˜—K˜šœ˜K˜—J˜J˜J˜—…—| ?