]> Nishi Git Mirror - serenade.git/commitdiff
better
authornishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Fri, 26 Apr 2024 05:19:13 +0000 (05:19 +0000)
committernishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Fri, 26 Apr 2024 05:19:13 +0000 (05:19 +0000)
git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@44 0f02c867-ac3d-714e-8a88-971ba1f6efcf

Serenade/main.c
Serenade/run.c

index c114a05e08d8d7b8310eaa2eb6db4ad97ac7ac38..9db6bc0df855b6cccf89f545d32d0d0b8c2223c4 100644 (file)
@@ -41,6 +41,8 @@
 #include <string.h>
 #include <sys/stat.h>
 
+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);
index 8cb5af2c09fb082fa16b0863de583e13ee22d905..18f52c4e40a82ef4ea61ea85119e759fe32ed6b3 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "run.h"
 
+#include "serenade.h"
 #include "util.h"
 
 #include <stdbool.h>
@@ -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;
 }