Generating Tables
State: TYPE ~ CARD16;
SymbolProc: TYPE ~ PROC [ name: ROPE ];
UniqueTokenProc: TYPE ~ PROC [ name: ROPE, spelling: ROPE ];
GenericTokenProc: TYPE ~ PROC [ name: ROPE, class: ROPE ];
ShiftProc: TYPE ~ PROC [ state: State, terminalSeq: ROPE, newState: State ];
ReductionProc: TYPE ~ PROC [ state: State, terminalSeq: ROPE, leftSide: ROPE, ruleNumber: CARD16, ruleSize: CARD16 ];
AcceptanceProc: TYPE ~ PROC [ state: State, terminalSeq: ROPE ];
StartStateProc: TYPE ~ PROC [ state: State ];
LexicalAnalysisProc:
TYPE ~
PROC [ stream:
IO.
STREAM, flushComments:
BOOL ¬
TRUE ]
RETURNS [ tokenKind:
IO.TokenKind, token:
ROPE, charsSkipped:
INT32 ];
defaulting the LexicalAnalysisProc (NIL) should result in a reasonable value,
e.g. IO.GetCedarTokenRope
GenInfoProc: TYPE ~ PROC [ recordSymbol: SymbolProc, recordUniqueToken: UniqueTokenProc, recordGenericToken: GenericTokenProc, recordShift: ShiftProc, recordReduction: ReductionProc, recordAcceptance: AcceptanceProc, recordStartState: StartStateProc ];
RecordKipperedParserTableOnStream: PROC [ s: IO.STREAM, genInfo: GenInfoProc, getSourceToken: LexicalAnalysisProc ¬ NIL ];
RecordReadableParserTableOnStream: PROC [ s: IO.STREAM, genInfo: GenInfoProc, getSourceToken: LexicalAnalysisProc ¬ NIL ];
Parsing
ParserTable: TYPE ~ REF ParserTableBody;
ParserTableBody: TYPE;
BuildParserTableFromKipperedStream: PROC [ s: IO.STREAM,
getSourceToken: LexicalAnalysisProc ¬ NIL ] RETURNS [ table: ParserTable ];
BuildParserTableFromReadableStream: PROC [ s: IO.STREAM,
getSourceToken: LexicalAnalysisProc ¬ NIL ] RETURNS [ table: ParserTable ];
GetSourceTokenProc: TYPE ~ PROC
RETURNS [ tokenKind: IO.TokenKind, tokenText: ROPE, position: INT32 ];
ShowReduceProc: TYPE ~ PROC [ rule: CARD16, firstCharPosition: INT32, length: INT32 ];
ShowGenericShiftProc: TYPE ~ PROC [ code: CARD16, kind: IO.TokenKind, text: ROPE, firstCharPosition: INT32 ];
ShowNonGenericShiftProc: TYPE ~ PROC [ text: ROPE, firstCharPosition: INT32 ];
Parse: PROC [ table: ParserTable, getSourceToken: GetSourceTokenProc, showReduce: ShowReduceProc ¬ NIL, showGenericShift: ShowGenericShiftProc ¬ NIL, showNonGenericShift: ShowNonGenericShiftProc ¬ NIL ] RETURNS [ accepted: BOOL ];
GetReportStream:
SIGNAL
RETURNS [ s:
IO.
STREAM ];
generated by Parse in the event of an error.
Clients should return the stream on which to place error messages.
UnRecoverableSyntaxError:
ERROR;
what OneCasaba does as a last resort!
}.