home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
cobol
/
library
/
xref
/
xref.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-10-01
|
25KB
|
848 lines
{$C-,A-,I-,V-,R-}
{++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
{+ +}
{+ PROGRAM TITLE: Cross Reference Generator +}
{+ +}
{+ AUTHOR: Peter Grogono, et al. +}
{+ +}
{+ SUMMARY: +}
{+ 1. Output Files: +}
{+ a. first output file is a numbered listing +}
{+ of the input source +}
{+ b. second output file is cross reference +}
{+ with each identifier followed by the +}
{+ line numbers on which it appears. +}
{+ 2. Listing Device: +}
{+ The numbered source listing may optionally +}
{+ be routed to the screen or printer (but not +}
{+ both). +}
{+ +}
{+ +}
{++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
(* COBOL Version, 10/1/86, David C. Oshel
Note: The list of reserved words includes IBM-PC COBOL 1.00 extensions,
such as BACKGROUND-COLOR, etc., that are not part of Standard COBOL.
This version has been kludged up to take command line arguments so it
can be used in batch. Assumes IBM-PC clone.
Type "C>xref ?" for usage.
Example: xref ptosub1 ptosub2 ptosub3 ptomain
*)
PROGRAM XREFT;
{ Cross Reference Generator }
CONST
xrefver = 'XREF 3.0 for COBOL';
datever = 'Oct. 1, 1986, D.C.Oshel';
alfa_length = 30;
dflt_str_len = 255;
entrygap = 0; { # of blank lines between line numbers}
heading : string[23] = 'cross-reference list';
headingsize = 3; {number of lines for heading}
LLmax = dflt_str_len;
MaxOnLine = 8;
Maxlines = MAXINT; {longest document permitted}
MaxWordlen = alfa_length;{longest word read without truncation}
Maxlinelen = 80; {length of output line}
MaxOnPage = 60; {size of output page}
NumKeys = 348; {number of COBOL reseved words}
NumberWidth = 6;
space : char = ' ';
TYPE
ALFA = string[alfa_length];
CHARNAME = (lletter, uletter, digit, blank, quote, atab,
EndOfLine, FileMark, otherchar );
CHARINFO = RECORD
name : charname;
valu : CHAR
END;
COUNTER = 1..Maxlines;
pageindex = BYTE;
Wordindex = 1..MaxWordlen;
Queuepointer = ^Queueitem;
Queueitem = RECORD
linenumber : counter;
NextInQueue: Queuepointer
END;
EntryType = RECORD
Wordvalue : alfa;
FirstInQueue,
lastinQueue: Queuepointer
END;
treepointer = ^node;
node = RECORD
entry : EntryType;
left,
right : treepointer
END;
GenStr = string[255];
VAR
bell : CHAR;
fatal_error : BOOLEAN;
UseFile, { Scratch for command line args }
FILE_ID, { Input file name }
PRN_ID, { basic file name + '.PRN' }
New_ID : string[80]; { basic file name + '.XRF' }
form_feed : CHAR;
Key : ARRAY[1..NumKeys] OF alfa;
LISTING : BOOLEAN;
tab : CHAR;
WordTree : treepointer;
GAP : char ;
Currentline : INTEGER;
FOUT: TEXT; { print output file }
XOUT: TEXT; { xref output file }
{$I XREF1.INC }
Procedure Heapsort; (* after Knuth, Vol. 3, p. 146 *)
label
lab1,lab2,lab3,lab4,lab5,lab6,lab7,lab8;
const
B = 1; Size = NumKeys;
var
I,J,L,R: Integer; Temp: ALFA;
begin
L := (Size div 2) + 1; (* don't ask, it's magic! *)
R := Size;
lab1: if L > B then goto lab2;
Temp := Key[R];
Key[R] := Key[B];
R := R - 1;
if R = B then goto lab8;
goto lab3;
lab2: L := L - 1;
Temp := Key[L];
lab3: J := L;
lab4: I := J;
J := 2 * J;
if J < R then goto lab5;
if J = R then goto lab6;
if J > R then goto lab7;
lab5: if Key[J] < Key[J+1] then J := J + 1;
lab6: if Temp >= Key[J] then goto lab7;
Key[I] := Key[J];
goto lab4;
lab7: Key[I] := Temp;
goto lab1;
lab8: Key[B] := Temp; (* finished! *)
end; { Heapsort }
const flag:Boolean = FALSE; (* used by SetKey *)
Procedure SetKey; (* the set of COBOL reserved words *)
begin
if not flag then begin
writeln;
write(xrefver,': one moment please, sorting ',NumKeys,' reserved words...');
Key[ 1] := 'ACCEPT';
Key[ 2] := 'ACCESS';
Key[ 3] := 'ADD';
Key[ 4] := 'ADVANCING';
Key[ 5] := 'AFTER';
Key[ 6] := 'ALL';
Key[ 7] := 'ALPHABETIC';
Key[ 8] := 'ALSO';
Key[ 9] := 'ALTER';
Key[ 10] := 'ALTERNATE';
Key[ 11] := 'AND';
Key[ 12] := 'ARE';
Key[ 13] := 'AREA';
Key[ 14] := 'AREAS';
Key[ 15] := 'ASCENDING';
Key[ 16] := 'ASCII';
Key[ 17] := 'ASSIGN';
Key[ 18] := 'AT';
Key[ 19] := 'AUTHOR';
Key[ 20] := 'AUTO';
Key[ 21] := 'AUTO-SKIP';
Key[ 22] := 'BACKGROUND-COLOR';
Key[ 23] := 'BEEP';
Key[ 24] := 'BEFORE';
Key[ 25] := 'BELL';
Key[ 26] := 'BLANK';
Key[ 27] := 'BLINK';
Key[ 28] := 'BLOCK';
Key[ 29] := 'BOTTOM';
Key[ 30] := 'BY';
Key[ 31] := 'CALL';
Key[ 32] := 'CANCEL';
Key[ 33] := 'CD';
Key[ 34] := 'CF';
Key[ 35] := 'CH';
Key[ 36] := 'CHAIN';
Key[ 37] := 'CHAINING';
Key[ 38] := 'CHARACTER';
Key[ 39] := 'CHARACTERS';
Key[ 40] := 'CLOCK-UNITS';
Key[ 41] := 'CLOSE';
Key[ 42] := 'COBOL';
Key[ 43] := 'CODE';
Key[ 44] := 'CODE-SET';
Key[ 45] := 'COL';
Key[ 46] := 'COLLATING';
Key[ 47] := 'COLUMN';
Key[ 48] := 'COMMA';
Key[ 49] := 'COMMUNICATION';
Key[ 50] := 'COMP';
Key[ 51] := 'COMP-0';
Key[ 52] := 'COMP-3';
Key[ 53] := 'COMPUTATIONAL';
Key[ 54] := 'COMPUTATIONAL-0';
Key[ 55] := 'COMPUTATIONAL-3';
Key[ 56] := 'COMPUTE';
Key[ 57] := 'CONFIGURATION';
Key[ 58] := 'CONTAINS';
Key[ 59] := 'CONTROL';
Key[ 60] := 'CONTROLS';
Key[ 61] := 'COPY';
Key[ 62] := 'CORR';
Key[ 63] := 'CORRESPONDING';
Key[ 64] := 'COUNT';
Key[ 65] := 'CURRENCY';
Key[ 66] := 'DATA';
Key[ 67] := 'DATE';
Key[ 68] := 'DATE-COMPILED';
Key[ 69] := 'DATE-WRITTEN';
Key[ 70] := 'DAY';
Key[ 71] := 'DE';
Key[ 72] := 'DEBUG-CONTENTS';
Key[ 73] := 'DEBUG-ITEM';
Key[ 74] := 'DEBUG-NAME';
Key[ 75] := 'DEBUG-SUB-1';
Key[ 76] := 'DEBUG-SUB-2';
Key[ 77] := 'DEBUG-SUB-3';
Key[ 78] := 'DEBUGGING';
Key[ 79] := 'DECIMAL-POINT';
Key[ 80] := 'DECLARATIVES';
Key[ 81] := 'DELETE';
Key[ 82] := 'DELIMITED';
Key[ 83] := 'DELIMITER';
Key[ 84] := 'DEPENDING';
Key[ 85] := 'DESCENDING';
Key[ 86] := 'DESTINATION';
Key[ 87] := 'DETAIL';
Key[ 88] := 'DISABLE';
Key[ 89] := 'DISK';
Key[ 90] := 'DISPLAY';
Key[ 91] := 'DIVIDE';
Key[ 92] := 'DIVISION';
Key[ 93] := 'DOWN';
Key[ 94] := 'DUPLICATES';
Key[ 95] := 'DYNAMIC';
Key[ 96] := 'EGI';
Key[ 97] := 'ELSE';
Key[ 98] := 'EMI';
Key[ 99] := 'EMPTY-CHECK';
Key[100] := 'ENABLE';
Key[101] := 'END';
Key[102] := 'END-OF-PAGE';
Key[103] := 'ENTER';
Key[104] := 'ENVIRONMENT';
Key[105] := 'EOP';
Key[106] := 'EQUAL';
Key[107] := 'ERASE';
Key[108] := 'ERROR';
Key[109] := 'ESCAPE';
Key[110] := 'ESI';
Key[111] := 'EVERY';
Key[112] := 'EXCEPTION';
Key[113] := 'EXHIBIT';
Key[114] := 'EXIT';
Key[115] := 'EXTEND';
Key[116] := 'FD';
Key[117] := 'FILE';
Key[118] := 'FILE-CONTROL';
Key[119] := 'FILE-ID';
Key[120] := 'FILLER';
Key[121] := 'FINAL';
Key[122] := 'FIRST';
Key[123] := 'FOOTING';
Key[124] := 'FOR';
Key[125] := 'FOREGROUND-COLOR';
Key[126] := 'FROM';
Key[127] := 'FULL';
Key[128] := 'GENERATE';
Key[129] := 'GIVING';
Key[130] := 'GO';
Key[131] := 'GREATER';
Key[132] := 'GROUP';
Key[133] := 'HEADING';
Key[134] := 'HIGHLIGHT';
Key[135] := 'HIGH-VALUE';
Key[136] := 'HIGH-VALUES';
Key[137] := 'I-O';
Key[138] := 'I-O-CONTROL';
Key[139] := 'IDENTIFICATION';
Key[140] := 'IF';
Key[141] := 'IN';
Key[142] := 'INDEX';
Key[143] := 'INDEXED';
Key[144] := 'INDICATE';
Key[145] := 'INITIAL';
Key[146] := 'INITIATE';
Key[147] := 'INPUT';
Key[148] := 'INPUT-OUTPUT';
Key[149] := 'INSPECT';
Key[150] := 'INSTALLATION';
Key[151] := 'INTO';
Key[152] := 'INVALID';
Key[153] := 'IS';
Key[154] := 'JUST';
Key[155] := 'JUSTIFIED';
Key[156] := 'KEY';
Key[157] := 'LABEL';
Key[158] := 'LAST';
Key[159] := 'LEADING';
Key[160] := 'LEFT';
Key[161] := 'LEFT-JUSTIFY';
Key[162] := 'LENGTH';
Key[163] := 'LENGTH-CHECK';
Key[164] := 'LESS';
Key[165] := 'LIMIT';
Key[166] := 'LIMITS';
Key[167] := 'LIN';
Key[168] := 'LINAGE';
Key[169] := 'LINAGE-COUNTER';
Key[170] := 'LINE';
Key[171] := 'LINE-COUNTER';
Key[172] := 'LINES';
Key[173] := 'LINKAGE';
Key[174] := 'LOCK';
Key[175] := 'LOW-VALUE';
Key[176] := 'LOW-VALUES';
Key[177] := 'MEMORY';
Key[178] := 'MERGE';
Key[179] := 'MESSAGE';
Key[180] := 'MODE';
Key[181] := 'MODULES';
Key[182] := 'MOVE';
Key[183] := 'MULTIPLE';
Key[184] := 'MULTIPLY';
Key[185] := 'NAMES';
Key[186] := 'NATIVE';
Key[187] := 'NEGATIVE';
Key[188] := 'NEXT';
Key[189] := 'NO';
Key[190] := 'NO-ECHO';
Key[191] := 'NOT';
Key[192] := 'NUMBER';
Key[193] := 'NUMERIC';
Key[194] := 'OBJECT-COMPUTER';
Key[195] := 'OCCURS';
Key[196] := 'OF';
Key[197] := 'OFF';
Key[198] := 'OMITTED';
Key[199] := 'ON';
Key[200] := 'OPEN';
Key[201] := 'OPTIONAL';
Key[202] := 'OR';
Key[203] := 'ORGANIZATION';
Key[204] := 'OUTPUT';
Key[205] := 'OVERFLOW';
Key[206] := 'PAGE';
Key[207] := 'PAGE-COUNTER';
Key[208] := 'PERFORM';
Key[209] := 'PF';
Key[210] := 'PH';
Key[211] := 'PIC';
Key[212] := 'PICTURE';
Key[213] := 'PLUS';
Key[214] := 'POINTER';
Key[215] := 'POSITION';
Key[216] := 'POSITIVE';
Key[217] := 'PRINTER';
Key[218] := 'PROCEDURE';
Key[219] := 'PROCEDURES';
Key[220] := 'PROCEED';
Key[221] := 'PROGRAM';
Key[222] := 'PROGRAM-ID';
Key[223] := 'PROMPT';
Key[224] := 'QUEUE';
Key[225] := 'QUOTE';
Key[226] := 'RANDOM';
Key[227] := 'RD';
Key[228] := 'READ';
Key[229] := 'READY';
Key[230] := 'RECEIVE';
Key[231] := 'RECORD';
Key[232] := 'RECORDS';
Key[233] := 'REDEFINES';
Key[234] := 'REEL';
Key[235] := 'REFERENCES';
Key[236] := 'RELATIVE';
Key[237] := 'RELEASE';
Key[238] := 'REMAINDER';
Key[239] := 'REMOVAL';
Key[240] := 'RENAMES';
Key[241] := 'REPLACING';
Key[242] := 'REPORT';
Key[243] := 'REPORTS';
Key[244] := 'REPORTING';
Key[245] := 'REQUIRED';
Key[246] := 'RERUN';
Key[247] := 'RESERVE';
Key[248] := 'RESET';
Key[249] := 'RETURN';
Key[250] := 'REVERSE-VIDEO';
Key[251] := 'REVERSED';
Key[252] := 'REWIND';
Key[253] := 'REWRITE';
Key[254] := 'RF';
Key[255] := 'RH';
Key[256] := 'RIGHT';
Key[257] := 'RIGHT-JUSTIFY';
Key[258] := 'ROUNDED';
Key[259] := 'RUN';
Key[260] := 'SAME';
Key[261] := 'SCREEN';
Key[262] := 'SD';
Key[263] := 'SEARCH';
Key[264] := 'SECTION';
Key[265] := 'SECURE';
Key[266] := 'SECURITY';
Key[267] := 'SEGMENT';
Key[268] := 'SEGMENT-LINE';
Key[269] := 'SELECT';
Key[270] := 'SEND';
Key[271] := 'SENTENCE';
Key[272] := 'SEPARATE';
Key[273] := 'SEQUENCE';
Key[274] := 'SEQUENTIAL';
Key[275] := 'SET';
Key[276] := 'SIGN';
Key[277] := 'SIZE';
Key[278] := 'SORT';
Key[279] := 'SORT-MERGE';
Key[280] := 'SOURCE';
Key[281] := 'SOURCE-COMPUTER';
Key[282] := 'SPACE';
Key[283] := 'SPACE-FILL';
Key[284] := 'SPACES';
Key[285] := 'SPECIAL-NAMES';
Key[286] := 'STANDARD';
Key[287] := 'STANDARD-1';
Key[288] := 'START';
Key[289] := 'STATUS';
Key[290] := 'STOP';
Key[291] := 'STRING';
Key[292] := 'SUB-QUEUE-1';
Key[293] := 'SUB-QUEUE-2';
Key[294] := 'SUB-QUEUE-3';
Key[295] := 'SUBTRACT';
Key[296] := 'SUM';
Key[297] := 'SUPPRESS';
Key[298] := 'SWITCH-1';
Key[299] := 'SWITCH-2';
Key[300] := 'SWITCH-3';
Key[301] := 'SWITCH-4';
Key[302] := 'SWITCH-5';
Key[303] := 'SWITCH-6';
Key[304] := 'SWITCH-7';
Key[305] := 'SWITCH-8';
Key[306] := 'SYMBOLIC';
Key[307] := 'SYNC';
Key[308] := 'SYNCHRONIZED';
Key[309] := 'TABLE';
Key[310] := 'TALLYING';
Key[311] := 'TAPE';
Key[312] := 'TERMINAL';
Key[313] := 'TERMINATE';
Key[314] := 'TEXT';
Key[315] := 'THAN';
Key[316] := 'THROUGH';
Key[317] := 'THRU';
Key[318] := 'TIME';
Key[319] := 'TIMES';
Key[320] := 'TO';
Key[321] := 'TOP';
Key[322] := 'TRACE';
Key[323] := 'TRAILING';
Key[324] := 'TRAILING-SIGN';
Key[325] := 'TYPE';
Key[326] := 'UNDERLINE';
Key[327] := 'UNIT';
Key[328] := 'UNSTRING';
Key[329] := 'UNTIL';
Key[330] := 'UP';
Key[331] := 'UPDATE';
Key[332] := 'UPON';
Key[333] := 'USAGE';
Key[334] := 'USE';
Key[335] := 'USER';
Key[336] := 'USING';
Key[337] := 'VALUE';
Key[338] := 'VALUES';
Key[339] := 'VARYING';
Key[340] := 'WHEN';
Key[341] := 'WITH';
Key[342] := 'WORDS';
Key[343] := 'WORKING-STORAGE';
Key[344] := 'WRITE';
Key[345] := 'ZERO';
Key[346] := 'ZERO-FILL';
Key[347] := 'ZEROES';
Key[348] := 'ZEROS';
(* Now GUARANTEE that this list is in proper search order! *)
Heapsort;
end;
flag := TRUE;
end; { SetKey }
PROCEDURE PrintTree(tree: treepointer);
{
GLOBAL
MaxOnLine = max line references per line
NumberWidth = field for each number
}
VAR
pageposition: pageindex;
PROCEDURE PrintEntry(subtree: treepointer;
VAR position: pageindex);
VAR ix: Wordindex;
itemcount : 0..Maxlinelen;
itemptr : Queuepointer;
PROCEDURE PrintLine(VAR Currentposition: pageindex;
newlines: pageindex);
VAR
linecounter: pageindex;
BEGIN
IF (Currentposition + newlines) < MaxOnPage THEN
BEGIN
FOR linecounter:=1 TO newlines DO WRITELN(XOUT);
Currentposition := Currentposition + newlines;
END
ELSE
BEGIN
PAGE(XOUT);
WRITELN(XOUT,xrefver,': ',FILE_ID,' ',heading);
FOR linecounter := 1 TO headingsize - 1 DO
WRITELN(XOUT);
Currentposition := headingsize + 1;
END
END;{PrintLine}
BEGIN{PrintEntry}
IF subtree<>nil THEN
WITH subtree^ DO BEGIN
PrintEntry(left,position);
PrintLine(position,entrygap + 1);
WITH entry DO BEGIN
FOR ix := 1 to length(WordValue) do WRITE(XOUT, WordValue[ix]);
WRITE(XOUT, space:(MaxWordLen-length(WordValue)));
itemcount := 0;
itemptr := FirstInQueue;
WHILE itemptr <> nil DO
BEGIN
itemcount := itemcount + 1;
IF itemcount > MaxOnLine THEN
BEGIN
PrintLine(position,1);
WRITE(XOUT, space:MaxWordlen);
itemcount := 1;
END;
WRITE(XOUT, itemptr^.linenumber: numberwidth);
itemptr := itemptr^.NextInQueue;
END;{WHILE}
END; {WITH entry}
PrintEntry(right,position);
END; {WITH subtree^}
END; {PrintEntry}
BEGIN{PrintTree}
PagePosition := MaxOnPage;
PrintEntry(tree,PagePosition);
END; {of PrintTree}{CLOSE(New_ID);}
FUNCTION ConnectFiles: boolean;
TYPE
Linebuffer = string[80];
VAR
ix : BYTE;
InChar : Char;
DotPos : Integer;
Procedure GetNames;
Begin
if ParamCount > 0 then FILE_ID := UseFile
else begin
WRITELN('Enter pathname (.COB, .PRN, and .XRF are appended as required)') ;
WRITELN ;
WRITE('Input File (RETURN to quit): ');
READLN(FILE_ID);
end;
DotPos := Length(File_ID); { Use an available variable }
If DotPos = 0 THEN HALT; { for a quick Sanity check }
DotPos := Pos( '.', File_ID );
If DotPos = 0 THEN { If NO extension (.) }
Begin
File_ID := ( File_ID + '.COB' );
DotPos := Pos( '.', File_ID )
End;
Prn_ID := Copy (File_ID, 1, DotPos) ; { Get base filename with dot }
Prn_ID := ( Prn_ID + 'PRN' ); { and add the proper extension }
New_ID := Copy (File_ID, 1, DotPos) ;
New_ID := ( New_ID + 'XRF' );
if ParamCount = 0 then begin
Writeln;
Writeln (' Input is from : ',File_Id);
Writeln (' Print Out to : ',Prn_Id);
Writeln (' Cross Ref to : ',New_Id);
Writeln;
Write (' Is this acceptable (Y/N)? <Y>:');
Read (Kbd,InChar);
Writeln;
If NOT ((InChar=^M) OR (UpCase(InChar)='Y')) THEN
Begin
Writeln ('--- Supply complete filenames ---');
WRITE('Printed output to: ');
READLN(PRN_ID);
WRITELN;
WRITE('Cross-Reference output to: ');
READLN(NEW_ID);
WRITELN;
End;
end
End; { GetNames }
BEGIN { ConnectFiles *** execution starts here *** }
File_ID := '';
fatal_error := FALSE;
ConnectFiles := TRUE;
GetNames;
Assign(fout,FILE_ID); (* PUH-LEEZE test to make sure the source exists! *)
Reset(fout);
if IOresult <> 0 then begin
writeln('error: ',FILE_ID,' not found');
fatal_error := TRUE;
ConnectFiles := FALSE;
end
else begin
close(fout);
Assign(fout,PRN_ID);
Rewrite(FOUT);
if IOresult <> 0 then begin
writeln('error: could not open ',PRN_ID);
ConnectFiles := FALSE;
fatal_error := TRUE;
end;
assign(xout,NEW_ID);
Rewrite(Xout) ;
if IOresult <> 0 then begin
writeln('error: could not open ',NEW_ID);
ConnectFiles := FALSE;
fatal_error := TRUE;
end;
end
END{ of ConnectFiles };
PROCEDURE Initialize;
VAR
Ch: CHAR;
BEGIN
bell := ^G; GAP := ' ' ;
Currentline := 0;
IF ConnectFiles THEN
BEGIN
tab := CHR(9); { ASCII Tab character }
form_feed := CHR(12);
gap := CHR(32);
if ParamCount = 0 then begin
WRITE('List file to console (Y/N)? <Y>:');
READ(kbd,Ch);
LISTING := (Ch=^M) or (Upcase(Ch)='Y');
WRITELN; WRITELN;
end
else LISTING := TRUE;
END; {IF ConnectFiles}
END; {of Initialize}
procedure helpmsg;
begin
writeln;
writeln(xrefver,', ',datever);
writeln;
writeln('usage: XREF [ ? ][ ! ][ pathname[.typ] ... ]');
writeln;
writeln(' ignores reserved words and IBM-PC COBOL 1.0 extensions');
writeln(' ignores comment lines');
writeln(' default is .COB file type');
writeln(' creates pathname.PRN, pathname.XRF');
writeln(' accepts multiple files, but cannot use wildcards');
writeln;
writeln('e.g., XREF c:\cobol\filectrl.cpy');
writeln(' XREF ptosub1 ptosub2 ptosub3 ptomain');
writeln(' XREF <- begin interactive');
writeln(' XREF ! <- list reserved words');
writeln(' XREF ? <- display help message');
end;
Procedure Doit;
begin
SetKey;
clrscr;
lowvideo;
if ParamCount = 0 then begin
helpmsg;
writeln;writeln;
writeln('Cross Reference Generator for COBOL Source Files');
writeln;
end;
Initialize;
IF NOT fatal_error THEN
BEGIN
if ParamCount > 0 then begin
writeln( xrefver,': ',FILE_ID )
end;
WordTree := NIL; {Make the Tree empty}
writeln('Pass 1 [Listing] Begins ...');
BuildTree(WordTree, FILE_ID);
close(FOUT) ;
writeln('Pass 2 [Cross-Ref] Begins ...');
PrintTree(WordTree);
writeln('Pass 2 [Cross-Ref] Complete..');
writeln(XOUT);
close(XOUT);
writeln;
END
end; { Doit }
Procedure ProcessArguments;
label errxit;
var i: Integer; ch:Char;
begin
if ParamCount = 0 then Doit
else begin
for i := 1 to ParamCount do begin
UseFile := ParamSTR(i);
if UseFile = '?' then begin
errxit: helpmsg;
Halt;
end
else if UseFile = '!' then begin
SetKey;
clrscr;
writeln(xrefver,': Reserved Words & IBM-PC Extensions'); writeln;
for i := 1 to NumKeys do begin
writeln( i:3,'. ',Key[i] );
if (i mod 22) = 0 then begin
write('-more-');
read(kbd,ch);
write(^M,' ':6,^M);
if ch = ^C then halt;
end
end;
write('-any key-');
read(kbd,ch);
write(^M,' ':9,^M);
goto errxit;
end
else if (Pos('*',UseFile) > 0) or (Pos('?',UseFile) > 0) then begin
writeln(xrefver,': error: can''t do wildcards');
goto errxit
end
else begin
Doit;
if fatal_error then goto errxit
end
end
end
end; { ProcessArguments }
(* main is here *)
BEGIN
ProcessArguments;
END.