home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / XREF3B.ZIP / XREF3B.PAS
Encoding:
Pascal/Delphi Source File  |  1985-12-28  |  24.6 KB  |  726 lines

  1. {$C-,I-,V-,R-,K-}
  2. {++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  3. {+                                                      +}
  4. {+  PROGRAM TITLE:      Cross Reference Generator       +}
  5. {+                                                      +}
  6. {+  WRITTEN BY:         Peter Grogono                   +}
  7. {+  DATE WRITTEN:       1978                            +}
  8. {+                                                      +}
  9. {+  SUMMARY:                                            +}
  10. {+      1. Output Files:                                +}
  11. {+         a. first output file is a numbered listing   +}
  12. {+            of the input source                       +}
  13. {+         b. second output file is cross reference     +}
  14. {+            with each identifier followed by the      +}
  15. {+            line numbers on which it appears.         +}
  16. {+      2. Listing Device:                              +}
  17. {+         The numbered source listing may optionally   +}
  18. {+         be routed to the screen or printer (but not  +}
  19. {+         both).                                       +}
  20. {+                                                      +}
  21. {+  MODIFICATION RECORD:                                +}
  22. {+      19-MAR-85       -Modified for full Turbo Pascal +}
  23. {+                       Ver2.0B command set            +}
  24. {+                       by David W. Carroll 76011,616  +}
  25. {+                                                      +}
  26. {+      17-APR-84       -Modified for Turbo Pascal so   +}
  27. {+                       $ includes are supported       +}
  28. {+                                                      +}
  29. {+                                                      +}
  30. {++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  31. program xrefg2;
  32. { Cross Reference Generator }
  33. const
  34.         alfa_length     =  15;
  35.         dflt_str_len    = 255;
  36.         entrygap        =    0;   { # of blank lines between line numbers}
  37.         heading         : string[23] = 'Cross-Reference Listing';
  38.         headingsize     =    3;   {number of lines for heading}
  39.         llmax           = dflt_str_len;
  40.         maxonline       =   8;
  41.         maxlines        = maxint; {longest document permitted}
  42.         maxwordlen      = alfa_length;{longest word read without truncation}
  43.         maxlinelen      =   80;   {length of output line}
  44.         maxonpage       =   60;   {size of output page}
  45.         numkeys         =   184;   {number of Pascal reseved words}
  46.                                   {Read your Pascal manuals on this one!}
  47.         numberwidth     =    6;
  48.         space           : char = ' ';
  49. type
  50.         alfa    = string[alfa_length];
  51.         charname = (lletter, uletter, digit, blank, quote, atab,
  52.                       endofline, filemark, otherchar );
  53.         charinfo = record
  54.                      name : charname;
  55.                      valu : char
  56.                    end;
  57.         counter = 1..maxlines;
  58.         pageindex = byte;
  59.         wordindex = 1..maxwordlen;
  60.         queuepointer = ^queueitem;
  61.         queueitem = record
  62.                         linenumber : counter;
  63.                         nextinqueue: queuepointer
  64.                     end;
  65.         entrytype = record
  66.                         wordvalue : alfa;
  67.                         firstinqueue,
  68.                         lastinqueue: queuepointer
  69.                      end;
  70.         treepointer = ^node;
  71.         node = record
  72.                  entry : entrytype;
  73.                  left,
  74.                  right : treepointer
  75.                end;
  76.         genstr  = string[255];
  77. var
  78.   bell          : char;
  79.   fatal_error   : boolean;
  80.   file_id,                      { Input file name }
  81.   prn_id,                       { basic file name + '.PRN' }
  82.   new_id        : string[20];   { basic file name + '.XRF' }
  83.   form_feed     : char;
  84.   key           : array[1..numkeys] of alfa;
  85.   listing       : boolean;
  86.   tab           : char;
  87.   wordtree      : treepointer;
  88.   gap           : char      ;
  89.   currentline: integer;
  90.   fout: text; { print output file }
  91.   xout: text; { xref  output file }
  92.  
  93.  
  94. procedure page(var fx: text);
  95. begin
  96.   writeln(fx);
  97.   write(fx, form_feed);
  98. end;
  99.  
  100. { FUNCTYPE:                                                        }
  101. { Do binary search for keyword in 'key' list.  If found, return    }
  102. { TRUE, else FALSE.                                                }
  103. function find_in_reserve(var kword: alfa) : boolean;
  104. label return;
  105. var
  106.     low, high, mid : integer;
  107. begin
  108.     low  := 1;
  109.     high := numkeys;
  110.     while (low <= high) do begin
  111.         mid := (low+high) div 2;
  112.         if kword < key[mid] then
  113.             high := mid - 1
  114.         else if kword > key[mid] then
  115.             low  := mid + 1
  116.         else begin
  117.             find_in_reserve := true;
  118.             goto return;
  119.             end;
  120.         end;
  121.     find_in_reserve := false;
  122. return:
  123. end;
  124.  
  125. procedure buildtree(var tree: treepointer; var infile: genstr);
  126. var
  127.   currentword : alfa;
  128.   fin : text; { local input file }
  129.   currchar,                     { Current operative character }
  130.   nextchar      : charinfo;     { Look-ahead character }
  131.   flushing      : (knot, dbl, std, lit, scanfn, scanfn2);
  132.   fname         : string[30];
  133.   doinclude     : boolean; { TRUE if we discovered include file }
  134.   fbuffer       : string[255];  { Format buffer - before final Print }
  135.   linein        : string[255];
  136.   lineinlast    : string[255];
  137.   cp            : 0..255;
  138.   xeof,                 { EOF status AFTER a read }
  139.   xeoln         : boolean;      { EOLN status after a read }
  140.  
  141.    procedure entertree(var subtree: treepointer;
  142.                            word   : alfa;
  143.                            line   :counter);
  144.    var
  145.      nextitem : queuepointer;
  146.    begin
  147.      if subtree=nil then
  148.        begin {create a new entry}
  149.          new(subtree);
  150.          with subtree^ do begin
  151.            left := nil;
  152.            right := nil;
  153.            with entry do begin
  154.              wordvalue := word;
  155.              new(firstinqueue);
  156.              lastinqueue := firstinqueue;
  157.              with firstinqueue^ do begin
  158.                 linenumber := line;
  159.                 nextinqueue := nil;
  160.              end;{WITH FirstInQueue}
  161.            end;{WITH entry}
  162.          end;{WITH subtree}
  163.        end {create a new entry}
  164.      else {append a list item}
  165.        with subtree^, entry do
  166.          if word=wordvalue then
  167.            begin
  168.              if lastinqueue^.linenumber <> line then
  169.                 begin
  170.                   new(nextitem);
  171.                   with nextitem^ do begin
  172.                     linenumber := line;
  173.                     nextinqueue := nil;
  174.                   end;{WITH}
  175.                   lastinqueue^.nextinqueue := nextitem;
  176.                   lastinqueue := nextitem;
  177.                 end;
  178.            end
  179.          else
  180.            if word < wordvalue then
  181.              entertree(left,word,line)
  182.            else
  183.              entertree(right,word,line);
  184.    end;{Entertree}
  185.  
  186. procedure readc({updating} var nextchar : charinfo;
  187.                 {returning}var currchar : charinfo );
  188. var
  189.   look          : char; { Character read in from File }
  190. begin   {+++ File status module. +++
  191.    Stores file status "AFTER" a read.
  192.    NOTE this play on words - after one char is
  193.    actually "PRIOR TO" the next character               }
  194.   if xeoln then begin
  195.      lineinlast := linein;
  196.      if (not eof(fin)) then begin
  197.         readln(fin, linein);
  198.         cp := 0;
  199.         xeoln := false;
  200.         end
  201.       else
  202.         xeof := true;
  203.       end;
  204.   if cp >= length(linein) then begin
  205.      xeoln := true;
  206.      xeof  := eof(fin);
  207.      look  := ' ';
  208.      end
  209.   else begin
  210.      cp := cp + 1;
  211.      look := linein[cp];
  212.      end;
  213.         {+++ current operative character module +++}
  214.   currchar := nextchar;
  215.         {+++ Classify the character just read +++}
  216.   with nextchar do begin{ Look-ahead character name module }
  217.     if xeof then
  218.         name := filemark
  219.     else if xeoln then
  220.         name := endofline
  221.     else if look in ['a'..'z'] then {lower case plus}
  222.         name := lletter
  223.     else if look in ['^','$','_','A'..'Z'] then {upper case}
  224.         name := uletter
  225.     else if look in ['0'..'9'] then {digit}
  226.         name := digit
  227.     else if look = '''' then
  228.         name := quote
  229.     else if look = tab then
  230.         name := atab
  231.     else if look = space then
  232.         name := blank
  233.     else
  234.         name := otherchar;
  235.     case name of{ store character value module }
  236.         endofline,
  237.         filemark:       valu := space;
  238.         lletter:        valu := upcase(look);       { Cnvrt to uppcase }
  239.         else            valu := look;
  240.     end{ case name of };
  241.   end{ Look-ahead character name module };
  242. end; {of ReadC}
  243.  
  244. procedure getl( var fbuffer :  genstr      );
  245. {++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  246. {+      Get a line of text into users buffer.           +}
  247. {+      Flushes comment lines:                          +}
  248. {+      Flushes lines of Literals:  'this is it'        +}
  249. {+      Ignores special characters & tabs:              +}
  250. {+      Recognizes End of File and End of Line.         +}
  251. {+                                                      +}
  252. {+GLOBAL                                                +}
  253. {+      flushing : (KNOT, DBL, STD, LIT, SCANFN);       +}
  254. {+      LLmax   = 0..Max Line length;                   +}
  255. {++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
  256. var
  257.   state : (scanning, terminal, overflow);
  258.   sawdot : boolean;
  259. begin { GetL }
  260.    fbuffer := '';
  261.    fname := '';
  262.    fatal_error := false;
  263.    state := scanning;
  264.   repeat
  265.     readc(nextchar, currchar);
  266.     if (length(fbuffer) >= llmax) then{ exceeded length of buffer }
  267.       begin{ reset EOLN }
  268.         fatal_error := true;
  269.         state := overflow;
  270.         fbuffer := '';
  271.         write(bell);
  272.         writeln('EXCEEDED LENGTH OF INPUT BUFFER');
  273.       end
  274.     else
  275.       begin
  276.         if (currchar.name in [filemark,endofline]) then
  277.           state:=terminal{ END of line or END of file };
  278.         case flushing of
  279.             knot:
  280.                 case currchar.name of
  281.                 lletter, uletter, digit, blank:
  282.                         begin{ store }
  283.                         fbuffer := concat(fbuffer,currchar.valu) ;
  284.                         end;
  285.                 atab, quote, otherchar:
  286.                         begin{   Flush comments -convert
  287.                                  tabs & other chars to spaces }
  288.                         if (currchar.valu='(') and (nextchar.valu='*')
  289.                           then flushing := dbl
  290.                         else if (currchar.valu='{') THEN
  291.                            flushing := STD
  292.                         ELSE IF currchar.name=quote THEN
  293.                            flushing := LIT;
  294.                         { convert to a space }
  295.                            fbuffer := concat(fbuffer,gap);
  296.                         end;
  297.                 else         { END of line -or- file mark }
  298.                         fbuffer := concat(fbuffer,currchar.valu)
  299.                 end{ case currchar name of };
  300.             dbl:  { scanning for a closing  - double comment }
  301.                 if (currchar.valu ='*') and (nextchar.valu =')')
  302.                   then flushing := knot;
  303.             std:  begin { scanning for a closing curley  }
  304.                   if currchar.valu = '}' then
  305.                       flushing := knot;
  306. { Check if incl } if (currchar.valu = '$') and (nextchar.valu = 'I') then
  307.                       flushing := scanfn;
  308.                   end;
  309.             lit:  { scanning for a closing quote }
  310.                   if currchar.name = quote then
  311.                     flushing := knot;
  312.             scanfn: if (nextchar.valu<>' ') and (nextchar.valu<>tab) then
  313.                     begin
  314.                     flushing := scanfn2;
  315.                     sawdot := false;
  316.                     end;
  317.             scanfn2: if (currchar.valu in ['A'..'Z','0'..'9','.'])
  318.                      then begin
  319.                         fname := concat(fname, currchar.valu);
  320.                         if currchar.valu = '.' then sawdot := true;
  321.                         end
  322.                      else begin
  323.                         if length(fname) = 0 then  { Make sure we ignore $I-}
  324.                            doinclude := false      { compiler directive }
  325.                         else begin
  326.                            if not sawdot then fname := concat(fname, '.PAS');
  327.                            doinclude := true;
  328.                            end;
  329.                         flushing := std;
  330.                         end;
  331.         end{ flushing case }
  332.       end{ ELSE }
  333.   until (state<>scanning);
  334. end; {of GetL}
  335.  
  336. procedure readword;
  337. {++++++++++++++++++++++++++++++++++++++++++++++++}
  338. {+                                              +}
  339. {+       Analyze the Line into "words"          +}
  340. {+                                              +}
  341. {++++++++++++++++++++++++++++++++++++++++++++++++}
  342. label   1;
  343. var
  344.   ix,           {temp indexer}
  345.   idlen,        {length of the word}
  346.   cpos : byte; { Current Position pointer }
  347. begin{ ReadWord }
  348.   cpos := 1; { start at the beginning of a line }
  349.   while cpos < length(fbuffer) do
  350.     begin {Cpos<length(fbuffer)}
  351.       while (cpos < length(fbuffer)) and (fbuffer[cpos]=space) do
  352.         cpos:=cpos + 1;    {--- skip spaces ---}
  353.       idlen := 0;
  354.       while (cpos < length(fbuffer)) and (fbuffer[cpos ] <> space) do
  355.         begin{ accept only non-spaces }
  356.           if idlen < maxwordlen then
  357.             begin
  358.               idlen := idlen + 1;
  359.               currentword[idlen] := fbuffer[cpos];
  360.             end;
  361.           cpos := cpos +1;
  362.         end{ WHILE };
  363.       currentword[0] := chr(idlen);
  364.       if length(currentword)=0 then {no word was found} goto 1;
  365.  
  366.       if (not find_in_reserve(currentword)) and    {check if reserved word}
  367.          (not (currentword[1] in ['0'..'9'])) then {or numeric constant}
  368.          entertree(tree,currentword,currentline);
  369.  
  370.       1:{Here is no word <length of word=0>};
  371.     end; {WHILE Cpos<length(fbuffer)}
  372. end; {of Readword}
  373.  
  374. begin{BuildTree}
  375.    flushing := knot{ flushing };
  376.    doinclude := false;
  377.    xeoln := true;
  378.    xeof  := false;
  379.    linein := '';
  380.    assign(fin,infile);
  381.    reset(fin);
  382.    if ioresult <> 0 then
  383.       begin
  384.         write(bell);
  385.         writeln('File ',infile,' not found !!!!!!');
  386.         fatal_error := true;
  387.       end;
  388.      nextchar.name := blank;       { Initialize next char to a space }
  389.      nextchar.valu := space;
  390.      readc({update}    nextchar,   { Initialize current char to space }
  391.            {returning} currchar);  { First char from file in nextchar }
  392.      while ((currchar.name<>filemark) and (not fatal_error)) do
  393.        begin
  394.          currentline := currentline + 1;
  395.          getl(fbuffer) { attempt to read the first line };
  396.          writeln(fout, currentline:6,': ',lineinlast);
  397.          if listing then writeln(currentline:6,': ',lineinlast)
  398.          else if (currentline mod 100) = 0 then
  399.            writeln('ON LINE : ',currentline:0);
  400.          readword; {Analyze the Text into single 'words' }
  401.          if doinclude then begin
  402.             buildtree(tree, fname);  { recursively do include }
  403.             doinclude := false;
  404.             end;
  405.        end; {While}
  406.        close(fin);
  407.  
  408. end; {of BuildTree}{CLOSE(PRN_ID);}
  409.  
  410. procedure printtree(tree: treepointer);
  411. {
  412. GLOBAL
  413.         MaxOnLine   = max line references per line
  414.         NumberWidth = field for each number
  415. }
  416. var
  417.   pageposition: pageindex;
  418.    procedure printentry(subtree: treepointer;
  419.                         var position: pageindex);
  420.    var  ix: wordindex;
  421.         itemcount : 0..maxlinelen;
  422.         itemptr : queuepointer;
  423.         procedure printline(var currentposition: pageindex;
  424.                                 newlines: pageindex);
  425.         var
  426.           linecounter: pageindex;
  427.         begin
  428.           if (currentposition + newlines) < maxonpage then
  429.             begin
  430.                 for linecounter:=1 to newlines do writeln(xout);
  431.                 currentposition := currentposition + newlines;
  432.             end
  433.           else
  434.             begin
  435.               page(xout);
  436.               writeln(xout,heading);
  437.               for linecounter := 1 to headingsize - 1 do
  438.                  writeln(xout);
  439.               currentposition := headingsize + 1;
  440.             end
  441.         end;{PrintLine}
  442.  
  443.    begin{PrintEntry}
  444.      if subtree<>nil then
  445.         with subtree^ do begin
  446.           printentry(left,position);
  447.           printline(position,entrygap + 1);
  448.           with entry do begin
  449.             for ix := 1 to length(wordvalue) do write(xout, wordvalue[ix]);
  450.             write(xout, space:(maxwordlen-length(wordvalue)));
  451.             itemcount := 0;
  452.             itemptr := firstinqueue;
  453.             while itemptr <> nil do
  454.               begin
  455.                 itemcount := itemcount + 1;
  456.                 if itemcount > maxonline then
  457.                   begin
  458.                     printline(position,1);
  459.                     write(xout, space:maxwordlen);
  460.                     itemcount := 1;
  461.                   end;
  462.                 write(xout, itemptr^.linenumber: numberwidth);
  463.                 itemptr := itemptr^.nextinqueue;
  464.               end;{WHILE}
  465.           end; {WITH entry}
  466.           printentry(right,position);
  467.         end; {WITH subtree^}
  468.    end; {PrintEntry}
  469.  
  470. begin{PrintTree}
  471.   pageposition := maxonpage;
  472.   printentry(tree,pageposition);
  473. end; {of PrintTree}{CLOSE(New_ID);}
  474.  
  475. function connectfiles: boolean;
  476. type
  477.   linebuffer = string[80];
  478. var
  479.   ix  : byte;
  480. begin{ ConnectFiles }
  481.   fatal_error := false;
  482.   connectfiles := true;
  483.    writeln('Enter Complete Filenames') ;
  484.    writeln ;
  485.    write('Input File: ');
  486.    readln(file_id);
  487.    writeln;
  488.    write('Print output file (.PRN): ');
  489.    readln(prn_id);
  490.    writeln;
  491.    write('Cross-Reference output file (.XRF): ');
  492.    readln(new_id);
  493.    writeln;
  494.    assign(fout,prn_id);
  495.    rewrite(fout);
  496.    if ioresult <> 0 then begin
  497.       writeln('Could not open ',prn_id,' (print output file).');
  498.       connectfiles := false;
  499.       fatal_error  := true;
  500.       end;
  501.   assign(xout,new_id);
  502.   rewrite(xout) ;
  503.   if ioresult <> 0 then begin
  504.      writeln('Could not open ',new_id,' (xref output file).');
  505.      connectfiles := false;
  506.      fatal_error := true;
  507.      end;
  508. end{ of ConnectFiles };
  509.  
  510. procedure initialize;
  511. var
  512.   ch: char;
  513. begin
  514.   bell := ^g; gap := ' ' ;
  515.   currentline := 0;
  516.   if connectfiles then
  517.     begin
  518.          key[1] := 'ABSOLUTE';
  519.          key[2] := 'AND';
  520.          key[3] := 'ARCTAN';
  521.          key[4] := 'ARRAY';
  522.          key[5] := 'ASSIGN';
  523.          key[6] := 'AUX';
  524.          key[7] := 'AUXINPTR';
  525.          key[8] := 'AUXOUTPTR';
  526.          key[9] := 'BEGIN';
  527.          key[10] := 'BLACK';
  528.          key[11] := 'BLUE';
  529.          key[12] := 'BLOCKREAD';
  530.          key[13] := 'BLOCKWRITE';
  531.          key[14] := 'BOOLEAN';
  532.          key[15] := 'BROWN';
  533.          key[16] := 'BUFLEN';
  534.          key[17] := 'BYTE';
  535.          key[18] := 'CASE';
  536.          key[19] := 'CHAIN';
  537.          key[20] := 'CHAR';
  538.          key[21] := 'CHR';
  539.          key[22] := 'CLOSE';
  540.          key[23] := 'CLREOL';
  541.          key[24] := 'CLRSCR';
  542.          key[25] := 'CON';
  543.          key[26] := 'CONCAT';
  544.          key[27] := 'CONINPTR';
  545.          key[28] := 'CONOUTPTR';
  546.          key[29] := 'CONST';
  547.          key[30] := 'CONSTPTR';
  548.          key[31] := 'COPY';
  549.          key[32] := 'COS';
  550.          key[33] := 'CRTEXIT';
  551.          key[34] := 'CRTINIT';
  552.          key[35] := 'CYAN';
  553.          key[36] := 'DARKGRAY';
  554.          key[37] := 'DELAY';
  555.          key[38] := 'DELETE';
  556.          key[39] := 'DELLINE';
  557.          key[40] := 'DISPOSE';
  558.          key[41] := 'DIV';
  559.          key[42] := 'DO';
  560.          key[43] := 'DOWNTO';
  561.          key[44] := 'DRAW';
  562.          key[45] := 'ELSE';
  563.          key[46] := 'END';
  564.          key[47] := 'EOF';
  565.          key[48] := 'EOLN';
  566.          key[49] := 'ERASE';
  567.          key[50] := 'EXECUTE';
  568.          key[51] := 'EXIT';
  569.          key[52] := 'EXP';
  570.          key[53] := 'EXTERNAL';
  571.          key[54] := 'FALSE';
  572.          key[55] := 'FILE';
  573.          key[56] := 'FILEPOS';
  574.          key[57] := 'FILESIZE';
  575.          key[58] := 'FILLCHAR';
  576.          key[59] := 'FLUSH';
  577.          key[60] := 'FOR';
  578.          key[61] := 'FORWARD';
  579.          key[62] := 'FRAC';
  580.          key[63] := 'FREEMEM';
  581.          key[64] := 'FUNCTION';
  582.          key[65] := 'GETMEM';
  583.          key[66] := 'GOTO';
  584.          key[67] := 'GOTOXY';
  585.          key[68] := 'GRAPHBACKGROUND';
  586.          key[69] := 'GRAPHCOLORMODE';
  587.          key[70] := 'GRAPHMODE';
  588.          key[71] := 'GRAPHWINDOW';
  589.          key[72] := 'GREEN';
  590.          key[73] := 'HALT';
  591.          key[74] := 'HEAPPTR';
  592.          key[75] := 'HI';
  593.          key[76] := 'HIRES';
  594.          key[77] := 'HIRESCOLOR';
  595.          key[78] := 'IF';
  596.          key[79] := 'IN';
  597.          key[80] := 'INLINE';
  598.          key[81] := 'INPUT';
  599.          key[82] := 'INSERT';
  600.          key[83] := 'INSLINE';
  601.          key[84] := 'INT';
  602.          key[85] := 'INTEGER';
  603.          key[86] := 'IORESULT';
  604.          key[87] := 'KBD';
  605.          key[88] := 'KEYPRESSED';
  606.          key[89] := 'LABEL';
  607.          key[90] := 'LENGTH';
  608.          key[91] := 'LIGHTBLUE';
  609.          key[92] := 'LIGHTCYAN';
  610.          key[93] := 'LIGHTGRAY';
  611.          key[94] := 'LIGHTGREEN';
  612.          key[95] := 'LIGHTMAGENTA';
  613.          key[96] := 'LIGHTRED';
  614.          key[97] := 'LN';
  615.          key[98] := 'LO';
  616.          key[99] := 'LOWVIDEO';
  617.          key[100] := 'LST';
  618.          key[101] := 'LSTOUTPTR';
  619.          key[102] := 'MAGENTA';
  620.          key[103] := 'MARK';
  621.          key[104] := 'MAXAVAIL';
  622.          key[105] := 'MAXINT';
  623.          key[106] := 'MEM';
  624.          key[107] := 'MEMAVAIL';
  625.          key[108] := 'MEMW';
  626.          key[109] := 'MOD';
  627.          key[110] := 'MOVE';
  628.          key[111] := 'NEW';
  629.          key[112] := 'NIL';
  630.          key[113] := 'NORMVIDEO';
  631.          key[114] := 'NOSOUND';
  632.          key[115] := 'NOT';
  633.          key[116] := 'ODD';
  634.          key[117] := 'OF';
  635.          key[118] := 'OR';
  636.          key[119] := 'ORD';
  637.          key[120] := 'OUTPUT';
  638.          key[121] := 'OVERLAY';
  639.          key[122] := 'PACKED';
  640.          key[123] := 'PALETTE';
  641.          key[124] := 'PI';
  642.          key[125] := 'PLOT';
  643.          key[126] := 'PORT';
  644.          key[127] := 'POS';
  645.          key[128] := 'PRED';
  646.          key[129] := 'PROCEDURE';
  647.          key[130] := 'PROGRAM';
  648.          key[131] := 'PTR';
  649.          key[132] := 'RANDOM';
  650.          key[133] := 'RANDOMIZE';
  651.          key[134] := 'READ';
  652.          key[135] := 'READLN';
  653.          key[136] := 'REAL';
  654.          key[137] := 'RECORD';
  655.          key[138] := 'RED';
  656.          key[139] := 'RELEASE';
  657.          key[140] := 'RENAME';
  658.          key[141] := 'REPEAT';
  659.          key[142] := 'RESET';
  660.          key[143] := 'REWRITE';
  661.          key[144] := 'ROUND';
  662.          key[145] := 'SEEK';
  663.          key[146] := 'SET';
  664.          key[147] := 'SHL';
  665.          key[148] := 'SHR';
  666.          key[149] := 'SIN';
  667.          key[150] := 'SIZEOF';
  668.          key[151] := 'SOUND';
  669.          key[152] := 'SQR';
  670.          key[153] := 'SQRT';
  671.          key[154] := 'STR';
  672.          key[155] := 'STRING';
  673.          key[156] := 'SUCC';
  674.          key[157] := 'SWAP';
  675.          key[158] := 'TEXT';
  676.          key[159] := 'TEXTBACKGROUND';
  677.          key[160] := 'TEXTCOLOR';
  678.          key[161] := 'TEXTMODE';
  679.          key[162] := 'THEN';
  680.          key[163] := 'TO';
  681.          key[164] := 'TRM';
  682.          key[165] := 'TRUE';
  683.          key[166] := 'TRUNC';
  684.          key[167] := 'TYPE';
  685.          key[168] := 'UNTIL';
  686.          key[169] := 'UPCASE';
  687.          key[170] := 'USR';
  688.          key[171] := 'USRINPTR';
  689.          key[172] := 'USROUTPTR';
  690.          key[173] := 'VAL';
  691.          key[174] := 'VAR';
  692.          key[175] := 'WHEREX';
  693.          key[176] := 'WHEREY';
  694.          key[177] := 'WHILE';
  695.          key[178] := 'WHITE';
  696.          key[179] := 'WINDOW';
  697.          key[180] := 'WITH';
  698.          key[181] := 'WRITE';
  699.          key[182] := 'WRITELN';
  700.          key[183] := 'XOR';
  701.          key[184] := 'YELLOW';
  702.         tab     := chr(9);  { ASCII Tab character }
  703.         form_feed := chr(12);  gap  := chr(32);
  704.         write('List file to console (Y/N)?: ');
  705.         read(kbd,ch);
  706.         listing := ( (ch='Y') or (ch='y') );
  707.         writeln; writeln;
  708.     end; {IF ConnectFiles}
  709. end; {of Initialize}
  710.  
  711. begin { Cross Reference }
  712.   clrscr;
  713.   writeln(' ':22, 'CROSS REFERENCE GENERATOR');
  714.   writeln;writeln;writeln;writeln;
  715.   initialize;
  716.   if not fatal_error then
  717.     begin
  718.       wordtree := nil;          {Make the Tree empty}
  719.       writeln('Pass 1 [Listing] Begins ...');buildtree(wordtree, file_id);
  720.       close(fout) ;
  721.       writeln('Pass 2 [Cross-Ref] Begins ...');printtree(wordtree);
  722.       close(xout);
  723.     end;
  724.   writeln;
  725. end. { Cross Refer
  726.