Parser.mesa
Last Edited by: Arnon, June 10, 1985 4:19:22 pm PDT
Parse keystrokes. Note that the tip table (ViewExpr.Tip) also picks up certain keystrokes and has precedence over this parser.
DIRECTORY
MathDisplayExpr,
Rope;
Parser: CEDAR DEFINITIONS
= BEGIN
Type Abbreviations From Imported Interfaces
ROPE: TYPE ~ Rope.ROPE;
DisplayExpr: TYPE ~ MathDisplayExpr.DisplayExpr;
Types
LexType: TYPE ~ {ucAlpha, lcAlpha, digit, decimalPoint, backSpace, singleCharTemplate, templateDelimiter, symbolDelimiter, other};
TokenType: TYPE ~ {integer, real, variable, template, symbol, none};
KbBuffer: TYPE ~ RECORD[type: TokenType ← none, data: ROPE, savedWrapArg: DisplayExpr ← NIL];
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 => [
oldSelect: ATOM -- old selection flavor which contains expr to be wrapped
],
finishMultiCharTemplate => [
class: ATOM -- class for template wrapper
],
replace => [
oldSelect: ATOM, -- old selection flavor which contains expr to replace
construct: TokenType, -- new expression to be constructed
fromRope: ROPE, -- data for construction
newSelect: 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
];
Ops
LexChar: PROC[c: CHAR] RETURNS[LexType];
ParseKBChar: PUBLIC PROC[c: CHAR, inBuffer: KbBuffer, primaryActive, keyboardActive: BOOLFALSE] RETURNS [outBuffer: KbBuffer, action: ParseAction ← NIL];
END.