DefineClasses:
PROC [] ~ {
local declarations (lots of 'em)
cmr10, cmti10, cmmi10, cmex10, cmsy10: Style;
integerClass, realClass, variableClass, plainSymClass, smallMathSymClass, bigMathSymClass, italSymClass, mathItalSymClass, lineClass, placeholderClass, spaceClass: AtomClass;
sumClass, summationClass, fractionClass, integrationClass, differenceClass, powClass, eqFormulaClass, ltFormulaClass, leFormulaClass, geFormulaClass, gtFormulaClass, radicalClass, complexClass, productClass, orClass, notClass, negationClass, andClass, parenClass: CompoundClass;
lbArg, ubArg, summandArg, llimArg, ulimArg, integrandArg, wrtArg, baseArg, exponentArg, numeratorArg, denominatorArg, nArg, radicandArg, multiplierArg, multiplicandArg, realPartArg, imaginaryPartArg, aParenArg: Argument;
plusSym, sigmaSym, integralSym, dxSym, lineSym, radRootSym, radLineSym, iSym, leftParenSym, rightParenSym: Symbol;
reset current DB state (i.e. clean slate)
MathDB.ResetAtomClasses[];
MathDB.ResetCompoundClasses[];
plain vanilla TeX fonts
cmr10 ← [font: "xerox/pressfonts/cmr60"]; -- standard times roman (1 unit high)
cmti10 ← [font: "xerox/pressfonts/cmti60"]; -- italic (1 unit high)
cmex10 ← [font: "xerox/pressfonts/cmex60"]; -- math extentsion font (1 unit high)
cmmi10 ← [font: "xerox/pressfonts/cmmi60"]; -- math italic font (1 unit high)
cmsy10 ← [font: "xerox/pressfonts/cmsy60"]; -- math symbols font (1 unit high)
define Atom Classes
integerClass ← MakeAtomClass[$integer, atom, argument, cmr10, RopeBox, PaintRope, CvtRopeToRope];
realClass ← MakeAtomClass[$real, atom, argument, cmr10, RopeBox, PaintRope, CvtRopeToRope];
variableClass ← MakeAtomClass[$variable, atom, argument, cmti10, RopeBox, PaintRope, CvtRopeToRope];
plainSymClass ← MakeAtomClass[$plainSym, atom, symbol, cmr10, CharBox, PaintChar, CvtCharToRope];
bigMathSymClass ← MakeAtomClass[$bigMathSym, atom, symbol, cmex10, CharBox, PaintChar, CvtCharToRope];
smallMathSymClass ← MakeAtomClass[$smallMathSym, atom, symbol, cmsy10, CharBox, PaintChar, CvtCharToRope];
mathItalSymClass ← MakeAtomClass[$mathItalicSym, atom, symbol, cmmi10, CharBox, PaintChar, CvtCharToRope];
italSymClass ← MakeAtomClass[$italicSym, atom, symbol, cmti10, CharBox, PaintChar, CvtCharToRope];
lineClass ← MakeAtomClass[$line, atom, symbol, cmr10, LineBox, PaintLine, CvtOtherToRope];
placeholderClass ← MakeAtomClass[$placeholder, atom, placeholder, cmmi10, RopeBox, PaintRope, CvtRopeToRope];
spaceClass ← MakeAtomClass[$space, atom, symbol, cmr10, SpaceBox, PaintSpace, CvtSpaceToRope];
register atom classes
MathDB.InstallAtomClass[integerClass];
MathDB.InstallAtomClass[realClass];
MathDB.InstallAtomClass[variableClass];
MathDB.InstallAtomClass[plainSymClass];
MathDB.InstallAtomClass[italSymClass];
MathDB.InstallAtomClass[smallMathSymClass];
MathDB.InstallAtomClass[bigMathSymClass];
MathDB.InstallAtomClass[mathItalSymClass];
MathDB.InstallAtomClass[lineClass];
MathDB.InstallAtomClass[placeholderClass];
MathDB.InstallAtomClass[spaceClass];
define info for "complex a b" (a + bi)
realPartArg ← MakeArgument[$a, LIST[$aliasA, $aliasHot], normal];
imaginaryPartArg ← MakeArgument[$b, LIST[$aliasB], normal];
iSym ← MakeSymbol[$i, NIL, normal, MakeItalSym['i]];
plusSym ← MakeSymbol[$plus, LIST[$aliasBinOp], normal, MakePlainSym['+]];
define info for "product multiplier multiplicand"
multiplierArg ← MakeArgument[$multiplier, LIST[$aliasA, $aliasHot], normal];
multiplicandArg ← MakeArgument[$multiplicand, LIST[$aliasB], normal];
define info for "summation lowerbound upperbound summand"
lbArg ← MakeArgument[$lowerbound, NIL, script];
ubArg ← MakeArgument[$upperbound, NIL, script];
summandArg ← MakeArgument[$summand, LIST[$aliasHot], normal];
sigmaSym ← MakeSymbol[$sigma, LIST[$aliasOp], normal, MakeBigMathSym['\130]];
define info for "integral lowerlimit upperlimit integrand"
llimArg ← MakeArgument[$lowerlimit, NIL, script];
ulimArg ← MakeArgument[$upperlimit, NIL, script];
integrandArg ← MakeArgument[$integrand, LIST[$aliasHot], normal];
wrtArg ← MakeArgument[$wrt, NIL, script];
integralSym ← MakeSymbol[$integral, LIST[$aliasOp], normal, MakeBigMathSym['\132]];
dxSym ← MakeSymbol[$dx, NIL, script, MakeItalSym['d]];
define info for "pow base exponent"
baseArg ← MakeArgument[$base, LIST[$aliasA, $aliasHot], normal];
exponentArg ← MakeArgument[$exponent, LIST[$aliasB], script];
define info for "fraction numerator denominator"
numeratorArg ← MakeArgument[$numerator, LIST[$aliasA, $aliasHot], normal];
denominatorArg ← MakeArgument[$denominator, LIST[$aliasB], normal];
lineSym ← MakeSymbol[$fractionBar, LIST[$aliasLine], normal, MakeLine[]];
define info for "radical n radicand"
nArg ← MakeArgument[$n, LIST[$aliasB], script];
radicandArg ← MakeArgument[$radicand, LIST[$aliasA, $aliasHot], normal];
radRootSym ← MakeSymbol[$radRoot, NIL, normal, MakeBigMathSym['\162]];
radLineSym← MakeSymbol[$radLine, LIST[$aliasLine], normal, MakeLine[]];
define info for "( a )"
aParenArg ← MakeArgument[$a, LIST[$aliasA, $aliasHot], normal];
leftParenSym ← MakeSymbol[$leftParen, NIL, normal, MakeBigMathSym['\040]];
rightParenSym ← MakeSymbol[$rightParen, NIL, normal, MakeBigMathSym['\041]];
define compound classes
binary operations
sumClass ← MakeBinOpClass[$sum, $plus, $addend, $augend, MakePlainSym['+], "a + b", "$addend + $augend"];
differenceClass ← MakeBinOpClass[$difference, $minus, $subtrahend, $minuend, MakePlainSym['\173], "a - b", "$subtrahend - $minuend"];
andClass ← MakeBinOpClass[$and, $andOp, $a, $b, MakeSmallMathSym['\136], "a AND b", "$a & $b"];
orClass ← MakeBinOpClass[$or, $orOp, $a, $b, MakeSmallMathSym['\137], "a OR b", "$a | $b"];
unary operations
negationClass ← MakeUnaryOpClass[$negation, $minus, $a, MakePlainSym['-], "-a", "-$a"];
notClass ← MakeUnaryOpClass[$not, $notOp, $a, MakeSmallMathSym['\072], "~a", "~ $a"];
relations
eqFormulaClass ← MakeRelationClass[$eqFormula, $equals, $lhs, $rhs, MakePlainSym['=], "lhs = rhs", "$lhs = $rhs"];
ltFormulaClass ← MakeRelationClass[$ltFormula, $lt, $lhs, $rhs, MakeMathItalSym['<], "lhs < rhs", "$lhs < $rhs"];
gtFormulaClass ← MakeRelationClass[$gtFormula, $gt, $lhs, $rhs, MakeMathItalSym['>], "lhs > rhs", "$lhs > $rhs"];
leFormulaClass ← MakeRelationClass[$leFormula, $le, $lhs, $rhs, MakeSmallMathSym['\024], "lhs <= rhs", "$lhs <= $rhs"];
geFormulaClass ← MakeRelationClass[$geFormula, $ge, $lhs, $rhs, MakeSmallMathSym['\025], "lhs >= rhs", "$lhs >= $rhs"];
others
complexClass ← MakeCompoundClass[$complex, other, "a + bi", LIST[realPartArg, imaginaryPartArg], LIST[iSym, plusSym], FixedSizeBoxRule, ComplexCompRule, "($a + $bi)"];
productClass ← MakeCompoundClass[$product, binaryOp, "a * b", LIST[multiplierArg, multiplicandArg], NIL, FixedSizeBoxRule, ProductCompRule, "$multiplier $multiplicand"];
summationClass ← MakeCompoundClass[$summation, op, "summation", LIST[lbArg, ubArg, summandArg], LIST[sigmaSym], FixedSizeBoxRule, SummationCompRule, "(summation ($lowerbound) ($upperbound) ($summand))"];
integrationClass ← MakeCompoundClass[$integration, op, "integration", LIST[llimArg, ulimArg, integrandArg, wrtArg], LIST[integralSym, dxSym], FixedSizeBoxRule, IntegrationCompRule, "(integral ($lowerlimit) ($upperlimit) ($integrand) ($wrt))"];
powClass ← MakeCompoundClass[$pow, other, "a^b", LIST[baseArg, exponentArg], NIL, FixedSizeBoxRule, PowCompRule, "$base^$exponent"];
parenClass ← MakeCompoundClass[$paren, paren, "( a )", LIST[aParenArg], LIST[leftParenSym, rightParenSym], ParenBoxRule, ParenCompRule, "( $a )"];
fractionClass ← MakeCompoundClass[$fraction, over, "a / b", LIST[numeratorArg, denominatorArg], LIST[lineSym], FractionBoxRule, FractionCompRule, "$numerator / $denominator"];
radicalClass ← MakeCompoundClass[$radical, radical, "radical", LIST[nArg, radicandArg], LIST[radRootSym, radLineSym], RadicalBoxRule, RadicalCompRule, "(root ($radicand) ($n))"];
register compound classes
binary ops
MathDB.InstallCompoundClass[sumClass];
MathDB.InstallCompoundClass[differenceClass];
MathDB.InstallCompoundClass[andClass];
MathDB.InstallCompoundClass[orClass];
unary ops
MathDB.InstallCompoundClass[notClass];
MathDB.InstallCompoundClass[negationClass];
others
MathDB.InstallCompoundClass[powClass];
MathDB.InstallCompoundClass[parenClass];
MathDB.InstallCompoundClass[complexClass];
MathDB.InstallCompoundClass[productClass];
MathDB.InstallCompoundClass[summationClass];
MathDB.InstallCompoundClass[integrationClass];
MathDB.InstallCompoundClass[fractionClass];
MathDB.InstallCompoundClass[radicalClass];
relations
MathDB.InstallCompoundClass[eqFormulaClass];
MathDB.InstallCompoundClass[ltFormulaClass];
MathDB.InstallCompoundClass[leFormulaClass];
MathDB.InstallCompoundClass[gtFormulaClass];
MathDB.InstallCompoundClass[geFormulaClass];
};