From 34638780bdd4116f508af70b6b3881df39f52ec7 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 28 Aug 2011 17:58:50 +0900 Subject: [PATCH] don't try to compile AST types users enter directly at the repl --- eval.c | 2 +- include/chibi/eval.h | 1 + main.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/eval.c b/eval.c index f9538a9b..e1380da4 100644 --- a/eval.c +++ b/eval.c @@ -354,7 +354,7 @@ static sexp sexp_make_cnd (sexp ctx, sexp test, sexp pass, sexp fail) { return res; } -static sexp sexp_make_lit (sexp ctx, sexp value) { +sexp sexp_make_lit (sexp ctx, sexp value) { sexp res = sexp_alloc_type(ctx, lit, SEXP_LIT); sexp_lit_value(res) = value; return res; diff --git a/include/chibi/eval.h b/include/chibi/eval.h index 7e531843..d1cd61f9 100644 --- a/include/chibi/eval.h +++ b/include/chibi/eval.h @@ -170,6 +170,7 @@ SEXP_API sexp sexp_env_cell (sexp env, sexp sym, int localp); SEXP_API sexp sexp_env_ref (sexp env, sexp sym, sexp dflt); SEXP_API sexp sexp_parameter_ref (sexp ctx, sexp param); SEXP_API void sexp_warn_undefs (sexp ctx, sexp from, sexp to); +SEXP_API sexp sexp_make_lit (sexp ctx, sexp value); SEXP_API sexp sexp_make_opcode (sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp, sexp_proc1); SEXP_API sexp sexp_make_procedure_op (sexp ctx sexp_api_params(self, n), sexp flags, sexp num_args, sexp bc, sexp vars); SEXP_API sexp sexp_make_foreign (sexp ctx, const char *name, int num_args, int flags, sexp_proc1 f, sexp data); diff --git a/main.c b/main.c index 84cabaec..0db1cf8d 100644 --- a/main.c +++ b/main.c @@ -45,6 +45,8 @@ static void repl (sexp ctx, sexp env) { } else { tmp = sexp_env_bindings(env); sexp_context_top(ctx) = 0; + if (!(sexp_idp(obj)||sexp_pairp(obj))) + obj = sexp_make_lit(ctx, obj); res = sexp_eval(ctx, obj, env); if (sexp_exceptionp(res)) { sexp_print_exception(ctx, res, err);