LIBS =
SUFFIX =
+.if "$(PLATFORM)" != ""
+.include "platforms/${PLATFORM}.mk"
+.else
.include "platform.mk"
+.endif
.PHONY: all ./Serenade ./Tool replace format
$(MAKE) -C ./Tool CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" SUFFIX="$(SUFFIX)"
./config.h:
+ if [ ! -e ./Tool/configgen ]; then $(MAKE) ./Tool ; fi
./Tool/configgen $@
./Serenade::
# $Id$
-SERENADE_OBJS = main.o parser.o util.o
+SERENADE_OBJS = main.o parser.o util.o run.o
.PHONY: all clean
.SUFFIXES: .o .c
if(strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-V") == 0) {
printf("Serenade LISP %s\n", SERENADE_VERSION);
printf("Support: %s\n", SUPPORT);
- printf("Stack size: %d\n", STACK_SIZE);
+ printf("Parser stack size: %d\n", PARSER_STACK_SIZE);
return 1;
} else {
fprintf(stderr, "%s: %s: invalid option\n", argv[0], argv[i]);
if(!loaded) {
printf("Welcome to Serenade LISP %s\n", SERENADE_VERSION);
printf("Support: %s\n", SUPPORT);
- printf("Stack size: %d\n", STACK_SIZE);
+ printf("Parser stack size: %d\n", PARSER_STACK_SIZE);
}
return 0;
#else
int i;
int br = 0;
bool dq = false;
- struct sn_generic** gn_stack = malloc(sizeof(*gn_stack) * STACK_SIZE);
- int* index_stack = malloc(sizeof(int) * STACK_SIZE);
+ struct sn_generic** gn_stack = malloc(sizeof(*gn_stack) * PARSER_STACK_SIZE);
+ int* index_stack = malloc(sizeof(int) * PARSER_STACK_SIZE);
char* argbuf = malloc(1);
argbuf[0] = 0;
int argbufmode = SN_TYPE_VOID;
for(i = 0; i < size; i++) {
char c = data[i];
- if(c == '"') {
+ if(c == '\r') {
+ } else if(c == '"') {
dq = !dq;
} else if(dq) {
char cbuf[2] = {c, 0};
}
br--;
} else {
- if(c == ' ') {
+ if(c == ' ' || c == '\n') {
if(strlen(argbuf) > 0) {
push_stack(gn_stack[br - 1], argbuf, argbufmode);
index_stack[br - 1]++;
--- /dev/null
+/* $Id$ */
+/* --- START LICENSE --- */
+/* -------------------------------------------------------------------------- */
+/* Serenade is a Lisp Dialect */
+/* -------------------------------------------------------------------------- */
+/* Copyright (c) 2024 Nishi. */
+/* Redistribution and use in source and binary forms, with or without modific */
+/* ation, are permitted provided that the following conditions are met: */
+/* 1. Redistributions of source code must retain the above copyright noti */
+/* ce, this list of conditions and the following disclaimer. */
+/* 2. Redistributions in binary form must reproduce the above copyright n */
+/* otice, this list of conditions and the following disclaimer in the documen */
+/* tation and/or other materials provided with the distribution. */
+/* 3. Neither the name of the copyright holder nor the names of its contr */
+/* ibutors may be used to endorse or promote products derived from this softw */
+/* are without specific prior written permission. */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS */
+/* " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TH */
+/* E IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPO */
+/* SE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS */
+/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CON */
+/* SEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITU */
+/* TE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPT */
+/* ION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, S */
+/* TRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN AN */
+/* Y WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY */
+/* OF SUCH DAMAGE. */
+/* -------------------------------------------------------------------------- */
+/* --- END LICENSE --- */
+
+#include "run.h"
+
+int sn_run(struct sn_generic* gen) { return 0; }
--- /dev/null
+/* $Id$ */
+/* --- START LICENSE --- */
+/* -------------------------------------------------------------------------- */
+/* Serenade is a Lisp Dialect */
+/* -------------------------------------------------------------------------- */
+/* Copyright (c) 2024 Nishi. */
+/* Redistribution and use in source and binary forms, with or without modific */
+/* ation, are permitted provided that the following conditions are met: */
+/* 1. Redistributions of source code must retain the above copyright noti */
+/* ce, this list of conditions and the following disclaimer. */
+/* 2. Redistributions in binary form must reproduce the above copyright n */
+/* otice, this list of conditions and the following disclaimer in the documen */
+/* tation and/or other materials provided with the distribution. */
+/* 3. Neither the name of the copyright holder nor the names of its contr */
+/* ibutors may be used to endorse or promote products derived from this softw */
+/* are without specific prior written permission. */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS */
+/* " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TH */
+/* E IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPO */
+/* SE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS */
+/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CON */
+/* SEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITU */
+/* TE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPT */
+/* ION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, S */
+/* TRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN AN */
+/* Y WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY */
+/* OF SUCH DAMAGE. */
+/* -------------------------------------------------------------------------- */
+/* --- END LICENSE --- */
+
+#ifndef __SERENADE_RUN_H__
+#define __SERENADE_RUN_H__
+
+#include "parser.h"
+
+int sn_run(struct sn_generic* gen);
+
+#endif
fprintf(stderr, "[%2d]", gen->type);
for(i = 0; i < n; i++) fprintf(stderr, " ");
if(gen->type == SN_TYPE_TREE) {
+ fprintf(stderr, "(Tree)\n");
if(gen->tree->args != NULL) {
for(i = 0; gen->tree->args[i] != NULL; i++) {
_sn_print_generic(gen->tree->args[i], n + 1);
}
} else if(gen->type == SN_TYPE_DOUBLE) {
fprintf(stderr, "%f", gen->number);
+ fprintf(stderr, "\n");
} else if(gen->type == SN_TYPE_STRING || gen->type == SN_TYPE_FUNCTION) {
fwrite(gen->string, 1, gen->string_length, stderr);
+ fprintf(stderr, "\n");
}
- fprintf(stderr, "\n");
}
void sn_print_generic(struct sn_generic* gen) { _sn_print_generic(gen, 0); }
}
}
int stack_size = 1024;
- fprintf(stderr, "[recommended: 1024] Stack size? ");
+ fprintf(stderr, "[recommended: 1024] Parser stack size? ");
fflush(stderr);
scanf("%d", &stack_size);
- fprintf(out, "#define STACK_SIZE %d\n", stack_size);
+ fprintf(out, "#define PARSER_STACK_SIZE %d\n", stack_size);
fprintf(out, "#define SUPPORT \"");
for(n = 0; asks[n * 4] != NULL; n++) {
if(n > 0) fprintf(out, " ");