matlab: add metadata and atom support.
[jackhill/mal.git] / matlab / step1_read_print.m
1 function step1_read_print(varargin), main(varargin), end
2
3 % read
4 function ret = READ(str)
5 ret = reader.read_str(str);
6 end
7
8 % eval
9 function ret = EVAL(ast, env)
10 ret = ast;
11 end
12
13 % print
14 function ret = PRINT(ast)
15 ret = printer.pr_str(ast, true);
16 end
17
18 % REPL
19 function ret = rep(str, env)
20 ret = PRINT(EVAL(READ(str), env));
21 end
22
23 function main(args)
24 %cleanObj = onCleanup(@() disp('*** here1 ***'));
25 while (true)
26 line = input('user> ', 's');
27 if strcmp(strtrim(line),''), continue, end
28 try
29 fprintf('%s\n', rep(line, ''));
30 catch err
31 fprintf('Error: %s\n', err.message);
32 fprintf('%s\n', getReport(err, 'extended'));
33 end
34 end
35 end