home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turbo Toolbox
/
Turbo_Toolbox.iso
/
dtx9203
/
naxos
/
source
/
syscomp.pas
< prev
Wrap
Pascal/Delphi Source File
|
1992-02-08
|
4KB
|
137 lines
{$A+,B-,D-,E-,F-,G-,I-,L-,N-,O-,R-,S+,V+,X-}
{$M 16384,0,655360}
(*--------------------------------------------------------*)
(* SYSCOMP.PAS *)
(* NAXOS Systemdictionary Compiler Version 2.0 *)
(* (C) 1992 DMV-Verlag & A. Zissis *)
(* Compiler: Turbo Pascal 6.0 *)
(*--------------------------------------------------------*)
PROGRAM SysComp;
CONST
MaxName = 12; { Namensgröße }
TYPE
PDEps = POINTER;
pSymtab = ^Symtab;
Symtab = RECORD
Name : STRING[12];
Typ : BYTE;
QFA : WORD;
Par0,
Par1,
Par2,
Par3 : WORD;
RLink,
LLink: pSymtab;
END;
WortTyp = STRING[16];
VAR
Ptr,
Root : pSymtab;
D : pSymtab; { Wörterbuch }
InFile : TEXT;
OutFile : FILE;
Wort : STRING[12];
Code : BYTE;
by : WORD;
okr,okl : BOOLEAN;
PROCEDURE Error(n: BYTE);
BEGIN
CASE n OF
1 : WriteLn('Zuviele Definitionen');
2 : WriteLn('Dateiname fehlt');
3 : WriteLn('Fehler beim Öffnen des Quellfiles');
4 : WriteLn('Fehler beim Öffnen des Zielfiles');
5 : WriteLn('Fehler im Quelltext (leere Zeile)');
END;
Halt(0);
END;
PROCEDURE TueName(Name: STRING; Typ: BYTE);
VAR
p1, p2: pSymtab;
{ Name holen und überprüfen, Header bauen }
BEGIN
Write('▒');
IF Name[0] > Chr(MaxName) THEN Name[0] := Chr(MaxName);
New(D);
D^.Name := Name;
D^.LLink := NIL;
D^.RLink := NIL;
D^.QFA := 0; { QFAs }
D^.Typ := Typ; { TYP }
D^.Par0 := 0; { PAR 0 }
D^.Par1 := 0; { PAR 1 }
D^.Par2 := 0; { PAR 2 }
D^.Par3 := 0; { PAR 3 }
p1 := Root;
REPEAT
p2 := p1;
IF D^.Name > p1^.Name THEN p1 := p1^.RLink
ELSE p1 := p1^.LLink;
UNTIL p1 = NIL;
IF D^.Name > p2^.Name THEN p2^.RLink := D
ELSE p2^.LLink := D;
END;
PROCEDURE Sv(Ptr: pSymtab);
BEGIN
BlockWrite(OutFile,Ptr^, 1);
IF Ptr^.LLink <> NIL THEN Sv(Ptr^.LLink);
IF Ptr^.RLink <> NIL THEN Sv(Ptr^.RLink);
END;
BEGIN
WriteLn('NAXOS Systemdictionary Compiler V2.00');
WriteLn('(C) 1992 DMV-Verlag & A. Zissis');
WriteLn; WriteLn;
IF ParamCount = 0 THEN Error(2);
New(Root);
Root^.RLink := NIL;
Root^.LLink := NIL;
Root^.Name := 'EEEEEEEEEEEE';
Root^.Typ := 254;
IF Pos('.', ParamStr(1))= 0 THEN
Assign(InFile, ParamStr(1) + '.SRC')
ELSE
Assign(InFile, ParamStr(1));
{$I-} Reset(InFile); {$I+}
IF IOResult <> 0 THEN Error(3);
REPEAT
{$I-}
Read(InFile,Wort);
WHILE (Wort[1] = '/') AND (Wort[2] = '/') DO BEGIN
ReadLn(InFile);
Read(Wort);
END;
Read(InFile, Code);
ReadLn(InFile);
{$I+}
IF IOResult <> 0 THEN Error(5);
WHILE Wort[1] = ' ' DO Delete(Wort,1,1);
IF Pos(' ', Wort) <> 0 THEN
Wort[0] := Chr(Pos(' ', Wort) - 1);
TueName(Wort, Code);
UNTIL EoF(InFile);
Close(InFile);
WriteLn; WriteLn;
Assign(OutFile, 'SYSTEM.DIC');
{$I-} ReWrite(OutFile, SizeOf(Root^) - 8); {$I+}
IF IOResult <> 0 THEN Error(4);
Sv(Root);
by := FileSize(OutFile);
Close(OutFile);
WriteLn('SYSTEM.DIC erzeugt ', by,
' Einträge ', by * (SizeOf(Root^) - 8),' Bytes');
END.
(*--------------------------------------------------------*)
(* Ende von SYSCOMP.PAS *)