From: nishi Date: Fri, 26 Apr 2024 05:19:13 +0000 (+0000) Subject: better X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=0f8066ab31e8bc3d9c3214d444253e0ad23f1dd5;p=serenade.git better git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@44 0f02c867-ac3d-714e-8a88-971ba1f6efcf --- diff --git a/Serenade/main.c b/Serenade/main.c index c114a05..9db6bc0 100644 --- a/Serenade/main.c +++ b/Serenade/main.c @@ -41,6 +41,8 @@ #include #include +extern bool is_repl; + int main(int argc, char** argv) { int i; bool loaded = false; @@ -81,6 +83,7 @@ int main(int argc, char** argv) { } #ifdef HAS_REPL_SUPPORT if(!loaded) { + is_repl = true; printf("Welcome to Serenade LISP %s\n", SERENADE_VERSION); printf("Support: %s\n", SUPPORT); printf("Parser stack size: %d\n", PARSER_STACK_SIZE); diff --git a/Serenade/run.c b/Serenade/run.c index 8cb5af2..18f52c4 100644 --- a/Serenade/run.c +++ b/Serenade/run.c @@ -30,6 +30,7 @@ #include "run.h" +#include "serenade.h" #include "util.h" #include @@ -53,6 +54,12 @@ struct sn_generic* _sn_run(struct sn_interpreter* sn, struct sn_generic* gen) { free(r); return NULL; } else { + if(strcmp(op->name, "serenade-version") == 0) { + r->type = SN_TYPE_STRING; + r->string = sn_strdup(SERENADE_VERSION); + r->string_length = strlen(r->string); + return r; + } bool called = false; int j; for(j = 0; gen->tree->args[j]; j++) @@ -122,8 +129,14 @@ struct sn_generic* _sn_run(struct sn_interpreter* sn, struct sn_generic* gen) { return NULL; } +bool is_repl = false; + int sn_run(struct sn_interpreter* sn, struct sn_generic* gen) { struct sn_generic* rgen = _sn_run(sn, gen); if(rgen == NULL) return 1; + if(is_repl) { + sn_print_to(stdout, rgen); + printf("\n"); + } return 0; }