}
if(banner) {
printf("DataWorks version %s %s %s\n", dataworks_get_version(), dataworks_get_compile_date(), dataworks_get_platform());
+ printf("Using Yacc: %s\n", dataworks_get_yacc_version());
if(dataworks_get_endian() == 'L') {
printf("This system is little-endian.\n");
} else {
--- /dev/null
+# $Id$
+
+.SUFFIXES: .c .o
+.PHONY: all clean
+
+all: dw.tab.o dw.yy.o
+
+.c.o:
+ $(CC) $(CFLAGS) -fPIC -c -o $@ $<
+
+dw.tab.c: dw.y
+ $(YACC) $(YFLAGS) -o $@ dw.y
+
+dw.yy.c: dw.l
+ $(LEX) $(LFLAGS) -o $@ dw.l
+
+clean:
+ rm -f *.o dw.tab.c dw.tab.h dw.yy.c
--- /dev/null
+/* $Id$ */
+/* --- START LICENSE --- */
+/* -------------------------------------------------------------------------- */
+/* Copyright (c) 2024 Crabware. */
+/* 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 "dw.tab.h"
+#include "grammersym.h"
+#include <string.h>
+extern YYSTYPE yylval;
+%}
+
+%%
+
+["][^"]*["] {
+ yylval.string = strdup(yytext + 1);
+ yylval.string[strlen(yylval.string) - 1] = 0;
+ return (STRING);
+}
+['][^']*['] {
+ yylval.string = strdup(yytext + 1);
+ yylval.string[strlen(yylval.string) - 1] = 0;
+ return (STRING);
+}
+[a-zA-Z0-9_\-]+ {
+ yylval.ident = strdup(yytext);
+ return (IDENTIFIER);
+}
+[\(\),] {
+ return (yytext[0]);
+}
+[ \t\v]* {
+ return (SPACE);
+}
--- /dev/null
+/* $Id$ */
+/* --- START LICENSE --- */
+/* -------------------------------------------------------------------------- */
+/* Copyright (c) 2024 Crabware. */
+/* 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 "grammersym.h"
+#include <stdio.h>
+%}
+
+%token IDENTIFIER STRING SPACE
+%start command
+
+%union {
+ char* string;
+ char* ident;
+}
+
+%%
+
+argument
+ : STRING {
+ printf("%s\n", $<string>1);
+ }
+ ;
+
+single_argument
+ : SPACE argument SPACE
+ | SPACE argument
+ | argument SPACE
+ | argument
+ ;
+
+arguments
+ : single_argument
+ | arguments ',' single_argument
+ ;
+
+command
+ : IDENTIFIER SPACE '(' arguments ')' {
+ printf("%s\n", $<ident>1);
+ }
+ | IDENTIFIER '(' arguments ')' {
+ printf("%s\n", $<ident>1);
+ }
+ ;
+
+%%
+
+#if defined(YYBISON)
+const char* yaccver = "GNU Bison " YYBISON_VERSION;
+#elif defined(YYBYACC)
+#define XSTR(x) #x
+#define STR(x) XSTR(x)
+const char* yaccver = "Berkeley Yacc " STR(YYMAJOR) "." STR(YYMINOR);
+#endif
--- /dev/null
+int yyparse(void);
+int yylex(void);
+int yyerror(const char* msg);
.PHONY: all clean
.SUFFIXES: .c .o
-OBJS = parser.o database.o util.o dataworks.o database_table.o database_db.o database_record.o exec.o
+OBJS = parser.o database.o util.o dataworks.o database_table.o database_db.o database_record.o exec.o ../Grammar/dw.tab.o ../Grammar/dw.yy.o
all: $(LIB_PREFIX)dataworks$(LIB_SUFFIX) $(STATICLIB_PREFIX)dataworks$(STATICLIB_SUFFIX)
#endif
PLATFORM_M " (" PLATFORM_P ")";
+extern const char* yaccver;
+
const char* dataworks_get_version(void) { return dataworks_version; }
+const char* dataworks_get_yacc_version(void) { return yaccver; }
const char* dataworks_get_compile_date(void) { return dataworks_compile_date; }
const char* dataworks_get_platform(void) { return dataworks_platform; }
char dataworks_get_endian(void) {
}
const char* dataworks_get_copyright(void) { return dataworks_copyright; }
+
+int yywrap() { return 1; }
+
+int yyerror(const char* err) { return 0; }
+
bool dataworks_get_if_supported(void) {
#ifdef SUPPORTED
return true;
*/
const char* dataworks_get_version(void);
+/**
+ * @~english
+ * @brief Get the version of Yacc used by DataWorks
+ * @return Yacc version of DataWorks
+ *
+ */
+const char* dataworks_get_yacc_version(void);
+
/**
* @~english
* @brief Get the compilation date of DataWorks
CC = cc
SHCC = cc
AR = ar
+YACC = yacc
+LEX = lex
AR_ARGS = rcs \$$@
RANLIB = ranlib
WINDRES = windres
CFLAGS = -g -std=c99 -D_DEFAULT_SOURCE
LDFLAGS = -L`pwd`/Library
+YFLAGS = -d
+LFLAGS =
LIBS =
LIB_PREFIX = lib
LIB_SUFFIX = .so
PLATFORM_M = `uname -m`
PLATFORM_P = `uname -p | sed -E "s/[ \\(\\)]/-/g"`
LINK_LIB = ../Library/$(STATICLIB_PREFIX)dataworks$(STATICLIB_SUFFIX)
+
+COMPILE_FLAGS = CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" LIB_PREFIX="$(LIB_PREFIX)" LIB_SUFFIX="$(LIB_SUFFIX)" EXEC_SUFFIX="$(EXEC_SUFFIX)" PLATFORM_M="$(PLATFORM_M)" PLATFORM_P="$(PLATFORM_P)" STATICLIB_PREFIX="$(STATICLIB_PREFIX)" STATICLIB_SUFFIX="$(STATICLIB_SUFFIX)" AR="$(AR)" RANLIB="$(RANLIB)" SHCC="$(SHCC)" LINK_LIB="$(LINK_LIB)" AR_ARGS="$(AR_ARGS)" WINDRES="$(WINDRES)" YACC="$(YACC)" LEX="$(LEX)" LFLAGS="$(LFLAGS)" YFLAGS="$(YFLAGS)"
# $Id$
-COMPILE_FLAGS = CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" LIB_PREFIX="$(LIB_PREFIX)" LIB_SUFFIX="$(LIB_SUFFIX)" EXEC_SUFFIX="$(EXEC_SUFFIX)" PLATFORM_M="$(PLATFORM_M)" PLATFORM_P="$(PLATFORM_P)" STATICLIB_PREFIX="$(STATICLIB_PREFIX)" STATICLIB_SUFFIX="$(STATICLIB_SUFFIX)" AR="$(AR)" RANLIB="$(RANLIB)" SHCC="$(SHCC)" LINK_LIB="$(LINK_LIB)" AR_ARGS="$(AR_ARGS)" WINDRES="$(WINDRES)"
+.PHONY: all no-doc replace format clean ./Library ./Client ./Document ./Grammar archive archive-prepare archive-cleanup archive-targz archive-zip dosbox prepare-dosbox dosbox-x cleanup-dosbox
-.PHONY: all no-doc replace format clean ./Library ./Client ./Document archive archive-prepare archive-cleanup archive-targz archive-zip dosbox prepare-dosbox dosbox-x cleanup-dosbox
+all: ./Grammar ./Library ./Client ./Document
-all: ./Library ./Client ./Document
+no-doc: ./Grammar ./Library ./Client
-no-doc: ./Library ./Client
+./Grammar::
+ $(MAKE) -C $@ $(COMPILE_FLAGS)
-./Library::
+./Library:: ./Grammar
$(MAKE) -C $@ $(COMPILE_FLAGS)
./Client:: ./Library
FILES = `find . -name "*.c" -or -name "*.h"`
replace:
- for i in $(FILES); do \
+ for i in $(FILES) ./Grammar/dw.y ./Grammar/dw.l; do \
echo -n "$$i ... "; \
perl replace.pl < $$i > $$i.new; \
mv $$i.new $$i; \
clean:
rm -f *.zip *.tar.gz
+ $(MAKE) -C ./Grammar clean $(COMPILE_FLAGS)
$(MAKE) -C ./Library clean $(COMPILE_FLAGS)
$(MAKE) -C ./Client clean $(COMPILE_FLAGS)
$(MAKE) -C ./Document clean $(COMPILE_FLAGS)