OneCasabaParser.Mesa (September 18, 1984 8:45:22 am PDT)
Copyright Ó 1984, 1985, 1986, 1987, 1988, 1989, 1992 by Xerox Corporation. All rights reserved.
Sturgis, April 8, 1986 4:25:19 pm PST
Hopcroft, May 30, 1989 5:06:01 pm PDT
Bill Jackson (bj) September 13, 1989 9:51:00 pm PDT
DIRECTORY
IO USING [ STREAM, TokenKind ],
Rope USING [ ROPE ];
OneCasabaParser: CEDAR DEFINITIONS ~ {
OPEN Rope;
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!
}.