
    <<SMP1.Mesa>>
        <<Copyright © 1985 by Xerox Corporation.  All rights reserved.>>
        <<Satterthwaite, April 15, 1986 12:08:41 pm PST>>
    <<>>
    DIRECTORY
        IO: TYPE USING [STREAM],
        Rope: TYPE USING [ROPE],
        SMCommentTable: TYPE USING [Index],
        SMOps: TYPE USING [MS],
        SMParseTable: TYPE ParseTable USING [ActionEntry, ProdDataRef, State, TableRef, TSymbol];

    P1: CEDAR DEFINITIONS ~ {
        OPEN ParseTable~~SMParseTable;

        Index: TYPE ~ SMCommentTable.Index;

    <<ref types>>

        ValueStack: TYPE ~ REF  ValueSeq;
        StateStack: TYPE ~ REF StateSeq;
        LinkStack: TYPE ~ REF LinkSeq;
        ActionStack: TYPE ~ REF ActionSeq;

    <<record structures (LONG or REF does not occur past this point)>>

        TValue: TYPE ~ REF ANY;    -- tree value (usually)

        Value: TYPE ~ RECORD[        -- type of the value stack
            n: NAT_0,            -- scalars only
            t: TValue_NIL];

        ValueSeq: TYPE ~ RECORD[SEQUENCE length: NAT OF P1.Value];

        nullTValue: TValue ~ NIL;
        nullValue: P1.Value ~ [];
        nullId: P1.Value ~ nullValue;

        StateSeq: TYPE ~ RECORD[SEQUENCE length: NAT OF ParseTable.State];
        LinkSeq: TYPE ~ RECORD[SEQUENCE length: NAT OF CARDINAL];   -- links to source text
        ActionSeq: TYPE ~ RECORD[SEQUENCE length: NAT OF ParseTable.ActionEntry];


        Token: TYPE ~ RECORD[
            class: ParseTable.TSymbol,    -- the token class
            value: TValue,
            index: CARDINAL];        -- source line index

    <<implemented by Scanner>>
        ErrorContext: PROC[message: Rope.ROPE, tokenIndex: Index];
        InstallScanTable: PROC[ParseTable.TableRef];
        NextToken: PROC RETURNS[Token];
        ResetScanIndex: PROC[Index] RETURNS[success: BOOL];
        ScanInit: PROC[model: SMOps.MS, source: IO.STREAM];
        ScanReset: PROC RETURNS[nTokens, nErrors: CARDINAL];

    <<implemented by Parser>>
        InputLoc: PROC RETURNS[Index];
        InstallParseTable: PROC[ParseTable.TableRef];
        Parse: UNSAFE PROC[model: SMOps.MS, source: IO.STREAM, prefixOk: BOOL_FALSE]
            RETURNS[complete: BOOL, nTokens, nErrors: CARDINAL];

    <<implemented by tree builder>>

        AssignDescriptors: PROC[
            qd: ActionStack, vd: ValueStack, ld: LinkStack,
            pp: ParseTable.ProdDataRef,
            model: SMOps.MS];
        ProcessQueue: PROC[qI, top: CARDINAL];
        TokenValue: PROC[ParseTable.TSymbol] RETURNS[TValue];

        }.

