<> <> <<>> <> <<>> DIRECTORY MathDisplayExpr, Rope; Parser: CEDAR DEFINITIONS = BEGIN <> ROPE: TYPE ~ Rope.ROPE; DisplayExpr: TYPE ~ MathDisplayExpr.DisplayExpr; <> LexType: TYPE ~ {ucAlpha, lcAlpha, digit, decimalPoint, leftBracket, backSpace, singleCharTemplate, templateDelimiter, symbolDelimiter, other}; -- categories for scanned characters ReplacementExprType: TYPE ~ {integer, real, variable, templateName, symbol, template, none}; -- categories of Exprs that be grafted into the parse (i.e. Expression) tree KbBuffer: TYPE ~ RECORD[type: ReplacementExprType _ none, data: ROPE, savedWrapArg: DisplayExpr _ NIL]; -- build a "string of characters" token ParseAction: TYPE ~ REF ParseActionRep; ReplaceAction: TYPE ~ replace ParseActionRep; BeginMultiCharTemplateAction: TYPE ~ beginMultiCharTemplate ParseActionRep; FinishMultiCharTemplateAction: TYPE ~ finishMultiCharTemplate ParseActionRep; WrapAction: TYPE ~ wrap ParseActionRep; UndoAction: TYPE ~ undo ParseActionRep; NoAction: TYPE ~ none ParseActionRep; ParseActionRep: TYPE ~ RECORD [ SELECT type:* FROM beginMultiCharTemplate => [ oldSelection: ATOM -- old selection flavor which contains expr to be wrapped ], finishMultiCharTemplate => [ class: ATOM -- class for template wrapper ], replace => [ oldSelection: ATOM, -- old selection flavor which contains expr to replace; expected to always be $primary (i.e. we're starting to build a KB selection), or $keyboard (i.e. we're appending to the current KB selection) replacementType: ReplacementExprType, -- new expression to be constructed fromRope: ROPE, -- data for construction newSelection: ATOM -- selection flavor to select as after replacement ], wrap => [ selection: ATOM, -- old selection flavor class: ATOM -- class for template wrapper ], undo => NULL, none => NULL -- nothing ENDCASE ]; <> ParseKBChar: PUBLIC PROC[c: CHAR, inBuffer: KbBuffer, primaryActive, keyboardActive: BOOL _ FALSE] RETURNS [outBuffer: KbBuffer, action: ParseAction _ NIL]; <> LexChar: PROC[c: CHAR] RETURNS[LexType]; <> ExpandAbbreviation: PROC [name: ROPE] RETURNS [ROPE]; <> END.