-- NPGSParseTableImpl.mesa
  -- an NPGS production from NPGSScan.mesa, December 10, 1992 11:00:30 pm PST.

DIRECTORY NPGSParseTable;

NPGSParseTableImpl: CEDAR PROGRAM
  EXPORTS NPGSParseTable
  = { OPEN NPGSParseTable;

InitScanTable: PUBLIC PROC RETURNS [ScanTableRef] = {
  tab: ScanTableRef ← NEW[ScanTable ← ALL[0]];
    -- 94 entries
  tab[77C] ← 3;
  tab[174C] ← 4;
  RETURN [tab];
  };

InitHashTable: PUBLIC PROC RETURNS [HashTableRef] = {
  null: VocabHashEntry = [0, 0];
  tab: HashTableRef ← NEW[HashTable ← ALL[null]];
    -- 30 entries
  tab[4] ← [5, 0];
  tab[11] ← [1, 0];
  tab[15] ← [2, 0];
  tab[17] ← [18, 0];
  tab[18] ← [17, 0];
  tab[19] ← [16, 0];
  tab[20] ← [15, 18];
  tab[21] ← [14, 20];
  tab[22] ← [6, 29];
  tab[23] ← [8, 0];
  tab[24] ← [9, 0];
  tab[25] ← [10, 0];
  tab[26] ← [13, 21];
  tab[27] ← [12, 26];
  tab[28] ← [11, 19];
  tab[29] ← [7, 27];
  RETURN [tab];
  };

InitIndexTable: PUBLIC PROC RETURNS [IndexTableRef] = {
  tab: IndexTableRef ← NEW[IndexTable ← [
    -- 20 entries
    0, 6, 9, 10, 11, 14, 15, 23, 31, 39,
    -- 10
    47, 54, 61, 68, 77, 88, 95, 100, 104, 107]];
  RETURN [tab];
  };

InitVocabulary: PUBLIC PROC RETURNS [VocabularyRef] = {
  i: CARDINAL ← 0;
  appText: PROC [r: REF TEXT] = {
      FOR k: NAT IN [0..r.length) DO tab[i+k] ← r[k]; ENDLOOP;
      i ← i + r.length;
      };
  tab: VocabularyRef ← NEW[Vocabulary[107]];
  -- 107 chars
  -- 0
  appText["symbolnum?|::=C||TABLE1||TABLE2||TABLE3||TABLE4||I"];
  -- 50
  appText["NPUT||CHAIN||LISTS||PRINTLR||PRINTLALR||FIRST||IDS"];
  -- 100
  appText["GOALeof"];
  tab.length ← i;
  RETURN [tab];
  };

InitProdData: PUBLIC PROC RETURNS [ProdDataRef] = {
  i: CARDINAL ← 1;
  lag: ProductionInfo ← [0, 0];
  dup: PROC = {tab[i] ← lag; i ← i + 1};
  appR: PROC [r: CARDINAL] = {lag.rule ← r; tab[i] ← lag; i ← i + 1};
  appL: PROC [lhs: CARDINAL] = {lag.lhs ← lhs; tab[i] ← lag; i ← i + 1};
  appRL: PROC [r, lhs: CARDINAL] = {tab[i] ← lag ← [r, lhs]; i ← i + 1};
  tab: ProdDataRef ← NEW[ProdData ← ALL[lag]];
    -- 38 entries
  appL[2]; appRL[1, 3]; dup[]; appRL[2, 5];
  -- 5
  appR[28]; appRL[3, 9]; appR[4]; appR[5]; appR[6];
  -- 10
  appR[7]; appR[8]; appR[9]; appRL[10, 6]; appR[11];
  -- 15
  appL[7]; appR[12]; appRL[13, 8]; appR[14]; appRL[15, 10];
  -- 20
  appR[28]; dup[]; appRL[16, 11]; appR[17]; appR[18];
  -- 25
  appR[19]; appR[20]; appR[21]; appR[22]; appRL[23, 12];
  -- 30
  appR[24]; dup[]; appR[25]; appR[26]; appR[27];
  -- 35
  appRL[28, 4]; dup[]; appL[13];  RETURN [tab];
  };

InitNStarts: PUBLIC PROC RETURNS [NStartsRef] = {
  tab: NStartsRef ← NEW[NStarts ← [
    -- 7 entries
    0, 0, 3, 0, 2, 1, 0]];
  RETURN [tab];
  };

InitNLengths: PUBLIC PROC RETURNS [NLengthsRef] = {
  tab: NLengthsRef ← NEW[NLengths ← [
    -- 7 entries
    0, 0, 1, 1, 1, 1, 1]];
  RETURN [tab];
  };

InitNSymbols: PUBLIC PROC RETURNS [NSymbolsRef] = {
  tab: NSymbolsRef ← NEW[NSymbols ← [
    -- 4 entries
    12, 11, 10, 10]];
  RETURN [tab];
  };

InitNActions: PUBLIC PROC RETURNS [NActionsRef] = {
  i: CARDINAL ← 0;
  dup: PROC = {tab[i] ← tab[i-1]; i ← i + 1};
  app0: PROC [transition: CARDINAL] = {
      tab[i] ← [[FALSE, 0], transition];
      i ← i + 1;
      };
  app1: PROC [pLength: CARDINAL, transition: CARDINAL] = {
      tab[i] ← [[FALSE, pLength], transition];
      i ← i + 1;
      };
  app1t: PROC [transition: CARDINAL] = {
      tab[i] ← [[FALSE, 1], transition];
      i ← i + 1;
      };
  app2: PROC [pLength: CARDINAL, transition: CARDINAL] = {
      tab[i] ← [[TRUE, pLength], transition];
      i ← i + 1;
      };
  null: ActionEntry ← [[FALSE, 0], 0];
  tab: NActionsRef ← NEW[NActions ← ALL[null]];
    -- 4 entries

  -- 0
  app0[17];  app0[3];  app0[21];  app0[25];
  RETURN [tab];
  };

InitNTDefaults: PUBLIC PROC RETURNS [NTDefaultsRef] = {
  i: CARDINAL ← 2;
  dup: PROC = {tab[i] ← tab[i-1]; i ← i + 1};
  app0: PROC [transition: CARDINAL] = {
      tab[i] ← [[FALSE, 0], transition];
      i ← i + 1;
      };
  app1: PROC [pLength: CARDINAL, transition: CARDINAL] = {
      tab[i] ← [[FALSE, pLength], transition];
      i ← i + 1;
      };
  app1t: PROC [transition: CARDINAL] = {
      tab[i] ← [[FALSE, 1], transition];
      i ← i + 1;
      };
  app2: PROC [pLength: CARDINAL, transition: CARDINAL] = {
      tab[i] ← [[TRUE, pLength], transition];
      i ← i + 1;
      };
  null: ActionEntry ← [[FALSE, 0], 0];
  tab: NTDefaultsRef ← NEW[NTDefaults ← ALL[null]];
    -- 14 entries

  i ← i + 1;  app0[19];  app1[3, 1];
  app0[13];  app0[4];  app0[2];  app0[24];  app1[2, 5];
  app0[9];  app0[6];  app0[11];  app0[5];
  RETURN [tab];
  };

InitTStarts: PUBLIC PROC RETURNS [TStartsRef] = {
  tab: TStartsRef ← NEW[TStarts ← [
    -- 27 entries
    0, 0, 53, 47, 35, 31, 24, 19, 22, 23,
    -- 10
    16, 30, 15, 7, 39, 40, 42, 44, 46, 2,
    -- 20
    1, 58, 59, 60, 61, 63, 64]];
  RETURN [tab];
  };

InitTLengths: PUBLIC PROC RETURNS [TLengthsRef] = {
  tab: TLengthsRef ← NEW[TLengths ← [
    -- 27 entries
    0, 1, 5, 6, 4, 4, 6, 3, 1, 1,
    -- 10
    3, 1, 1, 8, 1, 2, 2, 2, 1, 5,
    -- 20
    1, 1, 1, 1, 2, 1, 1]];
  RETURN [tab];
  };

InitTSymbols: PUBLIC PROC RETURNS [TSymbolsRef] = {
  tab: TSymbolsRef ← NEW[TSymbols ← [
    -- 65 entries
    3, 0, 1, 2, 3, 18, 0, 7, 11, 12,
    -- 10
    13, 14, 15, 16, 17, 5, 2, 6, 0, 2,
    -- 20
    6, 0, 5, 6, 1, 2, 3, 4, 6, 0,
    -- 30
    1, 1, 2, 3, 0, 2, 3, 8, 0, 1,
    -- 40
    2, 0, 5, 0, 1, 4, 5, 1, 2, 3,
    -- 50
    4, 19, 0, 2, 3, 9, 10, 0, 1, 1,
    -- 60
    5, 1, 10, 1, 1]];
  RETURN [tab];
  };

InitTActions: PUBLIC PROC RETURNS [TActionsRef] = {
  i: CARDINAL ← 0;
  dup: PROC = {tab[i] ← tab[i-1]; i ← i + 1};
  app0: PROC [transition: CARDINAL] = {
      tab[i] ← [[FALSE, 0], transition];
      i ← i + 1;
      };
  app1: PROC [pLength: CARDINAL, transition: CARDINAL] = {
      tab[i] ← [[FALSE, pLength], transition];
      i ← i + 1;
      };
  app1t: PROC [transition: CARDINAL] = {
      tab[i] ← [[FALSE, 1], transition];
      i ← i + 1;
      };
  app2: PROC [pLength: CARDINAL, transition: CARDINAL] = {
      tab[i] ← [[TRUE, pLength], transition];
      i ← i + 1;
      };
  null: ActionEntry ← [[FALSE, 0], 0];
  tab: TActionsRef ← NEW[TActions ← ALL[null]];
    -- 65 entries

  -- 0
  app0[20];  app2[0, 4];  app0[12];  app0[10];  app0[7];
  app0[8];  app2[0, 19];  app1t[13];  app1t[6];  app1t[7];
  app1t[8];  app1t[9];  app1t[10];  app1t[11];  app1t[12];
  app1[2, 22];  app1[2, 30];  app2[1, 20];  app2[1, 29];  app1[2, 31];
  -- 20
  app2[1, 21];  app2[1, 34];  app0[14];  app0[15];  app0[16];
  app0[10];  app0[7];  app1[2, 26];  app2[0, 19];  app2[3, 1];
  app0[18];  app0[12];  app0[10];  app0[7];  app2[0, 19];
  app1t[20];  app1t[21];  app1t[16];  app2[0, 19];  app0[22];
  -- 40
  app1[3, 33];  app2[2, 32];  app1[3, 24];  app2[2, 28];  app0[23];
  app1[3, 27];  app1[3, 23];  app0[16];  app0[10];  app0[7];
  app1[2, 26];  app2[2, 36];  app2[0, 19];  app1t[20];  app1t[21];
  app1t[17];  app1[4, 2];  app2[0, 19];  app1[3, 14];  app1[4, 37];
  -- 60
  app1[4, 25];  app0[26];  app1[5, 3];  app1[3, 15];  app1[3, 18];
  RETURN [tab];
  };

}.