|
Last change
on this file was 225, checked in by chronos, 2 years ago |
- Modified: Project renamed to xpascal.
|
|
File size:
771 bytes
|
| Line | |
|---|
| 1 | unit Interpreter;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, Parser, Executor;
|
|---|
| 7 |
|
|---|
| 8 | type
|
|---|
| 9 |
|
|---|
| 10 | { TInterpreter }
|
|---|
| 11 |
|
|---|
| 12 | TInterpreter = class
|
|---|
| 13 | private
|
|---|
| 14 | Parser: TParser;
|
|---|
| 15 | Executor: TExecutor;
|
|---|
| 16 | public
|
|---|
| 17 | Source: string;
|
|---|
| 18 | procedure Compile;
|
|---|
| 19 | procedure Run;
|
|---|
| 20 | constructor Create;
|
|---|
| 21 | destructor Destroy; override;
|
|---|
| 22 | end;
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 | implementation
|
|---|
| 26 |
|
|---|
| 27 | { TInterpreter }
|
|---|
| 28 |
|
|---|
| 29 | procedure TInterpreter.Compile;
|
|---|
| 30 | begin
|
|---|
| 31 | Parser.Source := Source;
|
|---|
| 32 | Parser.Parse;
|
|---|
| 33 | end;
|
|---|
| 34 |
|
|---|
| 35 | procedure TInterpreter.Run;
|
|---|
| 36 | begin
|
|---|
| 37 | Parser.Source := Source;
|
|---|
| 38 | Parser.Parse;
|
|---|
| 39 | Executor.Prog := Parser.Prog;
|
|---|
| 40 | Executor.Run;
|
|---|
| 41 | end;
|
|---|
| 42 |
|
|---|
| 43 | constructor TInterpreter.Create;
|
|---|
| 44 | begin
|
|---|
| 45 | Parser := TParser.Create;
|
|---|
| 46 | Executor := TExecutor.Create;
|
|---|
| 47 | end;
|
|---|
| 48 |
|
|---|
| 49 | destructor TInterpreter.Destroy;
|
|---|
| 50 | begin
|
|---|
| 51 | Executor.Free;
|
|---|
| 52 | Parser.Free;
|
|---|
| 53 | inherited;
|
|---|
| 54 | end;
|
|---|
| 55 |
|
|---|
| 56 | end.
|
|---|
| 57 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.