altos/lisp: use regular read-eval-print loop for make const
[fw/altos] / src / lisp / ao_lisp_make_const.c
index 6f852f9d9a1f15d6c1f148f53c10334c189595de..4fc43e583b6ca50f16d3f48cf264d2a23af9d650 100644 (file)
@@ -33,6 +33,8 @@ struct builtin_func {
 };
 
 struct builtin_func funcs[] = {
+       "eval",         AO_LISP_FUNC_LAMBDA,    builtin_eval,
+       "read",         AO_LISP_FUNC_LAMBDA,    builtin_read,
        "lambda",       AO_LISP_FUNC_NLAMBDA,   builtin_lambda,
        "lexpr",        AO_LISP_FUNC_NLAMBDA,   builtin_lexpr,
        "nlambda",      AO_LISP_FUNC_NLAMBDA,   builtin_nlambda,
@@ -45,6 +47,8 @@ struct builtin_func funcs[] = {
        "set",          AO_LISP_FUNC_LAMBDA,    builtin_set,
        "setq",         AO_LISP_FUNC_MACRO,     builtin_setq,
        "cond",         AO_LISP_FUNC_NLAMBDA,   builtin_cond,
+       "progn",        AO_LISP_FUNC_NLAMBDA,   builtin_progn,
+       "while",        AO_LISP_FUNC_NLAMBDA,   builtin_while,
        "print",        AO_LISP_FUNC_LEXPR,     builtin_print,
        "patom",        AO_LISP_FUNC_LEXPR,     builtin_patom,
        "+",            AO_LISP_FUNC_LEXPR,     builtin_plus,
@@ -101,20 +105,12 @@ main(int argc, char **argv)
        ao_lisp_atom_set(ao_lisp_atom_poly(a),
                         ao_lisp_atom_poly(a));
 
-       for (;;) {
-               sexpr = ao_lisp_read();
-               if (!sexpr)
-                       break;
-               printf ("sexpr: ");
-               ao_lisp_poly_print(sexpr);
-               printf("\n");
-               val = ao_lisp_eval(sexpr);
-               if (ao_lisp_exception)
-                       exit(1);
-               printf("\t");
-               ao_lisp_poly_print(val);
-               printf("\n");
-       }
+       /* end of file value */
+       a = ao_lisp_atom_intern("eof");
+       ao_lisp_atom_set(ao_lisp_atom_poly(a),
+                        ao_lisp_atom_poly(a));
+
+       ao_lisp_read_eval_print();
 
        /* Reduce to referenced values */
        ao_lisp_collect();