Printing
Instead of printing the tree, we now want to print the result of the evaluation. Therefore we need to pass the tree into our eval
function, and print the result we get using printf
and the specifier %li
, which is used for long
type.
We also need to remember to delete the output tree after we are done evaluating it.
long result = eval(r.output);
printf("%li\n", result);
mpc_ast_delete(r.output);
If all of this is successful we should be able to do some basic maths with our new programming language!
Lispy Version 0.0.0.0.3
Press Ctrl+c to Exit
lispy> + 5 6
11
lispy> - (* 10 10) (+ 1 1 1)
97
当前内容版权归 orangeduck 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 orangeduck .