source: branches/Pascal Compiler 2/UCompiler.pas

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 
1unit UCompiler;
2
3interface
4
5const
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
10type
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
34var
35 Compiler: TCompiler;
36
37implementation
38
39procedure TCompiler.Compile;
40begin
41 ExpectBlock;
42end;
43
44procedure TCompiler.ExpectBlock;
45begin
46// ExpectReservedWord('begin');
47 ExpectCommand;
48// ExpectReservedWord('end');
49end;
50
51procedure TCompiler.ExpectCommand;
52begin
53
54end;
55
56procedure TCompiler.ExpectReservedWord;
57begin
58
59end;
60
61{ TScanner }
62
63function TScanner.Process(Text: string): TScannerElementList;
64begin
65
66end;
67
68end.
Note: See TracBrowser for help on using the repository browser.