Parse:
PROC [context:
REF
ANY, GetToken: TokenProc]
RETURNS [ans: Arg];
TokenProc:
TYPE =
PROC [context:
REF
ANY, expectingArg:
BOOLEAN]
RETURNS [token: Token];
Reducer: TYPE = PROC [sr: SourceRange, context: REF ANY, ops: TokenList, args: ArgList] RETURNS [reduced: REF ANY];
Arg: TYPE = RECORD [sr: SourceRange, arg: REF ANY];
Token: TYPE = RECORD [sr: SourceRange, 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 ← [nullSR, NIL, NIL]
];
end: Token;
argClass: TokenClass;
SourceRange: TYPE = RECORD [first, last: INT] ← nullSR;
nullSR: SourceRange = [-1, -1];
TokenList: TYPE = LIST OF Token;
ArgList: TYPE = LIST OF Arg;
CantReduce: SIGNAL [ops: TokenList, args: ArgList] RETURNS [use: REF ANY];
CantFix: SIGNAL [token: Token] RETURNS [fix: Token];
DoesntFix: ERROR [token: Token, expectingArg, willGetArg: BOOLEAN];
TerminateErr: ERROR [argStack: ArgList, opStack: TokenList];
LastReduceErr: ERROR [args: ArgList, ops: TokenList];
InvalidToken: ERROR [token: Token];