home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
turbopas
/
tlist11.lbr
/
PARSER.PQS
/
parser.pas
Wrap
Pascal/Delphi Source File
|
1985-11-08
|
3KB
|
68 lines
PROCEDURE Replace_Symbols_In_Line(VAR Line : Line_Type);
{
This routine parses the given line for "legal" symbols composed of alphanumeric
characters or underlines only; as it finds each symbol, it determines if the
symbol is one of the three kinds in the symbol tables: reserved words, standard
identifiers, or dedicated identifiers. When a tabulated symbol is found, it is
replaced with its accented version; the accent depends on the type of symbol.
}
VAR
X : CHAR;
BEGIN
I := 1;
Symbol[0] := CHR(0); {Set Symbol to a null string}
WHILE I <= LENGTH(Line) DO
BEGIN
X := Line[I];
IF ((X = '{') OR ((X = '(') AND (I < LENGTH(Line)) AND
(Line[I + 1] = '*'))) AND (NOT Strng) THEN Comment := TRUE;
IF ((X = '}') OR ((X = ')') AND (I > 1) AND
(Line[I - 1] = '*'))) AND (NOT Strng) THEN Comment := FALSE;
IF (X = '''') AND (NOT Comment) THEN Strng := NOT Strng;
IF (Page_number >= Starting_page_number) AND NOT (Comment OR Strng) THEN
BEGIN
IF (X >= 'a') AND (X <= 'z') THEN X := UPCASE(Line[I]);
IF ((X >= 'A') AND (X <= 'Z'))
OR (X = '_')
OR ((X >= '0') AND (X <= '9')) THEN
Symbol := CONCAT(Symbol, X)
ELSE
IF LENGTH(Symbol) <> 0 THEN
BEGIN
Search_Replace(Symbol, Reserved_Word_Accent_begin,
Reserved_Word_Accent_end, Reserved_Word_HT, Reserved_Word_CT,
Reserved_Word_ST, Res_Word_Hsh_size, Reserved_Word_Upper_Case, Line,
I);
Search_Replace(Symbol, Standard_Identifier_Accent_begin,
Standard_Identifier_Accent_end, Standard_Identifier_HT,
Standard_Identifier_CT, Standard_Identifier_ST, Stan_Ident_Hsh_size,
Standard_Identifier_Upper_Case, Line, I);
Search_Replace(Symbol, Dedicated_Identifier_Accent_begin,
Dedicated_Identifier_Accent_end, Dedicated_Identifier_HT,
Dedicated_Identifier_CT, Dedicated_Identifier_ST,
Ded_Ident_Hsh_size, Dedicated_Identifier_Upper_Case, Line, I);
Symbol[0] := CHR(0);
END;
END
ELSE
Symbol[0] := CHR(0);
I := I + 1;
END;
IF LENGTH(Symbol) <> 0 THEN
BEGIN
Search_Replace(Symbol, Reserved_Word_Accent_begin,
Reserved_Word_Accent_end, Reserved_Word_HT, Reserved_Word_CT,
Reserved_Word_ST, Res_Word_Hsh_size, Reserved_Word_Upper_Case, Line, I);
Search_Replace(Symbol, Standard_Identifier_Accent_begin,
Standard_Identifier_Accent_end, Standard_Identifier_HT,
Standard_Identifier_CT, Standard_Identifier_ST, Stan_Ident_Hsh_size,
Standard_Identifier_Upper_Case, Line, I);
Search_Replace(Symbol, Dedicated_Identifier_Accent_begin,
Dedicated_Identifier_Accent_end, Dedicated_Identifier_HT,
Dedicated_Identifier_CT, Dedicated_Identifier_ST,
Ded_Ident_Hsh_size, Dedicated_Identifier_Upper_Case, Line, I);
END;
END;