Last change
on this file was 16, checked in by george, 16 years ago |
- Přidáno: Další pokusný projekt překladače.
|
File size:
1.2 KB
|
Line | |
---|
1 | unit UCompiler;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | const
|
---|
6 | ReservedWords: array[0..18] of string = ('DIV', 'MOD', 'OR', 'OF', 'THEN', 'DO',
|
---|
7 | 'END', 'ELSE', 'ELSIF', 'IF', 'WHILE', 'ARRAY', 'RECORD', 'CONST', 'TYPE',
|
---|
8 | 'VAR', 'PROCEDURE', 'BEGIN', 'MODULE');
|
---|
9 |
|
---|
10 | type
|
---|
11 | TScannerElementType = (etReservedWord, etString, etIdentifier, erNumber);
|
---|
12 |
|
---|
13 | TScannerElement = record
|
---|
14 | ElementType: TScannerElementType;
|
---|
15 | Text: string;
|
---|
16 | end;
|
---|
17 |
|
---|
18 | TScannerElementList = array of TScannerElement;
|
---|
19 |
|
---|
20 | TScanner = record
|
---|
21 | function Process(Text: string): TScannerElementList;
|
---|
22 | end;
|
---|
23 |
|
---|
24 | TCompiler = record
|
---|
25 | private
|
---|
26 | procedure ExpectBlock;
|
---|
27 | procedure ExpectReservedWord;
|
---|
28 | procedure ExpectCommand;
|
---|
29 | public
|
---|
30 | SourceCode: string;
|
---|
31 | procedure Compile;
|
---|
32 | end;
|
---|
33 |
|
---|
34 | var
|
---|
35 | Compiler: TCompiler;
|
---|
36 |
|
---|
37 | implementation
|
---|
38 |
|
---|
39 | procedure TCompiler.Compile;
|
---|
40 | begin
|
---|
41 | ExpectBlock;
|
---|
42 | end;
|
---|
43 |
|
---|
44 | procedure TCompiler.ExpectBlock;
|
---|
45 | begin
|
---|
46 | // ExpectReservedWord('begin');
|
---|
47 | ExpectCommand;
|
---|
48 | // ExpectReservedWord('end');
|
---|
49 | end;
|
---|
50 |
|
---|
51 | procedure TCompiler.ExpectCommand;
|
---|
52 | begin
|
---|
53 |
|
---|
54 | end;
|
---|
55 |
|
---|
56 | procedure TCompiler.ExpectReservedWord;
|
---|
57 | begin
|
---|
58 |
|
---|
59 | end;
|
---|
60 |
|
---|
61 | { TScanner }
|
---|
62 |
|
---|
63 | function TScanner.Process(Text: string): TScannerElementList;
|
---|
64 | begin
|
---|
65 |
|
---|
66 | end;
|
---|
67 |
|
---|
68 | end.
|
---|
Note:
See
TracBrowser
for help on using the repository browser.