don't try to compile AST types users enter directly at the repl

This commit is contained in:
Alex Shinn 2011-08-28 17:58:50 +09:00
parent 8e3c1986c4
commit 34638780bd
3 changed files with 4 additions and 1 deletions

2
eval.c
View file

@ -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;

View file

@ -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);

2
main.c
View file

@ -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);