home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
turbopas
/
tlist11.lbr
/
INCLUDE.PQS
/
include.pas
Wrap
Pascal/Delphi Source File
|
1985-11-08
|
2KB
|
74 lines
PROCEDURE Includes(VAR Line : Line_Type;
VAR Include_file_present : BOOLEAN;
VAR Include_file_name : Filename_Type);
{
Include_file_present is TRUE if an Include compiler directive is in
the line. It also must be flush with the comment bracket to be recognized;
thus, if an include takes the following form, { $I filename.ext..., it will be
neither included during a compilation nor during a listing with this program.
It was lifted and modified from program: LISTER.PAS, supplied by Borland. It
must be called before the line is "processed" so that the string flag
represents a continuing string before the line. I. e., the include directive
is not recognized if it is within a string definition.
}
VAR
Name_start, Name_end : INTEGER;
BEGIN
Ch := '-';
Dummy := POS('{$I', Line);
IF Dummy <> 0 THEN
BEGIN
Name_start := Dummy + 3;
Ch := Line[Name_start];
END
ELSE
BEGIN
Dummy := POS('(*$I', Line);
IF Dummy <> 0 THEN
BEGIN
Name_start := Dummy + 4;
Ch := Line[Name_start];
END
ELSE
BEGIN
Dummy := POS('{$i', Line);
IF Dummy <> 0 THEN
BEGIN
Name_start := Dummy + 3;
Ch := Line[Name_start];
END
ELSE
BEGIN
Dummy := POS('(*$i', Line);
IF Dummy <> 0 THEN
BEGIN
Name_start := Dummy + 4;
Ch := Line[Name_start];
END;
END;
END;
END;
Include_file_present := NOT (Ch IN ['+', '-']);
FOR I := 1 TO Dummy - 1 DO
IF Line[I] = '''' THEN Include_file_present := NOT Include_file_present;
IF Strng THEN Include_file_present := NOT Include_file_present;
IF Include_file_present THEN
BEGIN
{
This section parses for a filename within the line, following the include
directive. It was lifted from program: LISTER.PAS, supplied by Borland.
}
WHILE Line[Name_start] = ' ' DO
Name_start := SUCC(Name_start);
Name_end := Name_start;
WHILE (NOT (Line[Name_end] IN [' ', '}', '*']))
AND ((Name_end - Name_start) <= Filename_Length) DO
Name_end := SUCC(Name_end);
Name_end := PRED(Name_end);
Include_file_name := COPY(Line, Name_start, (Name_end - Name_start + 1));
END;
END;