-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.pas
387 lines (296 loc) · 10.7 KB
/
setup.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
{$I CrossrefPrefixCode.inc} // STD definitions
// Crossref - Pascal Cross reference
// Version 0.01
// January 9, 2021
// Copyright 2021 Paul Robinson
// Licensed under GPL v2
// Setup.pas - Intended to initialize the application
// 2021-12-17
Unit setup;
interface
Uses sysutils, Tables, _SymbolTable;
// Temporary Procedure
Procedure AD(D:UnicodeString);
// General initialization
Procedure Init;
//symbol table related
implementation
Procedure Init;
Var
I: Integer;
T: TokenType;
begin
writeln; writeln;Writeln('** Start **'); writeln;
New(StateTable);
With StateTable^ Do
Begin
Cond:= NoState;
Closer:= '';
WithList := NIL;
WithCount:= 0;
Prev:= NIL;
End;
WithTable := NIL;
For I := 1 to IdentMax do
SymbolTable[I] := Nil;
TopExtension := 2;
Extensions[1] :='pas';
Extensions[2] :='pp';
TopFolder := 1;
FolderTable[1] := UnicodeString(GetCurrentDir);
// name, nickname, type Visible
// one byte (non-numeric) types
AddBaseClass('boolean', 'bool', Booltype); // boolean
AddBaseClass('char', 'char', charType); // 8-bit character
AddBaseClass('ansichar', 'ansc', charType); // alias for char
// Unicode related
AddBaseClass('widechar', 'wchr', wcharType); // 16-bit char
AddBaseClass('unicodestring', 'uni', uniStrType); // unicodeString
// Integer types
AddBaseClass('shortint', 'sby', shortintType); // 8-bit signed integer
AddBaseClass('byte', 'byte', Bytetype); // 8-bit unsigned integer
AddBaseClass('smallint', 'sint', smallintType); // 16-bit signed integer
AddBaseClass('word', 'word', wordType); // 16-bit integer
AddBaseClass('cardinal', 'card', cardinalType); // 32-bit signed integer
AddBaseClass('integer', 'int', intType); // 32-bit unsigned integer
AddBaseClass('longint', 'int', intType); // alias for int
AddBaseClass('long', 'int', intType); // alias for int
AddBaseClass('int64', 'I64', int64Type); // 64-bit int
AddBaseClass('pointer', 'ptr', pointerType); // address
// floating point
AddBaseClass('real', 'real', realtype); // 32-bit real
AddBaseClass('single', 'sng', singleType); // single
AddBaseClass('double', 'dbl', DoubleType); // double
// precision real
AddBaseClass('extended', 'ext', ExtendedType); // 80-bit real
// groupings
AddBaseClass('set', 'set', setType); // set
// Name of enumerated group
AddBaseClass('enumerator group', 'enum', EnumGroup,False);
// Name of member
AddBaseClass('enumerated value', 'valu', EnumType, False);
// array types
AddBaseClass('array', 'arr', ArrayType); // general array
// array of char with length
AddBaseClass('string', 'str', stringType);
AddBaseClass('ansistring', 'anss', AnsStrType);
// structures
AddBaseClass('record', 'rec', RecordType); // record
AddBaseClass('object', 'obj', objectType); // object
AddBaseClass('class', 'cls', ClassType); // class
AddBaseClass('template', 'tmpl', TemplateType); // class
AddBaseClass('file', 'file', FileType); // file
AddBaseClass('text', 'file', FileType); // file of char
// Std functions and procedures
AddStdConst('false', Booltype);
AddStdConst('true', Booltype);
AddStdConst('text', FileType);
AddStdConst('nil', pointerType);
AddStdConst('maxint', intType);
AddStdFunc('abs', realtype);
AddStdFunc('arctan', realtype);
AddStdFunc('chr', charType);
AddStdFunc('cos', realtype);
AddStdFunc('eof', Booltype);
AddStdFunc('eoln', Booltype);
AddStdFunc('exp', realtype);
AddStdFunc('ln', realtype);
AddStdFunc('odd', Booltype);
AddStdFunc('ord', intType);
AddStdFunc('pred', intType);
AddStdFunc('round', realtype);
AddStdFunc('sin', realtype);
AddStdFunc('sqr', realtype);
AddStdFunc('sqrt', realtype);
AddStdFunc('succ', intType);
AddStdFunc('trunc', realtype);
// Initialize keywords
{
KeywordType[DOTOK] := nxstmtDec;
KeywordType[VARTOK] := ElemDec; KeywordState[VARTOK] := invar ;
KeywordType[THENTOK] := nxstmtDec;
KeywordType[TRYTOK] := blockDec KeywordState[TRYTOK] := inTry ;
KeywordType[CASETOK] := BlockDec; KeywordState[CASETOK] := inCase ;
KeywordClose[CASETOK] := ENDTOK;
KeywordType[WITHTOK] := BlockDec; KeywordState[ELSETOK] := inwith ;
KeywordType[ELSETOK] := nxstmtDec;
KeywordType[TYPETOK] := ElemDec; KeywordState[TYPETOK] := intype ;
KeywordClose[BEGINTOK] := BlockDec; KeywordState[BEGINTOK] := inBegin;
KeywordClose[BEGINTOK] := ENDTOK;
KeywordType[UNTILTOK] := closureDec;
KeywordType[WHILETOK] := nxstmtDec;
KeywordType[CONSTTOK] := ElemDec; KeywordState[CONSTTOK] := inConst ;
KeywordType[REPEATTOK] := BlockDec; KeywordState[REPEATTOK] := inRepeat;
KeywordClose[REPEATTOK] := UNTILTOK;
// END (and any closure) does not have to
// say anything; the gentleman calling err
// I mean keyword calling will
// announce when it needs her
KeywordType[ENDTOK] := closureDec;
KeywordType[RECORDTOK] := structDec; KeywordState[RECORDTOK] := inRecord ;
KeywordClose[RECORDTOK]:= ENDTOK;
KeywordType[CLASSTOK] := structDec; KeywordState[CLASSTOK] := inClass ;
KeywordClose[CLASSTOK]:=ENDTOK;
KeywordType[OBJECTTOK] := structDec; KeywordState[OBJECTTOK] := inObject;
KeywordClose[OBJECTTOK]:= ENDTOK;
KeywordType[LIBRARYTOK] := unitLibProgDec;
KeywordState[LIBRARYTOK]:=inLibrary;
KeywordType[UNITTOK] := unitLibProgDec; KeywordState[UNITTOK]:=inUnit;
KeywordType[PROGRAMTOK] := unit:ibProgDec;
KeywordState[PROGRAMTOK]:=inProgram;
KeywordType[FUNCTION] := pfdec; KeywordState[FUNCTION] := inFunction ;
KeywordType[PROCEDURETOK]:= pfdec; KeywordState[PROCEDURETOK]:= inProcedure;
}
AddStdProc('get');
AddStdProc('put');
AddStdProc('reset');
AddStdProc('rewrite');
AddStdProc('read');
AddStdProc('write');
AddStdProc('pack');
AddStdProc('unpack');
AddStdProc('new');
AddStdProc('dispose');
AddStdProc('readln');
AddStdProc('writeln');
AddStdProc('page');
AddStdProc('mark');
AddStdProc('release');
AddStdProc('halt');
AddStdProc('break');
AddStdProc('continue');
AddStdFile('input');
AddStdFile('output');
AddStdFile('stdin');
AddStdFile('stdout');
AddStdFile('stderr');
{
AddKeyWord('as');
AddKeyWord('dispinterface');
AddKeyWord('except');
AddKeyWord('exports');
AddKeyWord('finalization');
AddKeyWord('finally');
AddKeyWord('initialization');
AddKeyWord('inline');
AddKeyWord('is');
AddKeyWord('on');
AddKeyWord('out');
AddKeyWord('property','',GenMod, inProperty);
AddKeyWord('raise');
}
// extended
if Lang_extended then
begin
{
AddKeyWord('and_then','', nxstmtDec );
AddKeyword('export');
AddKeyword('import');
AddKeyword('module','end',unitprogDec, inunit );
AddKeyword('only');
AddKeyword('or_else','', nxstmtDec );
// equiv to e+lse on case stmt
AddKeyword('otherwise', '' , BlockDec, incase );
AddKeyword('protected','',genmod);
AddKeyword('qualified','',genmod);
AddKeyword('restricted','',genmod);
AddKeyword('value');
}
AddStdFunc('pow',Realtype);
end;
if lang_turbo then // turbo pascal
begin
{
AddKeyword('asm','',BlockDec,inIgnore);
AddKeyword('constructor','',pfDec,inConstructor);
AddKeyword('destructor','',pfDec,inDestructor);
AddKeyword('implementation','',impDec,inImplementation);
AddKeyword('in');
AddKeyword('interface','',interDec,inInterface);
AddKeyword('object','end',structdec,inObject);
AddKeyword('operator','',genMod);
AddKeyword('reintroduce');
AddKeyword('self');
AddKeyWord('unit','end',unitprogDec, inunit );
AddKeyword('uses','',usesDec);
}
AddStdUnit('system');
end;
AddStdUnit('system');
if Lang_XD then // XDPascal
begin
{
AddKeyword('implementation','',impDec,inImplementation);
AddKeyword('interface','',interDec,inInterface);
AddKeyWord('unit','end',unitprogDec, inunit );
AddKeyword('uses','',usesDec);
}
AddStdProc('exit');
AddStdProc('halt');
AddStdProc('break');
AddStdProc('continue');
AddStdUnit('system');
end;
if Lang_Borland then // Borland Pascal
begin
AddStdUnit('system');
end;
if Lang_object then // Object Pascal
begin
// these are not reserved words, but it's
// orobably not a good idea to rdefine them
AddStdProc('exit');
AddStdProc('halt');
AddStdProc('break');
AddStdProc('continue');
AddStdUnit('system');
end;
if Lang_Delphi then // Delphi
begin
AddStdUnit('system');
end;
if Lang_FreePascal then
begin
{$I FPC_defs.inc}
AddStdUnit('system');
end;
if Lang_extended then // Extebded Pascal
BEGIN
END;
if lang_turbo then // Turbo Pascal
BEGIN
END;
if Lang_XD then // XDPascal
BEGIN
END;
if Lsng_GNU then // GNU Pascal
BEGIN
END;
IF lang_Stanford then // Stanford Pascal
BEGIN
// I := BComment1;
// whilr
END;
if Lang_Borland then // Borland Pascal
BEGIN
END;
if Lang_object then // Object Pascal
BEGIN
END;
if Lang_Delphi then // Delphi
BEGIN
END;
if Lang_FreePascal then // Ftee Pascal
BEGIN
END;
IF Allow_Control_Chars then // Allow ^A for Control-A
BEGIN
END;
dumpSymbolTable;
end;
{$NOTE AD Procedure is Temporsry}
Procedure AD(D:UnicodeString);
Begin
end;
end.
BEGIN END;