1 function step2_eval
(varargin), main
(varargin), end
4 function ret
= READ
(str
)
5 ret
= reader.read_str
(str
);
9 function ret
= eval_ast
(ast
, env
)
16 ret.append
(EVAL(ast.
get(i
), env
));
21 ret.append
(EVAL(ast.
get(i
), env
));
24 ret
= types.HashMap
();
28 ret.
set(EVAL(k
, env
), EVAL(ast.
get(k
), env
));
35 function ret
= EVAL(ast
, env
)
36 %fprintf('EVAL: %s\n', printer.pr_str(ast, true));
37 if ~type_utils.list_Q
(ast
)
38 ret
= eval_ast
(ast
, env
);
47 el
= eval_ast
(ast
, env
);
49 args
= el.data
(2:end);
54 function ret
= PRINT(ast
)
55 ret
= printer.pr_str
(ast
, true
);
59 function ret
= rep
(str
, env
)
60 ret
= PRINT(EVAL(READ
(str
), env
));
64 if exist('OCTAVE_VERSION', 'builtin') ~
= 0
67 repl_env
= containers.Map
();
69 repl_env
('+') = @
(a
,b
) a
+b
;
70 repl_env
('-') = @
(a
,b
) a
-b
;
71 repl_env
('*') = @
(a
,b
) a
*b
;
72 repl_env
('/') = @
(a
,b
) floor(a
/b
);
74 %cleanObj = onCleanup(@() disp('*** here1 ***'));
77 line = input('user> ', 's');
81 if strcmp(strtrim
(line),''), continue
, end
83 fprintf('%s\n', rep
(line, repl_env
));
85 fprintf('Error: %s\n', err.message
);
86 type_utils.print_stack
(err
);