-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.pl
More file actions
33 lines (28 loc) · 750 Bytes
/
Copy pathmain.pl
File metadata and controls
33 lines (28 loc) · 750 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
:- use_module(parser).
:- use_module(typing).
:- use_module(eval).
initial_env([(`i`, int(1)),
(`ii`, int(2)),
(`iii`, int(3)),
(`iv`, int(4)),
(`v`, int(5)),
(`x`, int(10))]).
initial_tyenv([(`i`, ([], int)),
(`ii`, ([], int)),
(`iii`, ([], int)),
(`iv`, ([], int)),
(`v`, ([], int)),
(`x`, ([], int))]).
main(Input, Output, T) :-
initial_env(E),
initial_tyenv(TE),
parser(Input, Ast),
infer(TE, Ast, T),
eval(E, Ast, Output).
repl :- repeat, read(X), repl_sub(X), !.
repl_sub(X) :- X == end_of_file, !.
repl_sub(X) :-
main(X, E, T),
write(E), nl,
write(T), nl,
fail.