forked from kanaka/mal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstep0_repl.pas
More file actions
47 lines (39 loc) Β· 704 Bytes
/
step0_repl.pas
File metadata and controls
47 lines (39 loc) Β· 704 Bytes
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
program Mal;
{$H+} // Use AnsiString
Uses CMem,
mal_readline;
var
Repl_Env: string = '';
Line : string;
// read
function READ(const Str: string) : string;
begin
READ := Str;
end;
// eval
function EVAL(Ast: string; Env: string) : string;
begin
EVAL := Ast;
end;
// print
function PRINT(Exp: string) : string;
begin
PRINT := Exp;
end;
// repl
function REP(Str: string) : string;
begin
REP := PRINT(EVAL(READ(Str), Repl_Env));
end;
begin
while True do
begin
try
Line := _readline('user> ');
if Line = '' then continue;
WriteLn(REP(Line))
except
On E : MalEOF do Halt(0);
end;
end;
end.