altos/lisp: use regular read-eval-print loop for make const
[fw/altos] / src / lisp / ao_lisp_make_const.c
index 501052b91b991a0c4533e86f4c39f9cd1d6f3e4e..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,
@@ -57,20 +61,12 @@ struct builtin_func funcs[] = {
        ">",            AO_LISP_FUNC_LEXPR,     builtin_greater,
        "<=",           AO_LISP_FUNC_LEXPR,     builtin_less_equal,
        ">=",           AO_LISP_FUNC_LEXPR,     builtin_greater_equal,
+       "delay",        AO_LISP_FUNC_LAMBDA,    builtin_delay,
+       "led",          AO_LISP_FUNC_LEXPR,     builtin_led,
 };
 
 #define N_FUNC (sizeof funcs / sizeof funcs[0])
 
-/* Syntactic atoms */
-char *atoms[] = {
-       "lambda",
-       "nlambda",
-       "lexpr",
-       "macro"
-};
-
-#define N_ATOM (sizeof atoms / sizeof atoms[0])
-
 struct ao_lisp_frame   *globals;
 
 static int
@@ -102,10 +98,6 @@ main(int argc, char **argv)
                                 ao_lisp_builtin_poly(b));
        }
 
-       /* atoms for syntax */
-       for (i = 0; i < N_ATOM; i++)
-               (void) ao_lisp_atom_intern(atoms[i]);
-
        /* boolean constants */
        ao_lisp_atom_set(ao_lisp_atom_poly(ao_lisp_atom_intern("nil")),
                         AO_LISP_NIL);
@@ -113,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();