From 3e62d571663b637dc08d444be9d750657467fd05 Mon Sep 17 00:00:00 2001 From: = <=> Date: Fri, 8 May 2020 17:08:14 +0100 Subject: [PATCH] Commands can be issued as args to the executable --- src/pebblisp.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pebblisp.c b/src/pebblisp.c index 003dc15..8551dc9 100644 --- a/src/pebblisp.c +++ b/src/pebblisp.c @@ -468,17 +468,22 @@ int repl(struct Environment *env) } } -int main(void) +int main(int argc, const char* argv[]) { struct Environment env = defaultEnv(); + if(argc == 2) { + Object r = parseEval(argv[1], &env); + printAndClean(&r); + } else { #ifndef NO_REPL - repl(&env); + repl(&env); #else - Object r = parseEval("(def ad (fn (a) (+ 1 a)))", &env); - printAndClean(&r); - r = parseEval("(map ad (1 2 3))", &env); - //printAndClean(&r); + Object r = parseEval("(def ad (fn (a) (+ 1 a)))", &env); + printAndClean(&r); + r = parseEval("(map ad (1 2 3))", &env); + printAndClean(&r); #endif + } deleteEnv(&env); } #endif