From 3279b5da07a59f6989ab58e2e94c7150e21e3784 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Thu, 24 Oct 2013 14:10:08 -0500 Subject: [PATCH] greg_gc #9: more greg-0.4.6 fixes check that YY_DEBUG is not set by potion.h, only by greg.h freeRules() is not exported, cannot be called yet. forward struct _GREG in syntax(-p5).y use YY_DEBUG instead of DEBUG in syntax(-p5).y --- Makefile | 2 +- core/potion.h | 5 ----- syn/compile.c | 57 ++++++++++++++++++++++++------------------------ syn/greg.c | 58 ++++++++++++++++++++++++------------------------- syn/greg.h | 12 +++++++--- syn/syntax-p5.y | 7 +++--- syn/syntax.y | 5 +++-- 7 files changed, 75 insertions(+), 71 deletions(-) diff --git a/Makefile b/Makefile index 08a11df..f94879b 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ SRC = core/asm.c core/ast.c core/compile.c core/contrib.c core/gc.c core/internal.c core/lick.c core/mt19937ar.c core/number.c core/objmodel.c core/primitive.c core/string.c core/table.c core/vm.c PLIBS = readline buffile aio PLIBS_SRC = lib/aio.c lib/buffile.c lib/readline/readline.c lib/readline/linenoise.c -GREGCFLAGS = -O3 -DNDEBUG -Wno-unused-value +GREGCFLAGS = -O3 -Wno-unused-value # bootstrap config.inc with make -f config.mak include config.inc diff --git a/core/potion.h b/core/potion.h index fa2069c..537cf07 100644 --- a/core/potion.h +++ b/core/potion.h @@ -69,11 +69,6 @@ and optionally args, statically typed via signature strings. #else # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS #endif -#ifdef DEBUG -# ifndef YY_DEBUG -# define YY_DEBUG -# endif -#endif // // types diff --git a/syn/compile.c b/syn/compile.c index 8a64f86..4a21365 100644 --- a/syn/compile.c +++ b/syn/compile.c @@ -478,6 +478,34 @@ static char *preamble= "\ #ifndef YY_END\n\ #define YY_END ( G->end= G->pos, 1)\n\ #endif\n\ +#ifndef YYSTYPE\n\ +#define YYSTYPE int\n\ +#endif\n\ +#ifndef YY_XTYPE\n\ +#define YY_XTYPE void *\n\ +#endif\n\ +#ifndef YY_XVAR\n\ +#define YY_XVAR yyxvar\n\ +#endif\n\ +\n\ +#ifndef YY_STACK_SIZE\n\ +#define YY_STACK_SIZE 1024\n\ +#endif\n\ +\n\ +#ifndef YY_BUFFER_START_SIZE\n\ +#define YY_BUFFER_START_SIZE 16384\n\ +#endif\n\ +\n\ +#ifndef YY_PART\n\ +#define yydata G->data\n\ +#define yy G->ss\n\ +#endif\n\ +\n\ +#include \"greg.h\"\n\ +\n\ +#ifndef YY_INITDATA\n\ +#define YY_INITDATA\n\ +#endif\n\ #ifdef YY_DEBUG\n\ # define yydebug G->debug\n\ # ifndef YYDEBUG_PARSE\n\ @@ -523,34 +551,7 @@ static char *preamble= "\ # define yyprintfvokrule(rule)\n\ # define yyprintfvfailrule(rule)\n\ #endif\n\ -#ifndef YYSTYPE\n\ -#define YYSTYPE int\n\ -#endif\n\ -#ifndef YY_XTYPE\n\ -#define YY_XTYPE void *\n\ -#endif\n\ -#ifndef YY_XVAR\n\ -#define YY_XVAR yyxvar\n\ -#endif\n\ \n\ -#ifndef YY_STACK_SIZE\n\ -#define YY_STACK_SIZE 1024\n\ -#endif\n\ -\n\ -#ifndef YY_BUFFER_START_SIZE\n\ -#define YY_BUFFER_START_SIZE 16384\n\ -#endif\n\ -\n\ -#ifndef YY_PART\n\ -#define yydata G->data\n\ -#define yy G->ss\n\ -#endif\n\ -\n\ -#include \"greg.h\"\n\ -\n\ -#ifndef YY_INITDATA\n\ -#define YY_INITDATA\n\ -#endif\n\ typedef void (*yyaction)(struct _GREG *G, char *yytext, int yyleng, struct _yythunk *thunkpos, YY_XTYPE YY_XVAR);\n\ typedef struct _yythunk { int begin, end; yyaction action; const char *name; struct _yythunk *next; } yythunk;\n\ \n\ @@ -866,7 +867,7 @@ YY_PARSE(void) YY_NAME(parse_free)(GREG *G)\n\ {\n\ #ifndef GREG_GC\n\ YY_NAME(deinit)(G);\n\ - freeRules();\n\ + //freeRules(); //not yet exported from tree.c\n\ YY_FREE(G);\n\ #endif\n\ \n\ diff --git a/syn/greg.c b/syn/greg.c index fcce459..bd2cb2b 100644 --- a/syn/greg.c +++ b/syn/greg.c @@ -69,6 +69,34 @@ void makeTrailer(struct _GREG *G, char *text); #ifndef YY_END #define YY_END ( G->end= G->pos, 1) #endif +#ifndef YYSTYPE +#define YYSTYPE int +#endif +#ifndef YY_XTYPE +#define YY_XTYPE void * +#endif +#ifndef YY_XVAR +#define YY_XVAR yyxvar +#endif + +#ifndef YY_STACK_SIZE +#define YY_STACK_SIZE 1024 +#endif + +#ifndef YY_BUFFER_START_SIZE +#define YY_BUFFER_START_SIZE 16384 +#endif + +#ifndef YY_PART +#define yydata G->data +#define yy G->ss +#endif + +#include "greg.h" + +#ifndef YY_INITDATA +#define YY_INITDATA +#endif #ifdef YY_DEBUG # define yydebug G->debug # ifndef YYDEBUG_PARSE @@ -114,34 +142,6 @@ void makeTrailer(struct _GREG *G, char *text); # define yyprintfvokrule(rule) # define yyprintfvfailrule(rule) #endif -#ifndef YYSTYPE -#define YYSTYPE int -#endif -#ifndef YY_XTYPE -#define YY_XTYPE void * -#endif -#ifndef YY_XVAR -#define YY_XVAR yyxvar -#endif - -#ifndef YY_STACK_SIZE -#define YY_STACK_SIZE 1024 -#endif - -#ifndef YY_BUFFER_START_SIZE -#define YY_BUFFER_START_SIZE 16384 -#endif - -#ifndef YY_PART -#define yydata G->data -#define yy G->ss -#endif - -#include "greg.h" - -#ifndef YY_INITDATA -#define YY_INITDATA -#endif typedef void (*yyaction)(struct _GREG *G, char *yytext, int yyleng, struct _yythunk *thunkpos, YY_XTYPE YY_XVAR); typedef struct _yythunk { int begin, end; yyaction action; const char *name; struct _yythunk *next; } yythunk; @@ -1611,7 +1611,7 @@ YY_PARSE(void) YY_NAME(parse_free)(GREG *G) { #ifndef GREG_GC YY_NAME(deinit)(G); - freeRules(); + //freeRules(); //not yet exported from tree.c YY_FREE(G); #endif diff --git a/syn/greg.h b/syn/greg.h index d2baae4..a61cea2 100644 --- a/syn/greg.h +++ b/syn/greg.h @@ -29,11 +29,17 @@ #include "p2.h" #include "internal.h" +#ifdef DEBUG +# ifndef YY_DEBUG +# define YY_DEBUG +# endif +#endif + #if 1 -# include -# define STRUCT_OFFSET(s,m) offsetof(s,m) +# include +# define STRUCT_OFFSET(s,m) offsetof(s,m) #else -# define STRUCT_OFFSET(s,m) (size_t)(&(((s *)0)->m)) +# define STRUCT_OFFSET(s,m) (size_t)(&(((s *)0)->m)) #endif // offset from ptr->data back to ptr diff --git a/syn/syntax-p5.y b/syn/syntax-p5.y index 52ea8d3..aac04a6 100644 --- a/syn/syntax-p5.y +++ b/syn/syntax-p5.y @@ -65,6 +65,7 @@ #define SRC_TPL2(x,y) P->source = PN_PUSH(PN_PUSH(DEF_PSRC, (x)), (y)) #define SRC_TPL3(x,y,z) P->source = PN_PUSH(PN_PUSH(PN_PUSH(DEF_PSRC, (x)), (y)), (z)) +struct _GREG; static PN yylastline(struct _GREG *G, int pos); %} @@ -563,7 +564,7 @@ PN p2_parse(Potion *P, PN code, char *filename) { P->input = code; P->source = PN_NIL; P->pbuf = potion_asm_new(P); -#ifdef DEBUG +#ifdef YY_DEBUG yydebug = P->flags; #endif @@ -596,7 +597,7 @@ PN potion_sig(Potion *P, char *fmt) { P->input = potion_byte_str(P, fmt); P->source = out = PN_TUP0(); P->pbuf = NULL; -#ifdef DEBUG +#ifdef YY_DEBUG yydebug = P->flags; #endif @@ -624,7 +625,7 @@ PN p2_sig(Potion *P, char *fmt) { P->input = potion_byte_str(P, fmt); P->source = out = PN_TUP0(); P->pbuf = NULL; -#ifdef DEBUG +#ifdef YY_DEBUG yydebug = P->flags; #endif diff --git a/syn/syntax.y b/syn/syntax.y index f3e9b4e..ed3722f 100644 --- a/syn/syntax.y +++ b/syn/syntax.y @@ -55,6 +55,7 @@ #define SRC_TPL2(x,y) P->source = PN_PUSH(PN_PUSH(P->source, x), y) #define SRC_TPL3(x,y,z) P->source = PN_PUSH(PN_PUSH(PN_PUSH(P->source, x), y), z) +struct _GREG; static PN yylastline(struct _GREG *G, int pos); %} @@ -371,7 +372,7 @@ PN potion_parse(Potion *P, PN code, char *filename) { P->input = code; P->source = PN_NIL; P->pbuf = potion_asm_new(P); -#ifdef DEBUG +#ifdef YY_DEBUG yydebug = P->flags; #endif @@ -429,7 +430,7 @@ PN potion_sig(Potion *P, char *fmt) { P->input = potion_byte_str(P, fmt); P->source = out = PN_TUP0(); P->pbuf = NULL; -#ifdef DEBUG +#ifdef YY_DEBUG yydebug = P->flags; #endif