Skip to content

Commit

Permalink
greg_gc #9: more greg-0.4.6 fixes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Reini Urban committed Oct 24, 2013
1 parent 0a523f4 commit 3279b5d
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 71 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions core/potion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 29 additions & 28 deletions syn/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down Expand Up @@ -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\
Expand Down Expand Up @@ -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\
Expand Down
58 changes: 29 additions & 29 deletions syn/greg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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

Expand Down
12 changes: 9 additions & 3 deletions syn/greg.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@
#include "p2.h"
#include "internal.h"

#ifdef DEBUG
# ifndef YY_DEBUG
# define YY_DEBUG
# endif
#endif

#if 1
# include <stddef.h>
# define STRUCT_OFFSET(s,m) offsetof(s,m)
# include <stddef.h>
# 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
Expand Down
7 changes: 4 additions & 3 deletions syn/syntax-p5.y
Original file line number Diff line number Diff line change
Expand Up @@ -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);
%}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions syn/syntax.y
Original file line number Diff line number Diff line change
Expand Up @@ -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);
%}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3279b5d

Please sign in to comment.