-- file BcdParseTable.mesa
-- created by PGS from BcdTreeBuild.mesa, 10-Jan-83 14:22

ParseTable: DEFINITIONS = {

  Symbol: TYPE = [0..255];
  TSymbol: TYPE = Symbol[0.. 30];
  NTSymbol: TYPE = Symbol[0.. 26];

-- token indices for the scanner and parser
  tokenID: TSymbol =  1;
  tokenSTR: TSymbol =  2;
  initialSymbol: TSymbol = 13;

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

  HashIndex: TYPE = [0.. 45];
  VIndex: TYPE = [0..108];

  VocabHashEntry: TYPE = MACHINE DEPENDENT RECORD [
    symbol(0: 0..7): TSymbol,	-- symbol index
    link(0: 8..15): HashIndex];	-- link to next entry

  State: TYPE = [0.. 67];
  NTState: TYPE = State[0.. 23];
  TIndex: TYPE = [0.. 90];
  NTIndex: TYPE = [0.. 23];
  Production: TYPE = [0.. 53];

  ActionTag: TYPE = MACHINE DEPENDENT RECORD [
    reduce(0: 0..0): BOOL,   	-- TRUE iff reduce entry
    pLength(0: 1..4): [0..15]];	-- number of symbols in production rhs
  ActionEntry: TYPE = MACHINE DEPENDENT RECORD [
    tag(0: 0..4): ActionTag,		-- [FALSE,0] if a shift entry
    transition(0: 5..15): [0..2047]];	-- production number / next state

  ProductionInfo: TYPE = MACHINE DEPENDENT RECORD [
    rule(0: 0..7): [0..256),		-- reduction rule
    lhs(0: 8..15): 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 = MACHINE DEPENDENT RECORD [
    length(0), maxlength(1): CARDINAL,
    text(2): PACKED ARRAY VIndex OF CHAR];
  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;

  Table: TYPE = MACHINE DEPENDENT RECORD [
    scanTable: RECORD [
      scanTab:    TableRef RELATIVE POINTER TO ScanTable,
      hashTab:    TableRef RELATIVE POINTER TO HashTable,
      vocabIndex: TableRef RELATIVE POINTER TO IndexTable,
      vocabBody:  TableRef RELATIVE POINTER TO Vocabulary],
    parseTable: RECORD [
      prodData:   TableRef RELATIVE POINTER TO ProdData,
      nStart:     TableRef RELATIVE POINTER TO NStarts,
      nLength:    TableRef RELATIVE POINTER TO NLengths,
      nSymbol:    TableRef RELATIVE POINTER TO NSymbols,
      nAction:    TableRef RELATIVE POINTER TO NActions,
      ntDefaults: TableRef RELATIVE POINTER TO NTDefaults,
      tStart:     TableRef RELATIVE POINTER TO TStarts,
      tLength:    TableRef RELATIVE POINTER TO TLengths,
      tSymbol:    TableRef RELATIVE POINTER TO TSymbols,
      tAction:    TableRef RELATIVE POINTER TO TActions]];

  TableRef: TYPE = LONG BASE POINTER TO Table;
  ScanTableRef: TYPE = LONG POINTER TO ScanTable;
  HashTableRef: TYPE = LONG POINTER TO HashTable;
  IndexTableRef: TYPE = LONG POINTER TO IndexTable;
  VocabularyRef: TYPE = LONG POINTER TO Vocabulary;
  ProdDataRef: TYPE = LONG POINTER TO ProdData;
  NStartsRef: TYPE = LONG POINTER TO NStarts;
  NLengthsRef: TYPE = LONG POINTER TO NLengths;
  NSymbolsRef: TYPE = LONG POINTER TO NSymbols;
  NActionsRef: TYPE = LONG POINTER TO NActions;
  NTDefaultsRef: TYPE = LONG POINTER TO NTDefaults;
  TStartsRef: TYPE = LONG POINTER TO TStarts;
  TLengthsRef: TYPE = LONG POINTER TO TLengths;
  TSymbolsRef: TYPE = LONG POINTER TO TSymbols;
  TActionsRef: TYPE = LONG POINTER TO TActions;

  }.