-- OneCasabaParser.mesa
-- last edit September 18, 1984 8:45:22 am PDT
-- Sturgis, April 8, 1986 4:25:19 pm PST
DIRECTORY
IO USING[STREAM, TokenKind],
Rope USING[ROPE];
OneCasabaParser: CEDAR DEFINITIONS =
BEGIN OPEN IO, Rope;
-- following types and procedures are used when generating parser tables
State: TYPE = CARDINAL;
RecordKipperedParserTableOnStream: PROC[s: STREAM,
genInfo: PROC[
recordSymbol: PROC[name: ROPE],
recordUniqueToken: PROC[name: ROPE, spelling: ROPE],
recordGenericToken: PROC[name: ROPE, class: ROPE],
recordShift: PROC[state: State, terminalSeq: ROPE, newState: State],
recordReduction: PROC[state: State, terminalSeq: ROPE, leftSide: ROPE, ruleNumber: CARDINAL, ruleSize: CARDINAL],
recordAcceptance: PROC[state: State, terminalSeq: ROPE],
recordStartState: PROC[state: State]]];
RecordReadableParserTableOnStream: PROC[s: STREAM,
genInfo: PROC[
recordSymbol: PROC[name: ROPE],
recordUniqueToken: PROC[name: ROPE, spelling: ROPE],
recordGenericToken: PROC[name: ROPE, class: ROPE],
recordShift: PROC[state: State, terminalSeq: ROPE, newState: State],
recordReduction: PROC[state: State, terminalSeq: ROPE, leftSide: ROPE, ruleNumber: CARDINAL, ruleSize: CARDINAL],
recordAcceptance: PROC[state: State, terminalSeq: ROPE],
recordStartState: PROC[state: State]]];
-- following types and procedures are used when parsing
ParserTable: TYPE = REF ParserTableBody;
ParserTableBody: TYPE;
BuildParserTableFromKipperedStream: PROC[STREAM] RETURNS[ParserTable];
BuildParserTableFromReadableStream: PROC[STREAM] RETURNS[ParserTable];
GetReportStream: SIGNAL RETURNS[IO.STREAM]; -- generated by Parse in the event of an error. Client of Parse should be prepared to return a stream on which the parser can place error messages.
Parse: PROC[
 table: ParserTable,
 getSourceToken: PROC RETURNS[tokenKind: TokenKind, tokenText: ROPE, position: INT],
 showReduce: PROC[rule: CARDINAL, firstCharPosition: INT, length: INT] ← NIL,
 showGenericShift: PROC[code: CARDINAL, kind: TokenKind, text: ROPE, firstCharPosition: INT] ← NIL,
 showNonGenericShift: PROC[text: ROPE, firstCharPosition: INT] ← NIL]
RETURNS[accepted: BOOLEAN];
END..