Parse:
PROC [context:
REF
ANY, GetToken: TokenProc]
RETURNS [ans:
REF
ANY];
TokenProc:
TYPE =
PROC [context:
REF
ANY, expectingArg:
BOOLEAN]
RETURNS [token: Token];
Reducer: TYPE = PROC [context: REF ANY, ops: TokenList, args: LORA] RETURNS [reduced: REF ANY];
Token: TYPE = RECORD [class: TokenClass, asArg: REF ANY ← NIL];
TokenClass: TYPE = REF TokenClassRep;
TokenClassRep:
TYPE =
RECORD [
leftPrec, rightPrec: CARDINAL ← 0, --0 = don't want, >1 = want.
Reduce: Reducer ← NIL,
leftFix: Token ← [NIL, NIL]
];
end: Token;
argClass: TokenClass;
TokenList: TYPE = LIST OF Token;
CantReduce: SIGNAL [ops: TokenList, args: LORA] RETURNS [use: REF ANY];
CantFix: SIGNAL [token: Token] RETURNS [fix: Token];
DoesntFix: ERROR [token: Token, expectingArg, willGetArg: BOOLEAN];
TerminateErr: ERROR [argStack: LORA, opStack: TokenList];
LastReduceErr: ERROR [args: LORA, ops: TokenList];
InvalidToken: ERROR [token: Token];