2015-02-08 05:32:06 +03:00
|
|
|
function step1_read_print(varargin), main(varargin), end
|
|
|
|
|
2015-02-08 06:03:43 +03:00
|
|
|
% read
|
2015-02-08 05:32:06 +03:00
|
|
|
function ret = READ(str)
|
|
|
|
ret = reader.read_str(str);
|
|
|
|
end
|
|
|
|
|
2015-02-08 06:03:43 +03:00
|
|
|
% eval
|
2015-02-08 05:32:06 +03:00
|
|
|
function ret = EVAL(ast, env)
|
|
|
|
ret = ast;
|
|
|
|
end
|
|
|
|
|
2015-02-08 06:03:43 +03:00
|
|
|
% print
|
2015-02-08 05:32:06 +03:00
|
|
|
function ret = PRINT(ast)
|
|
|
|
ret = printer.pr_str(ast, true);
|
|
|
|
end
|
|
|
|
|
2015-02-08 06:03:43 +03:00
|
|
|
% REPL
|
|
|
|
function ret = rep(str, env)
|
|
|
|
ret = PRINT(EVAL(READ(str), env));
|
2015-02-08 05:32:06 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
function main(args)
|
|
|
|
%cleanObj = onCleanup(@() disp('*** here1 ***'));
|
|
|
|
while (true)
|
|
|
|
line = input('user> ', 's');
|
|
|
|
if strcmp(strtrim(line),''), continue, end
|
|
|
|
try
|
2015-02-08 06:03:43 +03:00
|
|
|
fprintf('%s\n', rep(line, ''));
|
2015-02-08 05:32:06 +03:00
|
|
|
catch err
|
|
|
|
fprintf('Error: %s\n', err.message);
|
|
|
|
fprintf('%s\n', getReport(err, 'extended'));
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|