DEFINITION CRT; (* portable *)

 IMPORT Sets;

 CONST
  maxSymbols = 300;
  maxTerminals = 256;
  maxNt = 128;
  maxNodes = 1500;
  normTrans = 0; contextTrans = 1;
  t = 1; pr = 2; nt = 3; class = 4; char = 5; wt =  6; any = 7; eps = 8; sync = 9; sem = 10;
  alt = 11; iter = 12; opt = 13;
  noSym = -1;
  eofSy = 0;
  classToken = 0;
  litToken = 1;
  classLitToken = 2;

 TYPE
  Name = ARRAY 32 OF CHAR;
  Position = RECORD
   beg: LONGINT;
   len: LONGINT;
   col: INTEGER;
  END;

  SymbolNode = RECORD
   typ: INTEGER;
   name: Name;
   struct: INTEGER;
   deletable: BOOLEAN;
   attrPos: Position;
   semPos: Position;
   line: INTEGER;
  END;

  Set = ARRAY maxTerminals DIV Sets.size OF SET;
  GraphNode = RECORD
   typ: INTEGER;
   next: INTEGER;
   p1: INTEGER;
   p2: INTEGER;
   pos: Position;
   line: INTEGER;
  END;

  MarkList = ARRAY maxNodes DIV Sets.size OF SET;

 VAR 
  maxSet: INTEGER;
  maxT: INTEGER;
  maxP: INTEGER;
  firstNt: INTEGER;
  lastNt: INTEGER;
  maxC: INTEGER;
  semDeclPos: Position;
  importPos: Position;
  ignored: Set;
  ignoreCase: BOOLEAN;
  ddt: ARRAY 10 OF BOOLEAN;
  nNodes: INTEGER;
  root: INTEGER;
 PROCEDURE GetNode (gp: INTEGER; VAR n: GraphNode);
 PROCEDURE PutNode (gp: INTEGER; n: GraphNode);
 PROCEDURE DelGraph (gp: INTEGER): BOOLEAN;
 PROCEDURE NewSym (typ: INTEGER; name: Name; line: INTEGER): INTEGER;
 PROCEDURE GetSym (sp: INTEGER; VAR sn: SymbolNode);
 PROCEDURE PutSym (sp: INTEGER; sn: SymbolNode);
 PROCEDURE FindSym (name: Name): INTEGER;
 PROCEDURE NewSet (s: Set): INTEGER;
 PROCEDURE CompFirstSet (gp: INTEGER; VAR fs: Set);
 PROCEDURE CompExpected (gp, sp: INTEGER; VAR exp: Set);
 PROCEDURE CompDeletableSymbols;
 PROCEDURE CompSymbolSets;
 PROCEDURE GetSet (nr: INTEGER; VAR s: Set);
 PROCEDURE PrintSymbolTable;
 PROCEDURE NewClass (name: Name; set: Set): INTEGER;
 PROCEDURE ClassWithName (name: Name): INTEGER;
 PROCEDURE ClassWithSet (s: Set): INTEGER;
 PROCEDURE GetClass (n: INTEGER; VAR s: Set);
 PROCEDURE GetClassName (n: INTEGER; VAR name: Name);
 PROCEDURE XRef;
 PROCEDURE NewNode (typ, p1, line: INTEGER): INTEGER;
 PROCEDURE CompleteGraph (gp: INTEGER);
 PROCEDURE ConcatAlt (VAR gL1, gR1: INTEGER; gL2, gR2: INTEGER);
 PROCEDURE ConcatSeq (VAR gL1, gR1: INTEGER; gL2, gR2: INTEGER);
 PROCEDURE MakeFirstAlt (VAR gL, gR: INTEGER);
 PROCEDURE MakeIteration (VAR gL, gR: INTEGER);
 PROCEDURE MakeOption (VAR gL, gR: INTEGER);
 PROCEDURE StrToGraph (str: ARRAY OF CHAR; VAR gL, gR: INTEGER);
 PROCEDURE DelNode (gn: GraphNode): BOOLEAN;
 PROCEDURE PrintGraph;
 PROCEDURE FindCircularProductions (VAR ok: BOOLEAN);
 PROCEDURE LL1Test (VAR ll1: BOOLEAN);
 PROCEDURE TestCompleteness (VAR ok: BOOLEAN);
 PROCEDURE TestIfAllNtReached (VAR ok: BOOLEAN);
 PROCEDURE TestIfNtToTerm (VAR ok: BOOLEAN);
 PROCEDURE Init;

END CRT.