-- NPGSParseTable.mesa
-- an NPGS production from NPGSScan.mesa, May 24, 1990 1:52:14 pm PDT

NPGSParseTable: CEDAR DEFINITIONS = {

  Symbol: TYPE = CARDINAL[0..255];
  TSymbol: TYPE = Symbol[0..19];
  NTSymbol: TYPE = Symbol[0..13];

-- Token indices for the scanner and parser
  tokenID: TSymbol =  1;
  tokenNUM: TSymbol =  2;
  tokenQUERY: TSymbol =  3;
  tokenTAB3: TSymbol =  9;
  tokenTAB4: TSymbol = 10;
  initialSymbol: TSymbol =  3;

  defaultMarker: TSymbol = TSymbol.FIRST;
  endMarker: TSymbol = TSymbol.LAST;

  HashIndex: TYPE = CARDINAL[0..29];
  VIndex: TYPE = CARDINAL[0..106];


  VocabHashEntry: TYPE = RECORD [
    symbol: TSymbol,    -- symbol index
    link: HashIndex];    -- link to next entry

  State: TYPE = CARDINAL[0..26];
  NTState: TYPE = State[0..6];
  TIndex: TYPE = CARDINAL[0..64];
  NTIndex: TYPE = CARDINAL[0..3];
  Production: TYPE = CARDINAL[0..37];
  Rule: TYPE = CARDINAL[0..28];

  ActionTag: TYPE = RECORD [
    reduce: BOOL,        -- TRUE iff reduce entry
    pLength: [0..15]];     -- number of symbols in production rhs

  ActionEntry: TYPE = RECORD [
    tag: ActionTag,          -- [FALSE,0] if a shift entry
    transition: [0..2047]];   -- production number / next state

  ProductionInfo: TYPE = RECORD [
    rule: Rule,        -- reduction rule
    lhs: NTSymbol]; -- production lhs symbol

  ScanTable: TYPE = ARRAY CHAR['\040..'\177] OF TSymbol;
  HashTable: TYPE = ARRAY HashIndex OF VocabHashEntry;
  IndexTable: TYPE = ARRAY TSymbol OF CARDINAL;
  Vocabulary: TYPE = TEXT;
  ProdData: TYPE = ARRAY Production OF ProductionInfo;
  NStarts: TYPE = ARRAY NTState OF NTIndex;
  NLengths: TYPE = ARRAY NTState OF CARDINAL;
  NSymbols: TYPE = ARRAY NTIndex OF NTSymbol;
  NActions: TYPE = ARRAY NTIndex OF ActionEntry;
  NTDefaults: TYPE = ARRAY NTSymbol OF ActionEntry;
  TStarts: TYPE = ARRAY State OF TIndex;
  TLengths: TYPE = ARRAY State OF CARDINAL;
  TSymbols: TYPE = ARRAY TIndex OF TSymbol;
  TActions: TYPE = ARRAY TIndex OF ActionEntry;

  initialState: State = 1;
  finalState: State = 0;

  ScanTableRef: TYPE = REF ScanTable;
  InitScanTable: PROC RETURNS [ScanTableRef];

  HashTableRef: TYPE = REF HashTable;
  InitHashTable: PROC RETURNS [HashTableRef];

  IndexTableRef: TYPE = REF IndexTable;
  InitIndexTable: PROC RETURNS [IndexTableRef];

  VocabularyRef: TYPE = REF Vocabulary;
  InitVocabulary: PROC RETURNS [VocabularyRef];

  ProdDataRef: TYPE = REF ProdData;
  InitProdData: PROC RETURNS [ProdDataRef];

  NStartsRef: TYPE = REF NStarts;
  InitNStarts: PROC RETURNS [NStartsRef];

  NLengthsRef: TYPE = REF NLengths;
  InitNLengths: PROC RETURNS [NLengthsRef];

  NSymbolsRef: TYPE = REF NSymbols;
  InitNSymbols: PROC RETURNS [NSymbolsRef];

  NActionsRef: TYPE = REF NActions;
  InitNActions: PROC RETURNS [NActionsRef];

  NTDefaultsRef: TYPE = REF NTDefaults;
  InitNTDefaults: PROC RETURNS [NTDefaultsRef];

  TStartsRef: TYPE = REF TStarts;
  InitTStarts: PROC RETURNS [TStartsRef];

  TLengthsRef: TYPE = REF TLengths;
  InitTLengths: PROC RETURNS [TLengthsRef];

  TSymbolsRef: TYPE = REF TSymbols;
  InitTSymbols: PROC RETURNS [TSymbolsRef];

  TActionsRef: TYPE = REF TActions;
  InitTActions: PROC RETURNS [TActionsRef];


}.