-- file ModelParseDefs.Mesa
-- Pilot 6.0/ Mesa 7.0
-- last modified by Satterthwaite, January 3, 1983 3:08 pm
-- last modified by Schmidt,  2-May-81 13:33:18

DIRECTORY
  ModelParseTable: TYPE USING [ActionEntry, ProdDataRef, State, TableRef, TSymbol],
  Stream: TYPE USING [Handle];

P1: DEFINITIONS={
  OPEN ModelParseTable;

 -- pointer types
 
  ValueStack: TYPE~LONG POINTER TO  P1.ValueSeq;
  StateStack: TYPE~LONG POINTER TO StateSeq;
  LinkStack: TYPE~LONG POINTER TO LinkSeq;
  ActionStack: TYPE~LONG POINTER TO ActionSeq;
  
 -- record structures (LONG does not occur past this point)
  
  Value: TYPE~RECORD [	-- type of the value stack
    SELECT OVERLAID * FROM
      scalar => [s: LONG UNSPECIFIED],
      ref => [r: LONG UNSPECIFIED]
      ENDCASE];

  nullValue: P1.Value~[scalar[0]];
  nullId: P1.Value~[ref[0]];

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

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


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

 -- implemented by scanner
  Atom: PROC RETURNS [Token];
  ErrorContext: PROC [to: Stream.Handle, message: LONG STRING, tokenIndex: CARDINAL];
  ResetScanIndex: PROC [CARDINAL] RETURNS [success: BOOL];
  ScanInit: PROC [table: TableRef];
  ScanReset: PROC RETURNS [nTokens, nErrors: CARDINAL];
  GuaranteeScannerCleanedUp: PROC;
  
 -- implemented by parser
  InvokeParser: PROC RETURNS [complete: BOOL, nTokens, nErrors: CARDINAL];
  ParserID: PROC RETURNS [LONG STRING];
  InputLoc: PROC RETURNS [CARDINAL];

 -- implemented by interpreter (MDRulesImpl.mesa)

  AssignDescriptors: PROC [
    qd: P1.ActionStack, vd: P1.ValueStack, ld: P1.LinkStack, pp: ProdDataRef];
  ProcessQueue: PROC [qI, top: CARDINAL];
  TokenValue: PROC [TSymbol] RETURNS [P1.Value];

 -- the global frames
  ModelScannerImpl, ModelParserImpl, MDRulesImpl: PROGRAM;

 -- to hide need for CompilerUtil, implemented in MDParseImpl
  StreamId: TYPE = MACHINE DEPENDENT {source, object, log, (255)};
  AcquireStream: PROC [StreamId] RETURNS [Stream.Handle];
  ReleaseStream: PROC [StreamId];

  TableId: TYPE = MACHINE DEPENDENT {parse, error, debug, (255)};
  AcquireTable: PROC [TableId] RETURNS [LONG POINTER];
  ReleaseTable: PROC [TableId];

  }.