From 0fe23be2e5dbdf3815357addbd7eb684ddc15473 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 29 Apr 2012 00:00:00 +0200 Subject: [PATCH] imported peg-0.1.9 --- Makefile | 17 +- README.md | 2 + compile.c | 287 ++++++----- examples/Makefile | 10 +- examples/basic.leg | 5 +- examples/localctx.c | 13 + examples/localctx.ref | 10 + leg.c | 1121 +++++++++++++++++++++++------------------ leg.leg | 16 +- peg.1 | 50 +- peg.c | 16 +- peg.peg-c | 977 +++++++++++++++++++---------------- version.h | 2 +- 13 files changed, 1431 insertions(+), 1095 deletions(-) create mode 100644 examples/localctx.c create mode 100644 examples/localctx.ref diff --git a/Makefile b/Makefile index bc45e64..c10fbda 100644 --- a/Makefile +++ b/Makefile @@ -30,19 +30,26 @@ uninstall : .FORCE peg.o : peg.c peg.peg-c -%.peg-c : %.peg -# ./peg -o $@ $< +%.peg-c : %.peg compile.c + ./peg -o $@ $< leg.o : leg.c -leg.c : leg.leg -# ./leg -o $@ $< +leg.c : leg.leg compile.c + ./leg -o $@ $< -check : peg .FORCE +check : check-peg check-leg + +check-peg : peg .FORCE ./peg < peg.peg > peg.out diff peg.peg-c peg.out rm peg.out +check-leg : leg .FORCE + ./leg < leg.leg > leg.out + diff leg.c leg.out + rm leg.out + test examples : .FORCE $(SHELL) -ec '(cd examples; $(MAKE))' diff --git a/README.md b/README.md index 884c32d..fc1a4d6 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ distribute them any way you like. ## Version history +* **0.1.9** ([zip](peg/zipball/0.1.9), [tar.gz](peg/tarball/0.1.9)) — 2012-04-29 +Move global state into a structure to facilitate reentrant and thread-safe parsers (thanks to Dmitry Lipovoi). * **0.1.8** ([zip](peg/zipball/0.1.8), [tar.gz](peg/tarball/0.1.8)) — 2012-03-29 Allow nested, matched braces within actions. * **0.1.7** ([zip](peg/zipball/0.1.7), [tar.gz](peg/tarball/0.1.7)) — 2011-11-25 diff --git a/compile.c b/compile.c index 7c1c755..74506b7 100644 --- a/compile.c +++ b/compile.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2007 by Ian Piumarta +/* Copyright (c) 2007, 2012 by Ian Piumarta * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -13,7 +13,7 @@ * * THE SOFTWARE IS PROVIDED 'AS IS'. USE ENTIRELY AT YOUR OWN RISK. * - * Last edited: 2011-11-25 11:16:57 by piumarta on emilia + * Last edited: 2012-04-29 16:09:36 by piumarta on emilia */ #include @@ -117,8 +117,8 @@ static void begin(void) { fprintf(output, "\n {"); } static void end(void) { fprintf(output, "\n }"); } static void label(int n) { fprintf(output, "\n l%d:;\t", n); } static void jump(int n) { fprintf(output, " goto l%d;", n); } -static void save(int n) { fprintf(output, " int yypos%d= yypos, yythunkpos%d= yythunkpos;", n, n); } -static void restore(int n) { fprintf(output, " yypos= yypos%d; yythunkpos= yythunkpos%d;", n, n); } +static void save(int n) { fprintf(output, " int yypos%d= ctx->pos, yythunkpos%d= ctx->thunkpos;", n, n); } +static void restore(int n) { fprintf(output, " ctx->pos= yypos%d; ctx->thunkpos= yythunkpos%d;", n, n); } static void Node_compile_c_ko(Node *node, int ko) { @@ -131,13 +131,13 @@ static void Node_compile_c_ko(Node *node, int ko) break; case Dot: - fprintf(output, " if (!yymatchDot()) goto l%d;", ko); + fprintf(output, " if (!yymatchDot(ctx)) goto l%d;", ko); break; case Name: - fprintf(output, " if (!yy_%s()) goto l%d;", node->name.rule->rule.name, ko); + fprintf(output, " if (!yy_%s(ctx)) goto l%d;", node->name.rule->rule.name, ko); if (node->name.variable) - fprintf(output, " yyDo(yySet, %d, 0);", node->name.variable->variable.offset); + fprintf(output, " yyDo(ctx, yySet, %d, 0);", node->name.variable->variable.offset); break; case Character: @@ -147,28 +147,28 @@ static void Node_compile_c_ko(Node *node, int ko) if (1 == len) { if ('\'' == node->string.value[0]) - fprintf(output, " if (!yymatchChar('\\'')) goto l%d;", ko); + fprintf(output, " if (!yymatchChar(ctx, '\\'')) goto l%d;", ko); else - fprintf(output, " if (!yymatchChar('%s')) goto l%d;", node->string.value, ko); + fprintf(output, " if (!yymatchChar(ctx, '%s')) goto l%d;", node->string.value, ko); } else if (2 == len && '\\' == node->string.value[0]) - fprintf(output, " if (!yymatchChar('%s')) goto l%d;", node->string.value, ko); + fprintf(output, " if (!yymatchChar(ctx, '%s')) goto l%d;", node->string.value, ko); else - fprintf(output, " if (!yymatchString(\"%s\")) goto l%d;", node->string.value, ko); + fprintf(output, " if (!yymatchString(ctx, \"%s\")) goto l%d;", node->string.value, ko); } break; case Class: - fprintf(output, " if (!yymatchClass((unsigned char *)\"%s\")) goto l%d;", makeCharClass(node->cclass.value), ko); + fprintf(output, " if (!yymatchClass(ctx, (unsigned char *)\"%s\")) goto l%d;", makeCharClass(node->cclass.value), ko); break; case Action: - fprintf(output, " yyDo(yy%s, yybegin, yyend);", node->action.name); + fprintf(output, " yyDo(ctx, yy%s, ctx->begin, ctx->end);", node->action.name); break; case Predicate: - fprintf(output, " yyText(yybegin, yyend); if (!(%s)) goto l%d;", node->action.text, ko); + fprintf(output, " yyText(ctx, ctx->begin, ctx->end); if (!(%s)) goto l%d;", node->action.text, ko); break; case Alternate: @@ -287,14 +287,20 @@ static void defineVariables(Node *node) int count= 0; while (node) { - fprintf(output, "#define %s yyval[%d]\n", node->variable.name, --count); + fprintf(output, "#define %s ctx->val[%d]\n", node->variable.name, --count); node->variable.offset= count; node= node->variable.next; } + fprintf(output, "#define yy ctx->yy\n"); + fprintf(output, "#define yypos ctx->pos\n"); + fprintf(output, "#define yythunkpos ctx->thunkpos\n"); } static void undefineVariables(Node *node) { + fprintf(output, "#undef yythunkpos\n"); + fprintf(output, "#undef yypos\n"); + fprintf(output, "#undef yy\n"); while (node) { fprintf(output, "#undef %s\n", node->variable.name); @@ -319,21 +325,21 @@ static void Rule_compile_c2(Node *node) safe= ((Query == node->rule.expression->type) || (Star == node->rule.expression->type)); - fprintf(output, "\nYY_RULE(int) yy_%s()\n{", node->rule.name); + fprintf(output, "\nYY_RULE(int) yy_%s(yycontext *ctx)\n{", node->rule.name); if (!safe) save(0); if (node->rule.variables) - fprintf(output, " yyDo(yyPush, %d, 0);", countVariables(node->rule.variables)); + fprintf(output, " yyDo(ctx, yyPush, %d, 0);", countVariables(node->rule.variables)); fprintf(output, "\n yyprintf((stderr, \"%%s\\n\", \"%s\"));", node->rule.name); Node_compile_c_ko(node->rule.expression, ko); - fprintf(output, "\n yyprintf((stderr, \" ok %%s @ %%s\\n\", \"%s\", yybuf+yypos));", node->rule.name); + fprintf(output, "\n yyprintf((stderr, \" ok %%s @ %%s\\n\", \"%s\", ctx->buf+ctx->pos));", node->rule.name); if (node->rule.variables) - fprintf(output, " yyDo(yyPop, %d, 0);", countVariables(node->rule.variables)); + fprintf(output, " yyDo(ctx, yyPop, %d, 0);", countVariables(node->rule.variables)); fprintf(output, "\n return 1;"); if (!safe) { label(ko); restore(0); - fprintf(output, "\n yyprintf((stderr, \" fail %%s @ %%s\\n\", \"%s\", yybuf+yypos));", node->rule.name); + fprintf(output, "\n yyprintf((stderr, \" fail %%s @ %%s\\n\", \"%s\", ctx->buf+ctx->pos));", node->rule.name); fprintf(output, "\n return 0;"); } fprintf(output, "\n}"); @@ -350,9 +356,6 @@ static char *header= "\ "; static char *preamble= "\ -#ifndef YY_VARIABLE\n\ -#define YY_VARIABLE(T) static T\n\ -#endif\n\ #ifndef YY_LOCAL\n\ #define YY_LOCAL(T) static T\n\ #endif\n\ @@ -380,10 +383,10 @@ static char *preamble= "\ }\n\ #endif\n\ #ifndef YY_BEGIN\n\ -#define YY_BEGIN ( yybegin= yypos, 1)\n\ +#define YY_BEGIN ( ctx->begin= ctx->pos, 1)\n\ #endif\n\ #ifndef YY_END\n\ -#define YY_END ( yyend= yypos, 1)\n\ +#define YY_END ( ctx->end= ctx->pos, 1)\n\ #endif\n\ #ifdef YY_DEBUG\n\ # define yyprintf(args) fprintf args\n\ @@ -396,148 +399,168 @@ static char *preamble= "\ \n\ #ifndef YY_PART\n\ \n\ -typedef void (*yyaction)(char *yytext, int yyleng);\n\ +typedef struct _yycontext yycontext;\n\ +typedef void (*yyaction)(yycontext *ctx, char *yytext, int yyleng);\n\ typedef struct _yythunk { int begin, end; yyaction action; struct _yythunk *next; } yythunk;\n\ \n\ -YY_VARIABLE(char * ) yybuf= 0;\n\ -YY_VARIABLE(int ) yybuflen= 0;\n\ -YY_VARIABLE(int ) yypos= 0;\n\ -YY_VARIABLE(int ) yylimit= 0;\n\ -YY_VARIABLE(char * ) yytext= 0;\n\ -YY_VARIABLE(int ) yytextlen= 0;\n\ -YY_VARIABLE(int ) yybegin= 0;\n\ -YY_VARIABLE(int ) yyend= 0;\n\ -YY_VARIABLE(int ) yytextmax= 0;\n\ -YY_VARIABLE(yythunk *) yythunks= 0;\n\ -YY_VARIABLE(int ) yythunkslen= 0;\n\ -YY_VARIABLE(int ) yythunkpos= 0;\n\ -YY_VARIABLE(YYSTYPE ) yy;\n\ -YY_VARIABLE(YYSTYPE *) yyval= 0;\n\ -YY_VARIABLE(YYSTYPE *) yyvals= 0;\n\ -YY_VARIABLE(int ) yyvalslen= 0;\n\ +struct _yycontext {\n\ + char *buf;\n\ + int buflen;\n\ + int pos;\n\ + int limit;\n\ + char *text;\n\ + int textlen;\n\ + int begin;\n\ + int end;\n\ + int textmax;\n\ + yythunk *thunks;\n\ + int thunkslen;\n\ + int thunkpos;\n\ + YYSTYPE yy;\n\ + YYSTYPE *val;\n\ + YYSTYPE *vals;\n\ + int valslen;\n\ +#ifdef YY_CTX_MEMBERS\n\ + YY_CTX_MEMBERS\n\ +#endif\n\ +};\n\ +\n\ +#ifdef YY_CTX_LOCAL\n\ +#define YY_CTX_PARAM_ yycontext *yyctx,\n\ +#define YY_CTX_PARAM yycontext *yyctx\n\ +#define YY_CTX_ARG_ yyctx,\n\ +#define YY_CTX_ARG yyctx\n\ +#else\n\ +#define YY_CTX_PARAM_\n\ +#define YY_CTX_PARAM\n\ +#define YY_CTX_ARG_\n\ +#define YY_CTX_ARG\n\ +yycontext yyctx0;\n\ +yycontext *yyctx= &yyctx0;\n\ +#endif\n\ \n\ -YY_LOCAL(int) yyrefill(void)\n\ +YY_LOCAL(int) yyrefill(yycontext *ctx)\n\ {\n\ int yyn;\n\ - while (yybuflen - yypos < 512)\n\ + while (ctx->buflen - ctx->pos < 512)\n\ {\n\ - yybuflen *= 2;\n\ - yybuf= realloc(yybuf, yybuflen);\n\ + ctx->buflen *= 2;\n\ + ctx->buf= (char *)realloc(ctx->buf, ctx->buflen);\n\ }\n\ - YY_INPUT((yybuf + yypos), yyn, (yybuflen - yypos));\n\ + YY_INPUT((ctx->buf + ctx->pos), yyn, (ctx->buflen - ctx->pos));\n\ if (!yyn) return 0;\n\ - yylimit += yyn;\n\ + ctx->limit += yyn;\n\ return 1;\n\ }\n\ \n\ -YY_LOCAL(int) yymatchDot(void)\n\ +YY_LOCAL(int) yymatchDot(yycontext *ctx)\n\ {\n\ - if (yypos >= yylimit && !yyrefill()) return 0;\n\ - ++yypos;\n\ + if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;\n\ + ++ctx->pos;\n\ return 1;\n\ }\n\ \n\ -YY_LOCAL(int) yymatchChar(int c)\n\ +YY_LOCAL(int) yymatchChar(yycontext *ctx, int c)\n\ {\n\ - if (yypos >= yylimit && !yyrefill()) return 0;\n\ - if ((unsigned char)yybuf[yypos] == c)\n\ + if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;\n\ + if ((unsigned char)ctx->buf[ctx->pos] == c)\n\ {\n\ - ++yypos;\n\ - yyprintf((stderr, \" ok yymatchChar(%c) @ %s\\n\", c, yybuf+yypos));\n\ + ++ctx->pos;\n\ + yyprintf((stderr, \" ok yymatchChar(ctx, %c) @ %s\\n\", c, ctx->buf+ctx->pos));\n\ return 1;\n\ }\n\ - yyprintf((stderr, \" fail yymatchChar(%c) @ %s\\n\", c, yybuf+yypos));\n\ + yyprintf((stderr, \" fail yymatchChar(ctx, %c) @ %s\\n\", c, ctx->buf+ctx->pos));\n\ return 0;\n\ }\n\ \n\ -YY_LOCAL(int) yymatchString(char *s)\n\ +YY_LOCAL(int) yymatchString(yycontext *ctx, char *s)\n\ {\n\ - int yysav= yypos;\n\ + int yysav= ctx->pos;\n\ while (*s)\n\ {\n\ - if (yypos >= yylimit && !yyrefill()) return 0;\n\ - if (yybuf[yypos] != *s)\n\ + if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;\n\ + if (ctx->buf[ctx->pos] != *s)\n\ {\n\ - yypos= yysav;\n\ + ctx->pos= yysav;\n\ return 0;\n\ }\n\ ++s;\n\ - ++yypos;\n\ + ++ctx->pos;\n\ }\n\ return 1;\n\ }\n\ \n\ -YY_LOCAL(int) yymatchClass(unsigned char *bits)\n\ +YY_LOCAL(int) yymatchClass(yycontext *ctx, unsigned char *bits)\n\ {\n\ int c;\n\ - if (yypos >= yylimit && !yyrefill()) return 0;\n\ - c= (unsigned char)yybuf[yypos];\n\ + if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;\n\ + c= (unsigned char)ctx->buf[ctx->pos];\n\ if (bits[c >> 3] & (1 << (c & 7)))\n\ {\n\ - ++yypos;\n\ - yyprintf((stderr, \" ok yymatchClass @ %s\\n\", yybuf+yypos));\n\ + ++ctx->pos;\n\ + yyprintf((stderr, \" ok yymatchClass @ %s\\n\", ctx->buf+ctx->pos));\n\ return 1;\n\ }\n\ - yyprintf((stderr, \" fail yymatchClass @ %s\\n\", yybuf+yypos));\n\ + yyprintf((stderr, \" fail yymatchClass @ %s\\n\", ctx->buf+ctx->pos));\n\ return 0;\n\ }\n\ \n\ -YY_LOCAL(void) yyDo(yyaction action, int begin, int end)\n\ +YY_LOCAL(void) yyDo(yycontext *ctx, yyaction action, int begin, int end)\n\ {\n\ - while (yythunkpos >= yythunkslen)\n\ + while (ctx->thunkpos >= ctx->thunkslen)\n\ {\n\ - yythunkslen *= 2;\n\ - yythunks= realloc(yythunks, sizeof(yythunk) * yythunkslen);\n\ + ctx->thunkslen *= 2;\n\ + ctx->thunks= (yythunk *)realloc(ctx->thunks, sizeof(yythunk) * ctx->thunkslen);\n\ }\n\ - yythunks[yythunkpos].begin= begin;\n\ - yythunks[yythunkpos].end= end;\n\ - yythunks[yythunkpos].action= action;\n\ - ++yythunkpos;\n\ + ctx->thunks[ctx->thunkpos].begin= begin;\n\ + ctx->thunks[ctx->thunkpos].end= end;\n\ + ctx->thunks[ctx->thunkpos].action= action;\n\ + ++ctx->thunkpos;\n\ }\n\ \n\ -YY_LOCAL(int) yyText(int begin, int end)\n\ +YY_LOCAL(int) yyText(yycontext *ctx, int begin, int end)\n\ {\n\ int yyleng= end - begin;\n\ if (yyleng <= 0)\n\ yyleng= 0;\n\ else\n\ {\n\ - while (yytextlen < (yyleng + 1))\n\ + while (ctx->textlen < (yyleng + 1))\n\ {\n\ - yytextlen *= 2;\n\ - yytext= realloc(yytext, yytextlen);\n\ + ctx->textlen *= 2;\n\ + ctx->text= (char *)realloc(ctx->text, ctx->textlen);\n\ }\n\ - memcpy(yytext, yybuf + begin, yyleng);\n\ + memcpy(ctx->text, ctx->buf + begin, yyleng);\n\ }\n\ - yytext[yyleng]= '\\0';\n\ + ctx->text[yyleng]= '\\0';\n\ return yyleng;\n\ }\n\ \n\ -YY_LOCAL(void) yyDone(void)\n\ +YY_LOCAL(void) yyDone(yycontext *ctx)\n\ {\n\ int pos;\n\ - for (pos= 0; pos < yythunkpos; ++pos)\n\ + for (pos= 0; pos < ctx->thunkpos; ++pos)\n\ {\n\ - yythunk *thunk= &yythunks[pos];\n\ - int yyleng= thunk->end ? yyText(thunk->begin, thunk->end) : thunk->begin;\n\ - yyprintf((stderr, \"DO [%d] %p %s\\n\", pos, thunk->action, yytext));\n\ - thunk->action(yytext, yyleng);\n\ + yythunk *thunk= &ctx->thunks[pos];\n\ + int yyleng= thunk->end ? yyText(ctx, thunk->begin, thunk->end) : thunk->begin;\n\ + yyprintf((stderr, \"DO [%d] %p %s\\n\", pos, thunk->action, ctx->text));\n\ + thunk->action(ctx, ctx->text, yyleng);\n\ }\n\ - yythunkpos= 0;\n\ + ctx->thunkpos= 0;\n\ }\n\ \n\ -YY_LOCAL(void) yyCommit()\n\ +YY_LOCAL(void) yyCommit(yycontext *ctx)\n\ {\n\ - if ((yylimit -= yypos))\n\ + if ((ctx->limit -= ctx->pos))\n\ {\n\ - memmove(yybuf, yybuf + yypos, yylimit);\n\ + memmove(ctx->buf, ctx->buf + ctx->pos, ctx->limit);\n\ }\n\ - yybegin -= yypos;\n\ - yyend -= yypos;\n\ - yypos= yythunkpos= 0;\n\ + ctx->begin -= ctx->pos;\n\ + ctx->end -= ctx->pos;\n\ + ctx->pos= ctx->thunkpos= 0;\n\ }\n\ \n\ -YY_LOCAL(int) yyAccept(int tp0)\n\ +YY_LOCAL(int) yyAccept(yycontext *ctx, int tp0)\n\ {\n\ if (tp0)\n\ {\n\ @@ -546,19 +569,19 @@ YY_LOCAL(int) yyAccept(int tp0)\n\ }\n\ else\n\ {\n\ - yyDone();\n\ - yyCommit();\n\ + yyDone(ctx);\n\ + yyCommit(ctx);\n\ }\n\ return 1;\n\ }\n\ \n\ -YY_LOCAL(void) yyPush(char *text, int count) { yyval += count; }\n\ -YY_LOCAL(void) yyPop(char *text, int count) { yyval -= count; }\n\ -YY_LOCAL(void) yySet(char *text, int count) { yyval[count]= yy; }\n\ +YY_LOCAL(void) yyPush(yycontext *ctx, char *text, int count) { ctx->val += count; }\n\ +YY_LOCAL(void) yyPop(yycontext *ctx, char *text, int count) { ctx->val -= count; }\n\ +YY_LOCAL(void) yySet(yycontext *ctx, char *text, int count) { ctx->val[count]= ctx->yy; }\n\ \n\ #endif /* YY_PART */\n\ \n\ -#define YYACCEPT yyAccept(yythunkpos0)\n\ +#define YYACCEPT yyAccept(ctx, yythunkpos0)\n\ \n\ "; @@ -566,49 +589,35 @@ static char *footer= "\n\ \n\ #ifndef YY_PART\n\ \n\ -typedef int (*yyrule)();\n\ +typedef int (*yyrule)(yycontext *ctx);\n\ \n\ -YY_PARSE(int) YYPARSEFROM(yyrule yystart)\n\ +YY_PARSE(int) YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart)\n\ {\n\ int yyok;\n\ - if (!yybuflen)\n\ + if (!yyctx->buflen)\n\ {\n\ - yybuflen= 1024;\n\ - yybuf= malloc(yybuflen);\n\ - yytextlen= 1024;\n\ - yytext= malloc(yytextlen);\n\ - yythunkslen= 32;\n\ - yythunks= malloc(sizeof(yythunk) * yythunkslen);\n\ - yyvalslen= 32;\n\ - yyvals= malloc(sizeof(YYSTYPE) * yyvalslen);\n\ - yybegin= yyend= yypos= yylimit= yythunkpos= 0;\n\ + yyctx->buflen= 1024;\n\ + yyctx->buf= (char *)malloc(yyctx->buflen);\n\ + yyctx->textlen= 1024;\n\ + yyctx->text= (char *)malloc(yyctx->textlen);\n\ + yyctx->thunkslen= 32;\n\ + yyctx->thunks= (yythunk *)malloc(sizeof(yythunk) * yyctx->thunkslen);\n\ + yyctx->valslen= 32;\n\ + yyctx->vals= (YYSTYPE *)malloc(sizeof(YYSTYPE) * yyctx->valslen);\n\ + yyctx->begin= yyctx->end= yyctx->pos= yyctx->limit= yyctx->thunkpos= 0;\n\ }\n\ - yybegin= yyend= yypos;\n\ - yythunkpos= 0;\n\ - yyval= yyvals;\n\ - yyok= yystart();\n\ - if (yyok) yyDone();\n\ - yyCommit();\n\ + yyctx->begin= yyctx->end= yyctx->pos;\n\ + yyctx->thunkpos= 0;\n\ + yyctx->val= yyctx->vals;\n\ + yyok= yystart(yyctx);\n\ + if (yyok) yyDone(yyctx);\n\ + yyCommit(yyctx);\n\ return yyok;\n\ - (void)yyrefill;\n\ - (void)yymatchDot;\n\ - (void)yymatchChar;\n\ - (void)yymatchString;\n\ - (void)yymatchClass;\n\ - (void)yyDo;\n\ - (void)yyText;\n\ - (void)yyDone;\n\ - (void)yyCommit;\n\ - (void)yyAccept;\n\ - (void)yyPush;\n\ - (void)yyPop;\n\ - (void)yySet;\n\ - (void)yytextmax;\n\ }\n\ \n\ -YY_PARSE(int) YYPARSE(void)\n\ +YY_PARSE(int) YYPARSE(YY_CTX_PARAM)\n\ {\n\ - return YYPARSEFROM(yy_%s);\n\ + return YYPARSEFROM(YY_CTX_ARG_ yy_%s);\n\ }\n\ \n\ #endif\n\ @@ -692,11 +701,11 @@ void Rule_compile_c(Node *node) fprintf(output, "%s", preamble); for (n= node; n; n= n->rule.next) - fprintf(output, "YY_RULE(int) yy_%s(); /* %d */\n", n->rule.name, n->rule.id); + fprintf(output, "YY_RULE(int) yy_%s(yycontext *ctx); /* %d */\n", n->rule.name, n->rule.id); fprintf(output, "\n"); for (n= actions; n; n= n->action.list) { - fprintf(output, "YY_ACTION(void) yy%s(char *yytext, int yyleng)\n{\n", n->action.name); + fprintf(output, "YY_ACTION(void) yy%s(yycontext *ctx, char *yytext, int yyleng)\n{\n", n->action.name); defineVariables(n->action.rule->rule.variables); fprintf(output, " yyprintf((stderr, \"do yy%s\\n\"));\n", n->action.name); fprintf(output, " %s;\n", n->action.text); diff --git a/examples/Makefile b/examples/Makefile index 121692b..30d3cc8 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,4 +1,4 @@ -EXAMPLES = test rule accept wc dc dcv calc basic +EXAMPLES = test rule accept wc dc dcv calc basic localctx CFLAGS = -g -O3 @@ -71,6 +71,14 @@ basic : .FORCE rm -f $@.out @echo +localctx : .FORCE + ../peg -o test.peg.c test.peg + $(CC) $(CFLAGS) -o localctx localctx.c + echo 'ab.ac.ad.ae.afg.afh.afg.afh.afi.afj.' | ./$@ | $(TEE) $@.out + $(DIFF) $@.ref $@.out + rm -f $@.out + @echo + clean : .FORCE rm -f *~ *.o *.[pl]eg.[cd] $(EXAMPLES) rm -rf *.dSYM diff --git a/examples/basic.leg b/examples/basic.leg index 70f91e3..ed38a8d 100644 --- a/examples/basic.leg +++ b/examples/basic.leg @@ -16,7 +16,7 @@ # # THE SOFTWARE IS PROVIDED 'AS IS'. USE ENTIRELY AT YOUR OWN RISK. # -# Last edited: 2009-10-26 14:04:30 by piumarta on ubuntu2 +# Last edited: 2012-04-29 15:14:06 by piumarta on emilia %{ # include @@ -81,6 +81,7 @@ char *help; void error(char *fmt, ...); + int findLine(int n, int create); %} line = - s:statement CR @@ -95,7 +96,7 @@ statement = 'print'- expr-list | 'goto'- e:expression { epc= pc; if ((pc= findLine(e.number, 0)) < 0) error("no such line"); } | 'input'- var-list | 'let'- v:var EQUAL e:expression { variables[v.number]= e.number; } -| 'gosub'- e:expression { epc= pc; if (sp < 1024) stack[sp++]= pc, pc= findLine(e.number); else error("too many gosubs"); +| 'gosub'- e:expression { epc= pc; if (sp < 1024) stack[sp++]= pc, pc= findLine(e.number, 0); else error("too many gosubs"); if (pc < 0) error("no such line"); } | 'return'- { epc= pc; if ((pc= sp ? stack[--sp] : -1) < 0) error("no gosub"); } | 'clear'- { while (numLines) accept(lines->number, "\n"); } diff --git a/examples/localctx.c b/examples/localctx.c new file mode 100644 index 0000000..837ebc8 --- /dev/null +++ b/examples/localctx.c @@ -0,0 +1,13 @@ +#include + +#define YY_CTX_LOCAL + +#include "test.peg.c" + +int main() +{ + yycontext ctx; + memset(&ctx, 0, sizeof(yycontext)); + while (yyparse(&ctx)); + return 0; +} diff --git a/examples/localctx.ref b/examples/localctx.ref new file mode 100644 index 0000000..2d18109 --- /dev/null +++ b/examples/localctx.ref @@ -0,0 +1,10 @@ +a1 ab1 . +a2 ac2 . +a3 ad3 . +a3 ae3 . +a4 af4 afg4 . +a4 af5 afh5 . +a4 af4 afg4 . +a4 af5 afh5 . +af6 afi6 a6 . +af6 af7 afj7 a6 . diff --git a/leg.c b/leg.c index 8404e1f..91b696d 100644 --- a/leg.c +++ b/leg.c @@ -1,4 +1,4 @@ -/* A recursive-descent parser generated by peg 0.1.2 */ +/* A recursive-descent parser generated by peg 0.1.9 */ #include #include @@ -46,9 +46,6 @@ # define YY_LOCAL(T) static T # define YY_RULE(T) static T -#ifndef YY_VARIABLE -#define YY_VARIABLE(T) static T -#endif #ifndef YY_LOCAL #define YY_LOCAL(T) static T #endif @@ -76,10 +73,10 @@ } #endif #ifndef YY_BEGIN -#define YY_BEGIN ( yybegin= yypos, 1) +#define YY_BEGIN ( ctx->begin= ctx->pos, 1) #endif #ifndef YY_END -#define YY_END ( yyend= yypos, 1) +#define YY_END ( ctx->end= ctx->pos, 1) #endif #ifdef YY_DEBUG # define yyprintf(args) fprintf args @@ -92,148 +89,168 @@ #ifndef YY_PART -typedef void (*yyaction)(char *yytext, int yyleng); +typedef struct _yycontext yycontext; +typedef void (*yyaction)(yycontext *ctx, char *yytext, int yyleng); typedef struct _yythunk { int begin, end; yyaction action; struct _yythunk *next; } yythunk; -YY_VARIABLE(char * ) yybuf= 0; -YY_VARIABLE(int ) yybuflen= 0; -YY_VARIABLE(int ) yypos= 0; -YY_VARIABLE(int ) yylimit= 0; -YY_VARIABLE(char * ) yytext= 0; -YY_VARIABLE(int ) yytextlen= 0; -YY_VARIABLE(int ) yybegin= 0; -YY_VARIABLE(int ) yyend= 0; -YY_VARIABLE(int ) yytextmax= 0; -YY_VARIABLE(yythunk *) yythunks= 0; -YY_VARIABLE(int ) yythunkslen= 0; -YY_VARIABLE(int ) yythunkpos= 0; -YY_VARIABLE(YYSTYPE ) yy; -YY_VARIABLE(YYSTYPE *) yyval= 0; -YY_VARIABLE(YYSTYPE *) yyvals= 0; -YY_VARIABLE(int ) yyvalslen= 0; +struct _yycontext { + char *buf; + int buflen; + int pos; + int limit; + char *text; + int textlen; + int begin; + int end; + int textmax; + yythunk *thunks; + int thunkslen; + int thunkpos; + YYSTYPE yy; + YYSTYPE *val; + YYSTYPE *vals; + int valslen; +#ifdef YY_CTX_MEMBERS + YY_CTX_MEMBERS +#endif +}; + +#ifdef YY_CTX_LOCAL +#define YY_CTX_PARAM_ yycontext *yyctx, +#define YY_CTX_PARAM yycontext *yyctx +#define YY_CTX_ARG_ yyctx, +#define YY_CTX_ARG yyctx +#else +#define YY_CTX_PARAM_ +#define YY_CTX_PARAM +#define YY_CTX_ARG_ +#define YY_CTX_ARG +yycontext yyctx0; +yycontext *yyctx= &yyctx0; +#endif -YY_LOCAL(int) yyrefill(void) +YY_LOCAL(int) yyrefill(yycontext *ctx) { int yyn; - while (yybuflen - yypos < 512) + while (ctx->buflen - ctx->pos < 512) { - yybuflen *= 2; - yybuf= realloc(yybuf, yybuflen); + ctx->buflen *= 2; + ctx->buf= (char *)realloc(ctx->buf, ctx->buflen); } - YY_INPUT((yybuf + yypos), yyn, (yybuflen - yypos)); + YY_INPUT((ctx->buf + ctx->pos), yyn, (ctx->buflen - ctx->pos)); if (!yyn) return 0; - yylimit += yyn; + ctx->limit += yyn; return 1; } -YY_LOCAL(int) yymatchDot(void) +YY_LOCAL(int) yymatchDot(yycontext *ctx) { - if (yypos >= yylimit && !yyrefill()) return 0; - ++yypos; + if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0; + ++ctx->pos; return 1; } -YY_LOCAL(int) yymatchChar(int c) +YY_LOCAL(int) yymatchChar(yycontext *ctx, int c) { - if (yypos >= yylimit && !yyrefill()) return 0; - if (yybuf[yypos] == c) + if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0; + if ((unsigned char)ctx->buf[ctx->pos] == c) { - ++yypos; - yyprintf((stderr, " ok yymatchChar(%c) @ %s\n", c, yybuf+yypos)); + ++ctx->pos; + yyprintf((stderr, " ok yymatchChar(ctx, %c) @ %s\n", c, ctx->buf+ctx->pos)); return 1; } - yyprintf((stderr, " fail yymatchChar(%c) @ %s\n", c, yybuf+yypos)); + yyprintf((stderr, " fail yymatchChar(ctx, %c) @ %s\n", c, ctx->buf+ctx->pos)); return 0; } -YY_LOCAL(int) yymatchString(char *s) +YY_LOCAL(int) yymatchString(yycontext *ctx, char *s) { - int yysav= yypos; + int yysav= ctx->pos; while (*s) { - if (yypos >= yylimit && !yyrefill()) return 0; - if (yybuf[yypos] != *s) + if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0; + if (ctx->buf[ctx->pos] != *s) { - yypos= yysav; + ctx->pos= yysav; return 0; } ++s; - ++yypos; + ++ctx->pos; } return 1; } -YY_LOCAL(int) yymatchClass(unsigned char *bits) +YY_LOCAL(int) yymatchClass(yycontext *ctx, unsigned char *bits) { int c; - if (yypos >= yylimit && !yyrefill()) return 0; - c= yybuf[yypos]; + if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0; + c= (unsigned char)ctx->buf[ctx->pos]; if (bits[c >> 3] & (1 << (c & 7))) { - ++yypos; - yyprintf((stderr, " ok yymatchClass @ %s\n", yybuf+yypos)); + ++ctx->pos; + yyprintf((stderr, " ok yymatchClass @ %s\n", ctx->buf+ctx->pos)); return 1; } - yyprintf((stderr, " fail yymatchClass @ %s\n", yybuf+yypos)); + yyprintf((stderr, " fail yymatchClass @ %s\n", ctx->buf+ctx->pos)); return 0; } -YY_LOCAL(void) yyDo(yyaction action, int begin, int end) +YY_LOCAL(void) yyDo(yycontext *ctx, yyaction action, int begin, int end) { - while (yythunkpos >= yythunkslen) + while (ctx->thunkpos >= ctx->thunkslen) { - yythunkslen *= 2; - yythunks= realloc(yythunks, sizeof(yythunk) * yythunkslen); + ctx->thunkslen *= 2; + ctx->thunks= (yythunk *)realloc(ctx->thunks, sizeof(yythunk) * ctx->thunkslen); } - yythunks[yythunkpos].begin= begin; - yythunks[yythunkpos].end= end; - yythunks[yythunkpos].action= action; - ++yythunkpos; + ctx->thunks[ctx->thunkpos].begin= begin; + ctx->thunks[ctx->thunkpos].end= end; + ctx->thunks[ctx->thunkpos].action= action; + ++ctx->thunkpos; } -YY_LOCAL(int) yyText(int begin, int end) +YY_LOCAL(int) yyText(yycontext *ctx, int begin, int end) { int yyleng= end - begin; if (yyleng <= 0) yyleng= 0; else { - while (yytextlen < (yyleng - 1)) + while (ctx->textlen < (yyleng + 1)) { - yytextlen *= 2; - yytext= realloc(yytext, yytextlen); + ctx->textlen *= 2; + ctx->text= (char *)realloc(ctx->text, ctx->textlen); } - memcpy(yytext, yybuf + begin, yyleng); + memcpy(ctx->text, ctx->buf + begin, yyleng); } - yytext[yyleng]= '\0'; + ctx->text[yyleng]= '\0'; return yyleng; } -YY_LOCAL(void) yyDone(void) +YY_LOCAL(void) yyDone(yycontext *ctx) { int pos; - for (pos= 0; pos < yythunkpos; ++pos) + for (pos= 0; pos < ctx->thunkpos; ++pos) { - yythunk *thunk= &yythunks[pos]; - int yyleng= thunk->end ? yyText(thunk->begin, thunk->end) : thunk->begin; - yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, yytext)); - thunk->action(yytext, yyleng); + yythunk *thunk= &ctx->thunks[pos]; + int yyleng= thunk->end ? yyText(ctx, thunk->begin, thunk->end) : thunk->begin; + yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, ctx->text)); + thunk->action(ctx, ctx->text, yyleng); } - yythunkpos= 0; + ctx->thunkpos= 0; } -YY_LOCAL(void) yyCommit() +YY_LOCAL(void) yyCommit(yycontext *ctx) { - if ((yylimit -= yypos)) + if ((ctx->limit -= ctx->pos)) { - memmove(yybuf, yybuf + yypos, yylimit); + memmove(ctx->buf, ctx->buf + ctx->pos, ctx->limit); } - yybegin -= yypos; - yyend -= yypos; - yypos= yythunkpos= 0; + ctx->begin -= ctx->pos; + ctx->end -= ctx->pos; + ctx->pos= ctx->thunkpos= 0; } -YY_LOCAL(int) yyAccept(int tp0) +YY_LOCAL(int) yyAccept(yycontext *ctx, int tp0) { if (tp0) { @@ -242,691 +259,803 @@ YY_LOCAL(int) yyAccept(int tp0) } else { - yyDone(); - yyCommit(); + yyDone(ctx); + yyCommit(ctx); } return 1; } -YY_LOCAL(void) yyPush(char *text, int count) { yyval += count; } -YY_LOCAL(void) yyPop(char *text, int count) { yyval -= count; } -YY_LOCAL(void) yySet(char *text, int count) { yyval[count]= yy; } +YY_LOCAL(void) yyPush(yycontext *ctx, char *text, int count) { ctx->val += count; } +YY_LOCAL(void) yyPop(yycontext *ctx, char *text, int count) { ctx->val -= count; } +YY_LOCAL(void) yySet(yycontext *ctx, char *text, int count) { ctx->val[count]= ctx->yy; } #endif /* YY_PART */ -#define YYACCEPT yyAccept(yythunkpos0) +#define YYACCEPT yyAccept(ctx, yythunkpos0) -YY_RULE(int) yy_end_of_line(); /* 36 */ -YY_RULE(int) yy_comment(); /* 35 */ -YY_RULE(int) yy_space(); /* 34 */ -YY_RULE(int) yy_braces(); /* 33 */ -YY_RULE(int) yy_range(); /* 32 */ -YY_RULE(int) yy_char(); /* 31 */ -YY_RULE(int) yy_END(); /* 30 */ -YY_RULE(int) yy_BEGIN(); /* 29 */ -YY_RULE(int) yy_DOT(); /* 28 */ -YY_RULE(int) yy_class(); /* 27 */ -YY_RULE(int) yy_literal(); /* 26 */ -YY_RULE(int) yy_CLOSE(); /* 25 */ -YY_RULE(int) yy_OPEN(); /* 24 */ -YY_RULE(int) yy_COLON(); /* 23 */ -YY_RULE(int) yy_PLUS(); /* 22 */ -YY_RULE(int) yy_STAR(); /* 21 */ -YY_RULE(int) yy_QUESTION(); /* 20 */ -YY_RULE(int) yy_primary(); /* 19 */ -YY_RULE(int) yy_NOT(); /* 18 */ -YY_RULE(int) yy_suffix(); /* 17 */ -YY_RULE(int) yy_action(); /* 16 */ -YY_RULE(int) yy_AND(); /* 15 */ -YY_RULE(int) yy_prefix(); /* 14 */ -YY_RULE(int) yy_BAR(); /* 13 */ -YY_RULE(int) yy_sequence(); /* 12 */ -YY_RULE(int) yy_SEMICOLON(); /* 11 */ -YY_RULE(int) yy_expression(); /* 10 */ -YY_RULE(int) yy_EQUAL(); /* 9 */ -YY_RULE(int) yy_identifier(); /* 8 */ -YY_RULE(int) yy_RPERCENT(); /* 7 */ -YY_RULE(int) yy_end_of_file(); /* 6 */ -YY_RULE(int) yy_trailer(); /* 5 */ -YY_RULE(int) yy_definition(); /* 4 */ -YY_RULE(int) yy_declaration(); /* 3 */ -YY_RULE(int) yy__(); /* 2 */ -YY_RULE(int) yy_grammar(); /* 1 */ +YY_RULE(int) yy_end_of_line(yycontext *ctx); /* 36 */ +YY_RULE(int) yy_comment(yycontext *ctx); /* 35 */ +YY_RULE(int) yy_space(yycontext *ctx); /* 34 */ +YY_RULE(int) yy_braces(yycontext *ctx); /* 33 */ +YY_RULE(int) yy_range(yycontext *ctx); /* 32 */ +YY_RULE(int) yy_char(yycontext *ctx); /* 31 */ +YY_RULE(int) yy_END(yycontext *ctx); /* 30 */ +YY_RULE(int) yy_BEGIN(yycontext *ctx); /* 29 */ +YY_RULE(int) yy_DOT(yycontext *ctx); /* 28 */ +YY_RULE(int) yy_class(yycontext *ctx); /* 27 */ +YY_RULE(int) yy_literal(yycontext *ctx); /* 26 */ +YY_RULE(int) yy_CLOSE(yycontext *ctx); /* 25 */ +YY_RULE(int) yy_OPEN(yycontext *ctx); /* 24 */ +YY_RULE(int) yy_COLON(yycontext *ctx); /* 23 */ +YY_RULE(int) yy_PLUS(yycontext *ctx); /* 22 */ +YY_RULE(int) yy_STAR(yycontext *ctx); /* 21 */ +YY_RULE(int) yy_QUESTION(yycontext *ctx); /* 20 */ +YY_RULE(int) yy_primary(yycontext *ctx); /* 19 */ +YY_RULE(int) yy_NOT(yycontext *ctx); /* 18 */ +YY_RULE(int) yy_suffix(yycontext *ctx); /* 17 */ +YY_RULE(int) yy_action(yycontext *ctx); /* 16 */ +YY_RULE(int) yy_AND(yycontext *ctx); /* 15 */ +YY_RULE(int) yy_prefix(yycontext *ctx); /* 14 */ +YY_RULE(int) yy_BAR(yycontext *ctx); /* 13 */ +YY_RULE(int) yy_sequence(yycontext *ctx); /* 12 */ +YY_RULE(int) yy_SEMICOLON(yycontext *ctx); /* 11 */ +YY_RULE(int) yy_expression(yycontext *ctx); /* 10 */ +YY_RULE(int) yy_EQUAL(yycontext *ctx); /* 9 */ +YY_RULE(int) yy_identifier(yycontext *ctx); /* 8 */ +YY_RULE(int) yy_RPERCENT(yycontext *ctx); /* 7 */ +YY_RULE(int) yy_end_of_file(yycontext *ctx); /* 6 */ +YY_RULE(int) yy_trailer(yycontext *ctx); /* 5 */ +YY_RULE(int) yy_definition(yycontext *ctx); /* 4 */ +YY_RULE(int) yy_declaration(yycontext *ctx); /* 3 */ +YY_RULE(int) yy__(yycontext *ctx); /* 2 */ +YY_RULE(int) yy_grammar(yycontext *ctx); /* 1 */ -YY_ACTION(void) yy_9_primary(char *yytext, int yyleng) +YY_ACTION(void) yy_9_primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_9_primary\n")); push(makePredicate("YY_END")); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_8_primary(char *yytext, int yyleng) +YY_ACTION(void) yy_8_primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_8_primary\n")); push(makePredicate("YY_BEGIN")); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_7_primary(char *yytext, int yyleng) +YY_ACTION(void) yy_7_primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_7_primary\n")); push(makeAction(yytext)); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_6_primary(char *yytext, int yyleng) +YY_ACTION(void) yy_6_primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_6_primary\n")); push(makeDot()); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_5_primary(char *yytext, int yyleng) +YY_ACTION(void) yy_5_primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_5_primary\n")); push(makeClass(yytext)); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_4_primary(char *yytext, int yyleng) +YY_ACTION(void) yy_4_primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_4_primary\n")); push(makeString(yytext)); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_3_primary(char *yytext, int yyleng) +YY_ACTION(void) yy_3_primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_3_primary\n")); push(makeName(findRule(yytext))); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_2_primary(char *yytext, int yyleng) +YY_ACTION(void) yy_2_primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_2_primary\n")); Node *name= makeName(findRule(yytext)); name->name.variable= pop(); push(name); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_primary(char *yytext, int yyleng) +YY_ACTION(void) yy_1_primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_primary\n")); push(makeVariable(yytext)); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_3_suffix(char *yytext, int yyleng) +YY_ACTION(void) yy_3_suffix(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_3_suffix\n")); push(makePlus (pop())); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_2_suffix(char *yytext, int yyleng) +YY_ACTION(void) yy_2_suffix(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_2_suffix\n")); push(makeStar (pop())); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_suffix(char *yytext, int yyleng) +YY_ACTION(void) yy_1_suffix(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_suffix\n")); push(makeQuery(pop())); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_3_prefix(char *yytext, int yyleng) +YY_ACTION(void) yy_3_prefix(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_3_prefix\n")); push(makePeekNot(pop())); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_2_prefix(char *yytext, int yyleng) +YY_ACTION(void) yy_2_prefix(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_2_prefix\n")); push(makePeekFor(pop())); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_prefix(char *yytext, int yyleng) +YY_ACTION(void) yy_1_prefix(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_prefix\n")); push(makePredicate(yytext)); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_sequence(char *yytext, int yyleng) +YY_ACTION(void) yy_1_sequence(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_sequence\n")); Node *f= pop(); push(Sequence_append(pop(), f)); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_expression(char *yytext, int yyleng) +YY_ACTION(void) yy_1_expression(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_expression\n")); Node *f= pop(); push(Alternate_append(pop(), f)); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_2_definition(char *yytext, int yyleng) +YY_ACTION(void) yy_2_definition(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_2_definition\n")); Node *e= pop(); Rule_setExpression(pop(), e); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_definition(char *yytext, int yyleng) +YY_ACTION(void) yy_1_definition(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_definition\n")); if (push(beginRule(findRule(yytext)))->rule.expression) fprintf(stderr, "rule '%s' redefined\n", yytext); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_trailer(char *yytext, int yyleng) +YY_ACTION(void) yy_1_trailer(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_trailer\n")); makeTrailer(yytext); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_declaration(char *yytext, int yyleng) +YY_ACTION(void) yy_1_declaration(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_declaration\n")); makeHeader(yytext); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_RULE(int) yy_end_of_line() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_end_of_line(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "end_of_line")); - { int yypos2= yypos, yythunkpos2= yythunkpos; if (!yymatchString("\r\n")) goto l3; goto l2; - l3:; yypos= yypos2; yythunkpos= yythunkpos2; if (!yymatchChar('\n')) goto l4; goto l2; - l4:; yypos= yypos2; yythunkpos= yythunkpos2; if (!yymatchChar('\r')) goto l1; + { int yypos2= ctx->pos, yythunkpos2= ctx->thunkpos; if (!yymatchString(ctx, "\r\n")) goto l3; goto l2; + l3:; ctx->pos= yypos2; ctx->thunkpos= yythunkpos2; if (!yymatchChar(ctx, '\n')) goto l4; goto l2; + l4:; ctx->pos= yypos2; ctx->thunkpos= yythunkpos2; if (!yymatchChar(ctx, '\r')) goto l1; } l2:; - yyprintf((stderr, " ok %s @ %s\n", "end_of_line", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "end_of_line", ctx->buf+ctx->pos)); return 1; - l1:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "end_of_line", yybuf+yypos)); + l1:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "end_of_line", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_comment() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "comment")); if (!yymatchChar('#')) goto l5; +YY_RULE(int) yy_comment(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "comment")); if (!yymatchChar(ctx, '#')) goto l5; l6:; - { int yypos7= yypos, yythunkpos7= yythunkpos; - { int yypos8= yypos, yythunkpos8= yythunkpos; if (!yy_end_of_line()) goto l8; goto l7; - l8:; yypos= yypos8; yythunkpos= yythunkpos8; - } if (!yymatchDot()) goto l7; goto l6; - l7:; yypos= yypos7; yythunkpos= yythunkpos7; - } if (!yy_end_of_line()) goto l5; - yyprintf((stderr, " ok %s @ %s\n", "comment", yybuf+yypos)); + { int yypos7= ctx->pos, yythunkpos7= ctx->thunkpos; + { int yypos8= ctx->pos, yythunkpos8= ctx->thunkpos; if (!yy_end_of_line(ctx)) goto l8; goto l7; + l8:; ctx->pos= yypos8; ctx->thunkpos= yythunkpos8; + } if (!yymatchDot(ctx)) goto l7; goto l6; + l7:; ctx->pos= yypos7; ctx->thunkpos= yythunkpos7; + } if (!yy_end_of_line(ctx)) goto l5; + yyprintf((stderr, " ok %s @ %s\n", "comment", ctx->buf+ctx->pos)); return 1; - l5:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "comment", yybuf+yypos)); + l5:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "comment", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_space() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_space(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "space")); - { int yypos10= yypos, yythunkpos10= yythunkpos; if (!yymatchChar(' ')) goto l11; goto l10; - l11:; yypos= yypos10; yythunkpos= yythunkpos10; if (!yymatchChar('\t')) goto l12; goto l10; - l12:; yypos= yypos10; yythunkpos= yythunkpos10; if (!yy_end_of_line()) goto l9; + { int yypos10= ctx->pos, yythunkpos10= ctx->thunkpos; if (!yymatchChar(ctx, ' ')) goto l11; goto l10; + l11:; ctx->pos= yypos10; ctx->thunkpos= yythunkpos10; if (!yymatchChar(ctx, '\t')) goto l12; goto l10; + l12:; ctx->pos= yypos10; ctx->thunkpos= yythunkpos10; if (!yy_end_of_line(ctx)) goto l9; } l10:; - yyprintf((stderr, " ok %s @ %s\n", "space", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "space", ctx->buf+ctx->pos)); return 1; - l9:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "space", yybuf+yypos)); + l9:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "space", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_braces() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_braces(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "braces")); - { int yypos14= yypos, yythunkpos14= yythunkpos; if (!yymatchChar('{')) goto l15; + { int yypos14= ctx->pos, yythunkpos14= ctx->thunkpos; if (!yymatchChar(ctx, '{')) goto l15; l16:; - { int yypos17= yypos, yythunkpos17= yythunkpos; if (!yy_braces()) goto l17; goto l16; - l17:; yypos= yypos17; yythunkpos= yythunkpos17; - } if (!yymatchChar('}')) goto l15; goto l14; - l15:; yypos= yypos14; yythunkpos= yythunkpos14; - { int yypos18= yypos, yythunkpos18= yythunkpos; if (!yymatchChar('}')) goto l18; goto l13; - l18:; yypos= yypos18; yythunkpos= yythunkpos18; - } if (!yymatchDot()) goto l13; + { int yypos17= ctx->pos, yythunkpos17= ctx->thunkpos; if (!yy_braces(ctx)) goto l17; goto l16; + l17:; ctx->pos= yypos17; ctx->thunkpos= yythunkpos17; + } if (!yymatchChar(ctx, '}')) goto l15; goto l14; + l15:; ctx->pos= yypos14; ctx->thunkpos= yythunkpos14; + { int yypos18= ctx->pos, yythunkpos18= ctx->thunkpos; if (!yymatchChar(ctx, '}')) goto l18; goto l13; + l18:; ctx->pos= yypos18; ctx->thunkpos= yythunkpos18; + } if (!yymatchDot(ctx)) goto l13; } l14:; - yyprintf((stderr, " ok %s @ %s\n", "braces", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "braces", ctx->buf+ctx->pos)); return 1; - l13:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "braces", yybuf+yypos)); + l13:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "braces", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_range() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_range(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "range")); - { int yypos20= yypos, yythunkpos20= yythunkpos; if (!yy_char()) goto l21; if (!yymatchChar('-')) goto l21; if (!yy_char()) goto l21; goto l20; - l21:; yypos= yypos20; yythunkpos= yythunkpos20; if (!yy_char()) goto l19; + { int yypos20= ctx->pos, yythunkpos20= ctx->thunkpos; if (!yy_char(ctx)) goto l21; if (!yymatchChar(ctx, '-')) goto l21; if (!yy_char(ctx)) goto l21; goto l20; + l21:; ctx->pos= yypos20; ctx->thunkpos= yythunkpos20; if (!yy_char(ctx)) goto l19; } l20:; - yyprintf((stderr, " ok %s @ %s\n", "range", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "range", ctx->buf+ctx->pos)); return 1; - l19:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "range", yybuf+yypos)); + l19:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "range", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_char() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_char(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "char")); - { int yypos23= yypos, yythunkpos23= yythunkpos; if (!yymatchChar('\\')) goto l24; if (!yymatchClass((unsigned char *)"\000\000\000\000\204\040\000\000\000\000\000\070\146\100\124\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l24; goto l23; - l24:; yypos= yypos23; yythunkpos= yythunkpos23; if (!yymatchChar('\\')) goto l25; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\017\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; goto l23; - l25:; yypos= yypos23; yythunkpos= yythunkpos23; if (!yymatchChar('\\')) goto l26; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l26; - { int yypos27= yypos, yythunkpos27= yythunkpos; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l27; goto l28; - l27:; yypos= yypos27; yythunkpos= yythunkpos27; + { int yypos23= ctx->pos, yythunkpos23= ctx->thunkpos; if (!yymatchChar(ctx, '\\')) goto l24; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\204\040\000\000\000\000\000\070\146\100\124\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l24; goto l23; + l24:; ctx->pos= yypos23; ctx->thunkpos= yythunkpos23; if (!yymatchChar(ctx, '\\')) goto l25; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\017\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; goto l23; + l25:; ctx->pos= yypos23; ctx->thunkpos= yythunkpos23; if (!yymatchChar(ctx, '\\')) goto l26; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l26; + { int yypos27= ctx->pos, yythunkpos27= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l27; goto l28; + l27:; ctx->pos= yypos27; ctx->thunkpos= yythunkpos27; } l28:; goto l23; - l26:; yypos= yypos23; yythunkpos= yythunkpos23; - { int yypos29= yypos, yythunkpos29= yythunkpos; if (!yymatchChar('\\')) goto l29; goto l22; - l29:; yypos= yypos29; yythunkpos= yythunkpos29; - } if (!yymatchDot()) goto l22; + l26:; ctx->pos= yypos23; ctx->thunkpos= yythunkpos23; + { int yypos29= ctx->pos, yythunkpos29= ctx->thunkpos; if (!yymatchChar(ctx, '\\')) goto l29; goto l22; + l29:; ctx->pos= yypos29; ctx->thunkpos= yythunkpos29; + } if (!yymatchDot(ctx)) goto l22; } l23:; - yyprintf((stderr, " ok %s @ %s\n", "char", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "char", ctx->buf+ctx->pos)); return 1; - l22:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "char", yybuf+yypos)); + l22:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "char", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_END() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "END")); if (!yymatchChar('>')) goto l30; if (!yy__()) goto l30; - yyprintf((stderr, " ok %s @ %s\n", "END", yybuf+yypos)); +YY_RULE(int) yy_END(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "END")); if (!yymatchChar(ctx, '>')) goto l30; if (!yy__(ctx)) goto l30; + yyprintf((stderr, " ok %s @ %s\n", "END", ctx->buf+ctx->pos)); return 1; - l30:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "END", yybuf+yypos)); + l30:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "END", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_BEGIN() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "BEGIN")); if (!yymatchChar('<')) goto l31; if (!yy__()) goto l31; - yyprintf((stderr, " ok %s @ %s\n", "BEGIN", yybuf+yypos)); +YY_RULE(int) yy_BEGIN(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "BEGIN")); if (!yymatchChar(ctx, '<')) goto l31; if (!yy__(ctx)) goto l31; + yyprintf((stderr, " ok %s @ %s\n", "BEGIN", ctx->buf+ctx->pos)); return 1; - l31:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "BEGIN", yybuf+yypos)); + l31:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "BEGIN", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_DOT() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "DOT")); if (!yymatchChar('.')) goto l32; if (!yy__()) goto l32; - yyprintf((stderr, " ok %s @ %s\n", "DOT", yybuf+yypos)); +YY_RULE(int) yy_DOT(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "DOT")); if (!yymatchChar(ctx, '.')) goto l32; if (!yy__(ctx)) goto l32; + yyprintf((stderr, " ok %s @ %s\n", "DOT", ctx->buf+ctx->pos)); return 1; - l32:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "DOT", yybuf+yypos)); + l32:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "DOT", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_class() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "class")); if (!yymatchChar('[')) goto l33; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l33; +YY_RULE(int) yy_class(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "class")); if (!yymatchChar(ctx, '[')) goto l33; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l33; l34:; - { int yypos35= yypos, yythunkpos35= yythunkpos; - { int yypos36= yypos, yythunkpos36= yythunkpos; if (!yymatchChar(']')) goto l36; goto l35; - l36:; yypos= yypos36; yythunkpos= yythunkpos36; - } if (!yy_range()) goto l35; goto l34; - l35:; yypos= yypos35; yythunkpos= yythunkpos35; - } yyText(yybegin, yyend); if (!(YY_END)) goto l33; if (!yymatchChar(']')) goto l33; if (!yy__()) goto l33; - yyprintf((stderr, " ok %s @ %s\n", "class", yybuf+yypos)); + { int yypos35= ctx->pos, yythunkpos35= ctx->thunkpos; + { int yypos36= ctx->pos, yythunkpos36= ctx->thunkpos; if (!yymatchChar(ctx, ']')) goto l36; goto l35; + l36:; ctx->pos= yypos36; ctx->thunkpos= yythunkpos36; + } if (!yy_range(ctx)) goto l35; goto l34; + l35:; ctx->pos= yypos35; ctx->thunkpos= yythunkpos35; + } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l33; if (!yymatchChar(ctx, ']')) goto l33; if (!yy__(ctx)) goto l33; + yyprintf((stderr, " ok %s @ %s\n", "class", ctx->buf+ctx->pos)); return 1; - l33:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "class", yybuf+yypos)); + l33:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "class", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_literal() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_literal(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "literal")); - { int yypos38= yypos, yythunkpos38= yythunkpos; if (!yymatchClass((unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l39; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l39; + { int yypos38= ctx->pos, yythunkpos38= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l39; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l39; l40:; - { int yypos41= yypos, yythunkpos41= yythunkpos; - { int yypos42= yypos, yythunkpos42= yythunkpos; if (!yymatchClass((unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l42; goto l41; - l42:; yypos= yypos42; yythunkpos= yythunkpos42; - } if (!yy_char()) goto l41; goto l40; - l41:; yypos= yypos41; yythunkpos= yythunkpos41; - } yyText(yybegin, yyend); if (!(YY_END)) goto l39; if (!yymatchClass((unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l39; if (!yy__()) goto l39; goto l38; - l39:; yypos= yypos38; yythunkpos= yythunkpos38; if (!yymatchClass((unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l37; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l37; + { int yypos41= ctx->pos, yythunkpos41= ctx->thunkpos; + { int yypos42= ctx->pos, yythunkpos42= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l42; goto l41; + l42:; ctx->pos= yypos42; ctx->thunkpos= yythunkpos42; + } if (!yy_char(ctx)) goto l41; goto l40; + l41:; ctx->pos= yypos41; ctx->thunkpos= yythunkpos41; + } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l39; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l39; if (!yy__(ctx)) goto l39; goto l38; + l39:; ctx->pos= yypos38; ctx->thunkpos= yythunkpos38; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l37; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l37; l43:; - { int yypos44= yypos, yythunkpos44= yythunkpos; - { int yypos45= yypos, yythunkpos45= yythunkpos; if (!yymatchClass((unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l45; goto l44; - l45:; yypos= yypos45; yythunkpos= yythunkpos45; - } if (!yy_char()) goto l44; goto l43; - l44:; yypos= yypos44; yythunkpos= yythunkpos44; - } yyText(yybegin, yyend); if (!(YY_END)) goto l37; if (!yymatchClass((unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l37; if (!yy__()) goto l37; + { int yypos44= ctx->pos, yythunkpos44= ctx->thunkpos; + { int yypos45= ctx->pos, yythunkpos45= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l45; goto l44; + l45:; ctx->pos= yypos45; ctx->thunkpos= yythunkpos45; + } if (!yy_char(ctx)) goto l44; goto l43; + l44:; ctx->pos= yypos44; ctx->thunkpos= yythunkpos44; + } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l37; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l37; if (!yy__(ctx)) goto l37; } l38:; - yyprintf((stderr, " ok %s @ %s\n", "literal", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "literal", ctx->buf+ctx->pos)); return 1; - l37:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "literal", yybuf+yypos)); + l37:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "literal", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_CLOSE() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "CLOSE")); if (!yymatchChar(')')) goto l46; if (!yy__()) goto l46; - yyprintf((stderr, " ok %s @ %s\n", "CLOSE", yybuf+yypos)); +YY_RULE(int) yy_CLOSE(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "CLOSE")); if (!yymatchChar(ctx, ')')) goto l46; if (!yy__(ctx)) goto l46; + yyprintf((stderr, " ok %s @ %s\n", "CLOSE", ctx->buf+ctx->pos)); return 1; - l46:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "CLOSE", yybuf+yypos)); + l46:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "CLOSE", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_OPEN() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "OPEN")); if (!yymatchChar('(')) goto l47; if (!yy__()) goto l47; - yyprintf((stderr, " ok %s @ %s\n", "OPEN", yybuf+yypos)); +YY_RULE(int) yy_OPEN(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "OPEN")); if (!yymatchChar(ctx, '(')) goto l47; if (!yy__(ctx)) goto l47; + yyprintf((stderr, " ok %s @ %s\n", "OPEN", ctx->buf+ctx->pos)); return 1; - l47:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "OPEN", yybuf+yypos)); + l47:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "OPEN", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_COLON() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "COLON")); if (!yymatchChar(':')) goto l48; if (!yy__()) goto l48; - yyprintf((stderr, " ok %s @ %s\n", "COLON", yybuf+yypos)); +YY_RULE(int) yy_COLON(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "COLON")); if (!yymatchChar(ctx, ':')) goto l48; if (!yy__(ctx)) goto l48; + yyprintf((stderr, " ok %s @ %s\n", "COLON", ctx->buf+ctx->pos)); return 1; - l48:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "COLON", yybuf+yypos)); + l48:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "COLON", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_PLUS() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "PLUS")); if (!yymatchChar('+')) goto l49; if (!yy__()) goto l49; - yyprintf((stderr, " ok %s @ %s\n", "PLUS", yybuf+yypos)); +YY_RULE(int) yy_PLUS(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "PLUS")); if (!yymatchChar(ctx, '+')) goto l49; if (!yy__(ctx)) goto l49; + yyprintf((stderr, " ok %s @ %s\n", "PLUS", ctx->buf+ctx->pos)); return 1; - l49:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PLUS", yybuf+yypos)); + l49:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PLUS", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_STAR() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "STAR")); if (!yymatchChar('*')) goto l50; if (!yy__()) goto l50; - yyprintf((stderr, " ok %s @ %s\n", "STAR", yybuf+yypos)); +YY_RULE(int) yy_STAR(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "STAR")); if (!yymatchChar(ctx, '*')) goto l50; if (!yy__(ctx)) goto l50; + yyprintf((stderr, " ok %s @ %s\n", "STAR", ctx->buf+ctx->pos)); return 1; - l50:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "STAR", yybuf+yypos)); + l50:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "STAR", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_QUESTION() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "QUESTION")); if (!yymatchChar('?')) goto l51; if (!yy__()) goto l51; - yyprintf((stderr, " ok %s @ %s\n", "QUESTION", yybuf+yypos)); +YY_RULE(int) yy_QUESTION(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "QUESTION")); if (!yymatchChar(ctx, '?')) goto l51; if (!yy__(ctx)) goto l51; + yyprintf((stderr, " ok %s @ %s\n", "QUESTION", ctx->buf+ctx->pos)); return 1; - l51:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "QUESTION", yybuf+yypos)); + l51:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "QUESTION", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_primary() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_primary(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "primary")); - { int yypos53= yypos, yythunkpos53= yythunkpos; if (!yy_identifier()) goto l54; yyDo(yy_1_primary, yybegin, yyend); if (!yy_COLON()) goto l54; if (!yy_identifier()) goto l54; - { int yypos55= yypos, yythunkpos55= yythunkpos; if (!yy_EQUAL()) goto l55; goto l54; - l55:; yypos= yypos55; yythunkpos= yythunkpos55; - } yyDo(yy_2_primary, yybegin, yyend); goto l53; - l54:; yypos= yypos53; yythunkpos= yythunkpos53; if (!yy_identifier()) goto l56; - { int yypos57= yypos, yythunkpos57= yythunkpos; if (!yy_EQUAL()) goto l57; goto l56; - l57:; yypos= yypos57; yythunkpos= yythunkpos57; - } yyDo(yy_3_primary, yybegin, yyend); goto l53; - l56:; yypos= yypos53; yythunkpos= yythunkpos53; if (!yy_OPEN()) goto l58; if (!yy_expression()) goto l58; if (!yy_CLOSE()) goto l58; goto l53; - l58:; yypos= yypos53; yythunkpos= yythunkpos53; if (!yy_literal()) goto l59; yyDo(yy_4_primary, yybegin, yyend); goto l53; - l59:; yypos= yypos53; yythunkpos= yythunkpos53; if (!yy_class()) goto l60; yyDo(yy_5_primary, yybegin, yyend); goto l53; - l60:; yypos= yypos53; yythunkpos= yythunkpos53; if (!yy_DOT()) goto l61; yyDo(yy_6_primary, yybegin, yyend); goto l53; - l61:; yypos= yypos53; yythunkpos= yythunkpos53; if (!yy_action()) goto l62; yyDo(yy_7_primary, yybegin, yyend); goto l53; - l62:; yypos= yypos53; yythunkpos= yythunkpos53; if (!yy_BEGIN()) goto l63; yyDo(yy_8_primary, yybegin, yyend); goto l53; - l63:; yypos= yypos53; yythunkpos= yythunkpos53; if (!yy_END()) goto l52; yyDo(yy_9_primary, yybegin, yyend); + { int yypos53= ctx->pos, yythunkpos53= ctx->thunkpos; if (!yy_identifier(ctx)) goto l54; yyDo(ctx, yy_1_primary, ctx->begin, ctx->end); if (!yy_COLON(ctx)) goto l54; if (!yy_identifier(ctx)) goto l54; + { int yypos55= ctx->pos, yythunkpos55= ctx->thunkpos; if (!yy_EQUAL(ctx)) goto l55; goto l54; + l55:; ctx->pos= yypos55; ctx->thunkpos= yythunkpos55; + } yyDo(ctx, yy_2_primary, ctx->begin, ctx->end); goto l53; + l54:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_identifier(ctx)) goto l56; + { int yypos57= ctx->pos, yythunkpos57= ctx->thunkpos; if (!yy_EQUAL(ctx)) goto l57; goto l56; + l57:; ctx->pos= yypos57; ctx->thunkpos= yythunkpos57; + } yyDo(ctx, yy_3_primary, ctx->begin, ctx->end); goto l53; + l56:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_OPEN(ctx)) goto l58; if (!yy_expression(ctx)) goto l58; if (!yy_CLOSE(ctx)) goto l58; goto l53; + l58:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_literal(ctx)) goto l59; yyDo(ctx, yy_4_primary, ctx->begin, ctx->end); goto l53; + l59:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_class(ctx)) goto l60; yyDo(ctx, yy_5_primary, ctx->begin, ctx->end); goto l53; + l60:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_DOT(ctx)) goto l61; yyDo(ctx, yy_6_primary, ctx->begin, ctx->end); goto l53; + l61:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_action(ctx)) goto l62; yyDo(ctx, yy_7_primary, ctx->begin, ctx->end); goto l53; + l62:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_BEGIN(ctx)) goto l63; yyDo(ctx, yy_8_primary, ctx->begin, ctx->end); goto l53; + l63:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; if (!yy_END(ctx)) goto l52; yyDo(ctx, yy_9_primary, ctx->begin, ctx->end); } l53:; - yyprintf((stderr, " ok %s @ %s\n", "primary", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "primary", ctx->buf+ctx->pos)); return 1; - l52:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "primary", yybuf+yypos)); + l52:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "primary", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_NOT() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "NOT")); if (!yymatchChar('!')) goto l64; if (!yy__()) goto l64; - yyprintf((stderr, " ok %s @ %s\n", "NOT", yybuf+yypos)); +YY_RULE(int) yy_NOT(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "NOT")); if (!yymatchChar(ctx, '!')) goto l64; if (!yy__(ctx)) goto l64; + yyprintf((stderr, " ok %s @ %s\n", "NOT", ctx->buf+ctx->pos)); return 1; - l64:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NOT", yybuf+yypos)); + l64:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NOT", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_suffix() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "suffix")); if (!yy_primary()) goto l65; - { int yypos66= yypos, yythunkpos66= yythunkpos; - { int yypos68= yypos, yythunkpos68= yythunkpos; if (!yy_QUESTION()) goto l69; yyDo(yy_1_suffix, yybegin, yyend); goto l68; - l69:; yypos= yypos68; yythunkpos= yythunkpos68; if (!yy_STAR()) goto l70; yyDo(yy_2_suffix, yybegin, yyend); goto l68; - l70:; yypos= yypos68; yythunkpos= yythunkpos68; if (!yy_PLUS()) goto l66; yyDo(yy_3_suffix, yybegin, yyend); +YY_RULE(int) yy_suffix(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "suffix")); if (!yy_primary(ctx)) goto l65; + { int yypos66= ctx->pos, yythunkpos66= ctx->thunkpos; + { int yypos68= ctx->pos, yythunkpos68= ctx->thunkpos; if (!yy_QUESTION(ctx)) goto l69; yyDo(ctx, yy_1_suffix, ctx->begin, ctx->end); goto l68; + l69:; ctx->pos= yypos68; ctx->thunkpos= yythunkpos68; if (!yy_STAR(ctx)) goto l70; yyDo(ctx, yy_2_suffix, ctx->begin, ctx->end); goto l68; + l70:; ctx->pos= yypos68; ctx->thunkpos= yythunkpos68; if (!yy_PLUS(ctx)) goto l66; yyDo(ctx, yy_3_suffix, ctx->begin, ctx->end); } l68:; goto l67; - l66:; yypos= yypos66; yythunkpos= yythunkpos66; + l66:; ctx->pos= yypos66; ctx->thunkpos= yythunkpos66; } l67:; - yyprintf((stderr, " ok %s @ %s\n", "suffix", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "suffix", ctx->buf+ctx->pos)); return 1; - l65:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "suffix", yybuf+yypos)); + l65:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "suffix", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_action() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "action")); if (!yymatchChar('{')) goto l71; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l71; +YY_RULE(int) yy_action(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "action")); if (!yymatchChar(ctx, '{')) goto l71; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l71; l72:; - { int yypos73= yypos, yythunkpos73= yythunkpos; if (!yy_braces()) goto l73; goto l72; - l73:; yypos= yypos73; yythunkpos= yythunkpos73; - } yyText(yybegin, yyend); if (!(YY_END)) goto l71; if (!yymatchChar('}')) goto l71; if (!yy__()) goto l71; - yyprintf((stderr, " ok %s @ %s\n", "action", yybuf+yypos)); + { int yypos73= ctx->pos, yythunkpos73= ctx->thunkpos; if (!yy_braces(ctx)) goto l73; goto l72; + l73:; ctx->pos= yypos73; ctx->thunkpos= yythunkpos73; + } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l71; if (!yymatchChar(ctx, '}')) goto l71; if (!yy__(ctx)) goto l71; + yyprintf((stderr, " ok %s @ %s\n", "action", ctx->buf+ctx->pos)); return 1; - l71:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "action", yybuf+yypos)); + l71:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "action", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_AND() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "AND")); if (!yymatchChar('&')) goto l74; if (!yy__()) goto l74; - yyprintf((stderr, " ok %s @ %s\n", "AND", yybuf+yypos)); +YY_RULE(int) yy_AND(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "AND")); if (!yymatchChar(ctx, '&')) goto l74; if (!yy__(ctx)) goto l74; + yyprintf((stderr, " ok %s @ %s\n", "AND", ctx->buf+ctx->pos)); return 1; - l74:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "AND", yybuf+yypos)); + l74:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "AND", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_prefix() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_prefix(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "prefix")); - { int yypos76= yypos, yythunkpos76= yythunkpos; if (!yy_AND()) goto l77; if (!yy_action()) goto l77; yyDo(yy_1_prefix, yybegin, yyend); goto l76; - l77:; yypos= yypos76; yythunkpos= yythunkpos76; if (!yy_AND()) goto l78; if (!yy_suffix()) goto l78; yyDo(yy_2_prefix, yybegin, yyend); goto l76; - l78:; yypos= yypos76; yythunkpos= yythunkpos76; if (!yy_NOT()) goto l79; if (!yy_suffix()) goto l79; yyDo(yy_3_prefix, yybegin, yyend); goto l76; - l79:; yypos= yypos76; yythunkpos= yythunkpos76; if (!yy_suffix()) goto l75; + { int yypos76= ctx->pos, yythunkpos76= ctx->thunkpos; if (!yy_AND(ctx)) goto l77; if (!yy_action(ctx)) goto l77; yyDo(ctx, yy_1_prefix, ctx->begin, ctx->end); goto l76; + l77:; ctx->pos= yypos76; ctx->thunkpos= yythunkpos76; if (!yy_AND(ctx)) goto l78; if (!yy_suffix(ctx)) goto l78; yyDo(ctx, yy_2_prefix, ctx->begin, ctx->end); goto l76; + l78:; ctx->pos= yypos76; ctx->thunkpos= yythunkpos76; if (!yy_NOT(ctx)) goto l79; if (!yy_suffix(ctx)) goto l79; yyDo(ctx, yy_3_prefix, ctx->begin, ctx->end); goto l76; + l79:; ctx->pos= yypos76; ctx->thunkpos= yythunkpos76; if (!yy_suffix(ctx)) goto l75; } l76:; - yyprintf((stderr, " ok %s @ %s\n", "prefix", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "prefix", ctx->buf+ctx->pos)); return 1; - l75:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "prefix", yybuf+yypos)); + l75:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "prefix", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_BAR() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "BAR")); if (!yymatchChar('|')) goto l80; if (!yy__()) goto l80; - yyprintf((stderr, " ok %s @ %s\n", "BAR", yybuf+yypos)); +YY_RULE(int) yy_BAR(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "BAR")); if (!yymatchChar(ctx, '|')) goto l80; if (!yy__(ctx)) goto l80; + yyprintf((stderr, " ok %s @ %s\n", "BAR", ctx->buf+ctx->pos)); return 1; - l80:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "BAR", yybuf+yypos)); + l80:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "BAR", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_sequence() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "sequence")); if (!yy_prefix()) goto l81; +YY_RULE(int) yy_sequence(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "sequence")); if (!yy_prefix(ctx)) goto l81; l82:; - { int yypos83= yypos, yythunkpos83= yythunkpos; if (!yy_prefix()) goto l83; yyDo(yy_1_sequence, yybegin, yyend); goto l82; - l83:; yypos= yypos83; yythunkpos= yythunkpos83; + { int yypos83= ctx->pos, yythunkpos83= ctx->thunkpos; if (!yy_prefix(ctx)) goto l83; yyDo(ctx, yy_1_sequence, ctx->begin, ctx->end); goto l82; + l83:; ctx->pos= yypos83; ctx->thunkpos= yythunkpos83; } - yyprintf((stderr, " ok %s @ %s\n", "sequence", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "sequence", ctx->buf+ctx->pos)); return 1; - l81:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "sequence", yybuf+yypos)); + l81:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "sequence", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_SEMICOLON() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "SEMICOLON")); if (!yymatchChar(';')) goto l84; if (!yy__()) goto l84; - yyprintf((stderr, " ok %s @ %s\n", "SEMICOLON", yybuf+yypos)); +YY_RULE(int) yy_SEMICOLON(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "SEMICOLON")); if (!yymatchChar(ctx, ';')) goto l84; if (!yy__(ctx)) goto l84; + yyprintf((stderr, " ok %s @ %s\n", "SEMICOLON", ctx->buf+ctx->pos)); return 1; - l84:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SEMICOLON", yybuf+yypos)); + l84:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "SEMICOLON", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_expression() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "expression")); if (!yy_sequence()) goto l85; +YY_RULE(int) yy_expression(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "expression")); if (!yy_sequence(ctx)) goto l85; l86:; - { int yypos87= yypos, yythunkpos87= yythunkpos; if (!yy_BAR()) goto l87; if (!yy_sequence()) goto l87; yyDo(yy_1_expression, yybegin, yyend); goto l86; - l87:; yypos= yypos87; yythunkpos= yythunkpos87; + { int yypos87= ctx->pos, yythunkpos87= ctx->thunkpos; if (!yy_BAR(ctx)) goto l87; if (!yy_sequence(ctx)) goto l87; yyDo(ctx, yy_1_expression, ctx->begin, ctx->end); goto l86; + l87:; ctx->pos= yypos87; ctx->thunkpos= yythunkpos87; } - yyprintf((stderr, " ok %s @ %s\n", "expression", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "expression", ctx->buf+ctx->pos)); return 1; - l85:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "expression", yybuf+yypos)); + l85:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "expression", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_EQUAL() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "EQUAL")); if (!yymatchChar('=')) goto l88; if (!yy__()) goto l88; - yyprintf((stderr, " ok %s @ %s\n", "EQUAL", yybuf+yypos)); +YY_RULE(int) yy_EQUAL(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "EQUAL")); if (!yymatchChar(ctx, '=')) goto l88; if (!yy__(ctx)) goto l88; + yyprintf((stderr, " ok %s @ %s\n", "EQUAL", ctx->buf+ctx->pos)); return 1; - l88:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "EQUAL", yybuf+yypos)); + l88:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "EQUAL", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_identifier() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "identifier")); yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l89; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\040\000\000\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l89; +YY_RULE(int) yy_identifier(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "identifier")); yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l89; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\040\000\000\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l89; l90:; - { int yypos91= yypos, yythunkpos91= yythunkpos; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\040\377\003\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l91; goto l90; - l91:; yypos= yypos91; yythunkpos= yythunkpos91; - } yyText(yybegin, yyend); if (!(YY_END)) goto l89; if (!yy__()) goto l89; - yyprintf((stderr, " ok %s @ %s\n", "identifier", yybuf+yypos)); + { int yypos91= ctx->pos, yythunkpos91= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\040\377\003\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l91; goto l90; + l91:; ctx->pos= yypos91; ctx->thunkpos= yythunkpos91; + } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l89; if (!yy__(ctx)) goto l89; + yyprintf((stderr, " ok %s @ %s\n", "identifier", ctx->buf+ctx->pos)); return 1; - l89:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "identifier", yybuf+yypos)); + l89:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "identifier", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_RPERCENT() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "RPERCENT")); if (!yymatchString("%}")) goto l92; if (!yy__()) goto l92; - yyprintf((stderr, " ok %s @ %s\n", "RPERCENT", yybuf+yypos)); +YY_RULE(int) yy_RPERCENT(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "RPERCENT")); if (!yymatchString(ctx, "%}")) goto l92; if (!yy__(ctx)) goto l92; + yyprintf((stderr, " ok %s @ %s\n", "RPERCENT", ctx->buf+ctx->pos)); return 1; - l92:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "RPERCENT", yybuf+yypos)); + l92:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "RPERCENT", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_end_of_file() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_end_of_file(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "end_of_file")); - { int yypos94= yypos, yythunkpos94= yythunkpos; if (!yymatchDot()) goto l94; goto l93; - l94:; yypos= yypos94; yythunkpos= yythunkpos94; + { int yypos94= ctx->pos, yythunkpos94= ctx->thunkpos; if (!yymatchDot(ctx)) goto l94; goto l93; + l94:; ctx->pos= yypos94; ctx->thunkpos= yythunkpos94; } - yyprintf((stderr, " ok %s @ %s\n", "end_of_file", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "end_of_file", ctx->buf+ctx->pos)); return 1; - l93:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "end_of_file", yybuf+yypos)); + l93:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "end_of_file", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_trailer() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "trailer")); if (!yymatchString("%%")) goto l95; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l95; +YY_RULE(int) yy_trailer(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "trailer")); if (!yymatchString(ctx, "%%")) goto l95; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l95; l96:; - { int yypos97= yypos, yythunkpos97= yythunkpos; if (!yymatchDot()) goto l97; goto l96; - l97:; yypos= yypos97; yythunkpos= yythunkpos97; - } yyText(yybegin, yyend); if (!(YY_END)) goto l95; yyDo(yy_1_trailer, yybegin, yyend); - yyprintf((stderr, " ok %s @ %s\n", "trailer", yybuf+yypos)); + { int yypos97= ctx->pos, yythunkpos97= ctx->thunkpos; if (!yymatchDot(ctx)) goto l97; goto l96; + l97:; ctx->pos= yypos97; ctx->thunkpos= yythunkpos97; + } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l95; yyDo(ctx, yy_1_trailer, ctx->begin, ctx->end); + yyprintf((stderr, " ok %s @ %s\n", "trailer", ctx->buf+ctx->pos)); return 1; - l95:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "trailer", yybuf+yypos)); + l95:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "trailer", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_definition() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "definition")); if (!yy_identifier()) goto l98; yyDo(yy_1_definition, yybegin, yyend); if (!yy_EQUAL()) goto l98; if (!yy_expression()) goto l98; yyDo(yy_2_definition, yybegin, yyend); - { int yypos99= yypos, yythunkpos99= yythunkpos; if (!yy_SEMICOLON()) goto l99; goto l100; - l99:; yypos= yypos99; yythunkpos= yythunkpos99; +YY_RULE(int) yy_definition(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "definition")); if (!yy_identifier(ctx)) goto l98; yyDo(ctx, yy_1_definition, ctx->begin, ctx->end); if (!yy_EQUAL(ctx)) goto l98; if (!yy_expression(ctx)) goto l98; yyDo(ctx, yy_2_definition, ctx->begin, ctx->end); + { int yypos99= ctx->pos, yythunkpos99= ctx->thunkpos; if (!yy_SEMICOLON(ctx)) goto l99; goto l100; + l99:; ctx->pos= yypos99; ctx->thunkpos= yythunkpos99; } l100:; - yyprintf((stderr, " ok %s @ %s\n", "definition", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "definition", ctx->buf+ctx->pos)); return 1; - l98:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "definition", yybuf+yypos)); + l98:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "definition", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_declaration() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "declaration")); if (!yymatchString("%{")) goto l101; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l101; +YY_RULE(int) yy_declaration(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "declaration")); if (!yymatchString(ctx, "%{")) goto l101; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l101; l102:; - { int yypos103= yypos, yythunkpos103= yythunkpos; - { int yypos104= yypos, yythunkpos104= yythunkpos; if (!yymatchString("%}")) goto l104; goto l103; - l104:; yypos= yypos104; yythunkpos= yythunkpos104; - } if (!yymatchDot()) goto l103; goto l102; - l103:; yypos= yypos103; yythunkpos= yythunkpos103; - } yyText(yybegin, yyend); if (!(YY_END)) goto l101; if (!yy_RPERCENT()) goto l101; yyDo(yy_1_declaration, yybegin, yyend); - yyprintf((stderr, " ok %s @ %s\n", "declaration", yybuf+yypos)); + { int yypos103= ctx->pos, yythunkpos103= ctx->thunkpos; + { int yypos104= ctx->pos, yythunkpos104= ctx->thunkpos; if (!yymatchString(ctx, "%}")) goto l104; goto l103; + l104:; ctx->pos= yypos104; ctx->thunkpos= yythunkpos104; + } if (!yymatchDot(ctx)) goto l103; goto l102; + l103:; ctx->pos= yypos103; ctx->thunkpos= yythunkpos103; + } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l101; if (!yy_RPERCENT(ctx)) goto l101; yyDo(ctx, yy_1_declaration, ctx->begin, ctx->end); + yyprintf((stderr, " ok %s @ %s\n", "declaration", ctx->buf+ctx->pos)); return 1; - l101:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "declaration", yybuf+yypos)); + l101:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "declaration", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy__() +YY_RULE(int) yy__(yycontext *ctx) { yyprintf((stderr, "%s\n", "_")); l106:; - { int yypos107= yypos, yythunkpos107= yythunkpos; - { int yypos108= yypos, yythunkpos108= yythunkpos; if (!yy_space()) goto l109; goto l108; - l109:; yypos= yypos108; yythunkpos= yythunkpos108; if (!yy_comment()) goto l107; + { int yypos107= ctx->pos, yythunkpos107= ctx->thunkpos; + { int yypos108= ctx->pos, yythunkpos108= ctx->thunkpos; if (!yy_space(ctx)) goto l109; goto l108; + l109:; ctx->pos= yypos108; ctx->thunkpos= yythunkpos108; if (!yy_comment(ctx)) goto l107; } l108:; goto l106; - l107:; yypos= yypos107; yythunkpos= yythunkpos107; + l107:; ctx->pos= yypos107; ctx->thunkpos= yythunkpos107; } - yyprintf((stderr, " ok %s @ %s\n", "_", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "_", ctx->buf+ctx->pos)); return 1; } -YY_RULE(int) yy_grammar() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "grammar")); if (!yy__()) goto l110; - { int yypos113= yypos, yythunkpos113= yythunkpos; if (!yy_declaration()) goto l114; goto l113; - l114:; yypos= yypos113; yythunkpos= yythunkpos113; if (!yy_definition()) goto l110; +YY_RULE(int) yy_grammar(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "grammar")); if (!yy__(ctx)) goto l110; + { int yypos113= ctx->pos, yythunkpos113= ctx->thunkpos; if (!yy_declaration(ctx)) goto l114; goto l113; + l114:; ctx->pos= yypos113; ctx->thunkpos= yythunkpos113; if (!yy_definition(ctx)) goto l110; } l113:; l111:; - { int yypos112= yypos, yythunkpos112= yythunkpos; - { int yypos115= yypos, yythunkpos115= yythunkpos; if (!yy_declaration()) goto l116; goto l115; - l116:; yypos= yypos115; yythunkpos= yythunkpos115; if (!yy_definition()) goto l112; + { int yypos112= ctx->pos, yythunkpos112= ctx->thunkpos; + { int yypos115= ctx->pos, yythunkpos115= ctx->thunkpos; if (!yy_declaration(ctx)) goto l116; goto l115; + l116:; ctx->pos= yypos115; ctx->thunkpos= yythunkpos115; if (!yy_definition(ctx)) goto l112; } l115:; goto l111; - l112:; yypos= yypos112; yythunkpos= yythunkpos112; + l112:; ctx->pos= yypos112; ctx->thunkpos= yythunkpos112; } - { int yypos117= yypos, yythunkpos117= yythunkpos; if (!yy_trailer()) goto l117; goto l118; - l117:; yypos= yypos117; yythunkpos= yythunkpos117; + { int yypos117= ctx->pos, yythunkpos117= ctx->thunkpos; if (!yy_trailer(ctx)) goto l117; goto l118; + l117:; ctx->pos= yypos117; ctx->thunkpos= yythunkpos117; } - l118:; if (!yy_end_of_file()) goto l110; - yyprintf((stderr, " ok %s @ %s\n", "grammar", yybuf+yypos)); + l118:; if (!yy_end_of_file(ctx)) goto l110; + yyprintf((stderr, " ok %s @ %s\n", "grammar", ctx->buf+ctx->pos)); return 1; - l110:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "grammar", yybuf+yypos)); + l110:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "grammar", ctx->buf+ctx->pos)); return 0; } #ifndef YY_PART -typedef int (*yyrule)(); +typedef int (*yyrule)(yycontext *ctx); -YY_PARSE(int) YYPARSEFROM(yyrule yystart) +YY_PARSE(int) YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart) { int yyok; - if (!yybuflen) + if (!yyctx->buflen) { - yybuflen= 1024; - yybuf= malloc(yybuflen); - yytextlen= 1024; - yytext= malloc(yytextlen); - yythunkslen= 32; - yythunks= malloc(sizeof(yythunk) * yythunkslen); - yyvalslen= 32; - yyvals= malloc(sizeof(YYSTYPE) * yyvalslen); - yybegin= yyend= yypos= yylimit= yythunkpos= 0; + yyctx->buflen= 1024; + yyctx->buf= (char *)malloc(yyctx->buflen); + yyctx->textlen= 1024; + yyctx->text= (char *)malloc(yyctx->textlen); + yyctx->thunkslen= 32; + yyctx->thunks= (yythunk *)malloc(sizeof(yythunk) * yyctx->thunkslen); + yyctx->valslen= 32; + yyctx->vals= (YYSTYPE *)malloc(sizeof(YYSTYPE) * yyctx->valslen); + yyctx->begin= yyctx->end= yyctx->pos= yyctx->limit= yyctx->thunkpos= 0; } - yybegin= yyend= yypos; - yythunkpos= 0; - yyval= yyvals; - yyok= yystart(); - if (yyok) yyDone(); - yyCommit(); + yyctx->begin= yyctx->end= yyctx->pos; + yyctx->thunkpos= 0; + yyctx->val= yyctx->vals; + yyok= yystart(yyctx); + if (yyok) yyDone(yyctx); + yyCommit(yyctx); return yyok; - (void)yyrefill; - (void)yymatchDot; - (void)yymatchChar; - (void)yymatchString; - (void)yymatchClass; - (void)yyDo; - (void)yyText; - (void)yyDone; - (void)yyCommit; - (void)yyAccept; - (void)yyPush; - (void)yyPop; - (void)yySet; - (void)yytextmax; } -YY_PARSE(int) YYPARSE(void) +YY_PARSE(int) YYPARSE(YY_CTX_PARAM) { - return YYPARSEFROM(yy_grammar); + return YYPARSEFROM(YY_CTX_ARG_ yy_grammar); } #endif @@ -935,17 +1064,17 @@ YY_PARSE(int) YYPARSE(void) void yyerror(char *message) { fprintf(stderr, "%s:%d: %s", fileName, lineNumber, message); - if (yytext[0]) fprintf(stderr, " near token '%s'", yytext); - if (yypos < yylimit || !feof(input)) + if (yyctx->text[0]) fprintf(stderr, " near token '%s'", yyctx->text); + if (yyctx->pos < yyctx->limit || !feof(input)) { - yybuf[yylimit]= '\0'; + yyctx->buf[yyctx->limit]= '\0'; fprintf(stderr, " before text \""); - while (yypos < yylimit) + while (yyctx->pos < yyctx->limit) { - if ('\n' == yybuf[yypos] || '\r' == yybuf[yypos]) break; - fputc(yybuf[yypos++], stderr); + if ('\n' == yyctx->buf[yyctx->pos] || '\r' == yyctx->buf[yyctx->pos]) break; + fputc(yyctx->buf[yyctx->pos++], stderr); } - if (yypos == yylimit) + if (yyctx->pos == yyctx->limit) { int c; while (EOF != (c= fgetc(input)) && '\n' != c && '\r' != c) diff --git a/leg.leg b/leg.leg index 398129d..b94cda5 100644 --- a/leg.leg +++ b/leg.leg @@ -15,7 +15,7 @@ # # THE SOFTWARE IS PROVIDED 'AS IS'. USE ENTIRELY AT YOUR OWN RISK. # -# Last edited: 2012-03-23 03:16:17 by piumarta on emilia +# Last edited: 2012-04-29 15:51:15 by piumarta on emilia %{ # include "tree.h" @@ -148,17 +148,17 @@ end-of-file= !. void yyerror(char *message) { fprintf(stderr, "%s:%d: %s", fileName, lineNumber, message); - if (yytext[0]) fprintf(stderr, " near token '%s'", yytext); - if (yypos < yylimit || !feof(input)) + if (yyctx->text[0]) fprintf(stderr, " near token '%s'", yyctx->text); + if (yyctx->pos < yyctx->limit || !feof(input)) { - yybuf[yylimit]= '\0'; + yyctx->buf[yyctx->limit]= '\0'; fprintf(stderr, " before text \""); - while (yypos < yylimit) + while (yyctx->pos < yyctx->limit) { - if ('\n' == yybuf[yypos] || '\r' == yybuf[yypos]) break; - fputc(yybuf[yypos++], stderr); + if ('\n' == yyctx->buf[yyctx->pos] || '\r' == yyctx->buf[yyctx->pos]) break; + fputc(yyctx->buf[yyctx->pos++], stderr); } - if (yypos == yylimit) + if (yyctx->pos == yyctx->limit) { int c; while (EOF != (c= fgetc(input)) && '\n' != c && '\r' != c) diff --git a/peg.1 b/peg.1 index aa4b947..2736f59 100644 --- a/peg.1 +++ b/peg.1 @@ -13,9 +13,9 @@ .\" .\" THE SOFTWARE IS PROVIDED 'AS IS'. USE ENTIRELY AT YOUR OWN RISK. .\" -.\" Last edited: 2007-09-13 08:40:20 by piumarta on emilia.local +.\" Last edited: 2012-04-29 16:58:44 by piumarta on emilia .\" -.TH PEG 1 "May 2007" "Version 0.1" +.TH PEG 1 "April 2012" "Version 0.1" .SH NAME peg, leg \- parser generators .SH SYNOPSIS @@ -745,6 +745,48 @@ be redefined to declare them 'static'. #define YY_PARSE(T) static T .fi +.TP +.BI YY_CTX_LOCAL +If this symbol is defined during compilation of a generated parser +then global parser state will be kept in a structure of +type 'yycontext' which can be declared as a local variable. This +allows multiple instances of parsers to coexist and to be thread-safe. +The parsing function +.IR yyparse () +will be declared to expect a first argument of type 'yycontext *', an +instance of the structure holding the global state for the parser. +This instance must be allocated and initialised to zero by the client. +A trivial but complete example is as follows. +.nf + + #include + + #define YY_CTX_LOCAL + + #include "the-generated-parser.peg.c" + + int main() + { + yycontext ctx; + memset(&ctx, 0, sizeof(yycontext)); + while (yyparse(&ctx)); + return 0; + } + +.fi +Note that if this symbol is undefined then the compiled parser will +statically allocate its global state and will be neither reentrant nor +thread-safe. +.TP +.BI YY_CTX_MEMBERS +If YY_CTX_LOCAL is defined (see above) then the macro YY_CTX_MEMBERS +can be defined to expand to any additional member field declarations +that the client would like included in the declaration of +the 'yycontext' structure type. These additional members are +otherwise ignored by the generated parser. The instance +of 'yycontext' associated with the currently-active parser is +available in actions through the pointer variable +.IR yyctx . .PP The following variables can be reffered to within actions. .TP @@ -761,6 +803,10 @@ The most recent matched text delimited by '<' and '>' is stored in this variable .TP .B int yyleng This variable indicates the number of characters in 'yytext'. +.TP +.B yycontext *yyctx +This variable points to the instance of 'yycontext' associated with +the currently-active parser. .SH DIAGNOSTICS .I peg and diff --git a/peg.c b/peg.c index 9a22537..090dc61 100644 --- a/peg.c +++ b/peg.c @@ -13,7 +13,7 @@ * * THE SOFTWARE IS PROVIDED 'AS IS'. USE ENTIRELY AT YOUR OWN RISK. * - * Last edited: 2007-09-12 00:27:30 by piumarta on vps2.piumarta.com + * Last edited: 2012-04-29 15:49:09 by piumarta on emilia */ #include "tree.h" @@ -50,17 +50,17 @@ void yyerror(char *message); void yyerror(char *message) { fprintf(stderr, "%s:%d: %s", fileName, lineNumber, message); - if (yytext[0]) fprintf(stderr, " near token '%s'", yytext); - if (yypos < yylimit || !feof(input)) + if (yyctx->text[0]) fprintf(stderr, " near token '%s'", yyctx->text); + if (yyctx->pos < yyctx->limit || !feof(input)) { - yybuf[yylimit]= '\0'; + yyctx->buf[yyctx->limit]= '\0'; fprintf(stderr, " before text \""); - while (yypos < yylimit) + while (yyctx->pos < yyctx->limit) { - if ('\n' == yybuf[yypos] || '\r' == yybuf[yypos]) break; - fputc(yybuf[yypos++], stderr); + if ('\n' == yyctx->buf[yyctx->pos] || '\r' == yyctx->buf[yyctx->pos]) break; + fputc(yyctx->buf[yyctx->pos++], stderr); } - if (yypos == yylimit) + if (yyctx->pos == yyctx->limit) { int c; while (EOF != (c= fgetc(input)) && '\n' != c && '\r' != c) diff --git a/peg.peg-c b/peg.peg-c index de13ea3..cc03789 100644 --- a/peg.peg-c +++ b/peg.peg-c @@ -1,12 +1,9 @@ -/* A recursive-descent parser generated by peg 0.1.7 */ +/* A recursive-descent parser generated by peg 0.1.9 */ #include #include #include #define YYRULECOUNT 32 -#ifndef YY_VARIABLE -#define YY_VARIABLE(T) static T -#endif #ifndef YY_LOCAL #define YY_LOCAL(T) static T #endif @@ -34,10 +31,10 @@ } #endif #ifndef YY_BEGIN -#define YY_BEGIN ( yybegin= yypos, 1) +#define YY_BEGIN ( ctx->begin= ctx->pos, 1) #endif #ifndef YY_END -#define YY_END ( yyend= yypos, 1) +#define YY_END ( ctx->end= ctx->pos, 1) #endif #ifdef YY_DEBUG # define yyprintf(args) fprintf args @@ -50,148 +47,168 @@ #ifndef YY_PART -typedef void (*yyaction)(char *yytext, int yyleng); +typedef struct _yycontext yycontext; +typedef void (*yyaction)(yycontext *ctx, char *yytext, int yyleng); typedef struct _yythunk { int begin, end; yyaction action; struct _yythunk *next; } yythunk; -YY_VARIABLE(char * ) yybuf= 0; -YY_VARIABLE(int ) yybuflen= 0; -YY_VARIABLE(int ) yypos= 0; -YY_VARIABLE(int ) yylimit= 0; -YY_VARIABLE(char * ) yytext= 0; -YY_VARIABLE(int ) yytextlen= 0; -YY_VARIABLE(int ) yybegin= 0; -YY_VARIABLE(int ) yyend= 0; -YY_VARIABLE(int ) yytextmax= 0; -YY_VARIABLE(yythunk *) yythunks= 0; -YY_VARIABLE(int ) yythunkslen= 0; -YY_VARIABLE(int ) yythunkpos= 0; -YY_VARIABLE(YYSTYPE ) yy; -YY_VARIABLE(YYSTYPE *) yyval= 0; -YY_VARIABLE(YYSTYPE *) yyvals= 0; -YY_VARIABLE(int ) yyvalslen= 0; +struct _yycontext { + char *buf; + int buflen; + int pos; + int limit; + char *text; + int textlen; + int begin; + int end; + int textmax; + yythunk *thunks; + int thunkslen; + int thunkpos; + YYSTYPE yy; + YYSTYPE *val; + YYSTYPE *vals; + int valslen; +#ifdef YY_CTX_MEMBERS + YY_CTX_MEMBERS +#endif +}; + +#ifdef YY_CTX_LOCAL +#define YY_CTX_PARAM_ yycontext *yyctx, +#define YY_CTX_PARAM yycontext *yyctx +#define YY_CTX_ARG_ yyctx, +#define YY_CTX_ARG yyctx +#else +#define YY_CTX_PARAM_ +#define YY_CTX_PARAM +#define YY_CTX_ARG_ +#define YY_CTX_ARG +yycontext yyctx0; +yycontext *yyctx= &yyctx0; +#endif -YY_LOCAL(int) yyrefill(void) +YY_LOCAL(int) yyrefill(yycontext *ctx) { int yyn; - while (yybuflen - yypos < 512) + while (ctx->buflen - ctx->pos < 512) { - yybuflen *= 2; - yybuf= realloc(yybuf, yybuflen); + ctx->buflen *= 2; + ctx->buf= (char *)realloc(ctx->buf, ctx->buflen); } - YY_INPUT((yybuf + yypos), yyn, (yybuflen - yypos)); + YY_INPUT((ctx->buf + ctx->pos), yyn, (ctx->buflen - ctx->pos)); if (!yyn) return 0; - yylimit += yyn; + ctx->limit += yyn; return 1; } -YY_LOCAL(int) yymatchDot(void) +YY_LOCAL(int) yymatchDot(yycontext *ctx) { - if (yypos >= yylimit && !yyrefill()) return 0; - ++yypos; + if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0; + ++ctx->pos; return 1; } -YY_LOCAL(int) yymatchChar(int c) +YY_LOCAL(int) yymatchChar(yycontext *ctx, int c) { - if (yypos >= yylimit && !yyrefill()) return 0; - if ((unsigned char)yybuf[yypos] == c) + if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0; + if ((unsigned char)ctx->buf[ctx->pos] == c) { - ++yypos; - yyprintf((stderr, " ok yymatchChar(%c) @ %s\n", c, yybuf+yypos)); + ++ctx->pos; + yyprintf((stderr, " ok yymatchChar(ctx, %c) @ %s\n", c, ctx->buf+ctx->pos)); return 1; } - yyprintf((stderr, " fail yymatchChar(%c) @ %s\n", c, yybuf+yypos)); + yyprintf((stderr, " fail yymatchChar(ctx, %c) @ %s\n", c, ctx->buf+ctx->pos)); return 0; } -YY_LOCAL(int) yymatchString(char *s) +YY_LOCAL(int) yymatchString(yycontext *ctx, char *s) { - int yysav= yypos; + int yysav= ctx->pos; while (*s) { - if (yypos >= yylimit && !yyrefill()) return 0; - if (yybuf[yypos] != *s) + if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0; + if (ctx->buf[ctx->pos] != *s) { - yypos= yysav; + ctx->pos= yysav; return 0; } ++s; - ++yypos; + ++ctx->pos; } return 1; } -YY_LOCAL(int) yymatchClass(unsigned char *bits) +YY_LOCAL(int) yymatchClass(yycontext *ctx, unsigned char *bits) { int c; - if (yypos >= yylimit && !yyrefill()) return 0; - c= (unsigned char)yybuf[yypos]; + if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0; + c= (unsigned char)ctx->buf[ctx->pos]; if (bits[c >> 3] & (1 << (c & 7))) { - ++yypos; - yyprintf((stderr, " ok yymatchClass @ %s\n", yybuf+yypos)); + ++ctx->pos; + yyprintf((stderr, " ok yymatchClass @ %s\n", ctx->buf+ctx->pos)); return 1; } - yyprintf((stderr, " fail yymatchClass @ %s\n", yybuf+yypos)); + yyprintf((stderr, " fail yymatchClass @ %s\n", ctx->buf+ctx->pos)); return 0; } -YY_LOCAL(void) yyDo(yyaction action, int begin, int end) +YY_LOCAL(void) yyDo(yycontext *ctx, yyaction action, int begin, int end) { - while (yythunkpos >= yythunkslen) + while (ctx->thunkpos >= ctx->thunkslen) { - yythunkslen *= 2; - yythunks= realloc(yythunks, sizeof(yythunk) * yythunkslen); + ctx->thunkslen *= 2; + ctx->thunks= (yythunk *)realloc(ctx->thunks, sizeof(yythunk) * ctx->thunkslen); } - yythunks[yythunkpos].begin= begin; - yythunks[yythunkpos].end= end; - yythunks[yythunkpos].action= action; - ++yythunkpos; + ctx->thunks[ctx->thunkpos].begin= begin; + ctx->thunks[ctx->thunkpos].end= end; + ctx->thunks[ctx->thunkpos].action= action; + ++ctx->thunkpos; } -YY_LOCAL(int) yyText(int begin, int end) +YY_LOCAL(int) yyText(yycontext *ctx, int begin, int end) { int yyleng= end - begin; if (yyleng <= 0) yyleng= 0; else { - while (yytextlen < (yyleng + 1)) + while (ctx->textlen < (yyleng + 1)) { - yytextlen *= 2; - yytext= realloc(yytext, yytextlen); + ctx->textlen *= 2; + ctx->text= (char *)realloc(ctx->text, ctx->textlen); } - memcpy(yytext, yybuf + begin, yyleng); + memcpy(ctx->text, ctx->buf + begin, yyleng); } - yytext[yyleng]= '\0'; + ctx->text[yyleng]= '\0'; return yyleng; } -YY_LOCAL(void) yyDone(void) +YY_LOCAL(void) yyDone(yycontext *ctx) { int pos; - for (pos= 0; pos < yythunkpos; ++pos) + for (pos= 0; pos < ctx->thunkpos; ++pos) { - yythunk *thunk= &yythunks[pos]; - int yyleng= thunk->end ? yyText(thunk->begin, thunk->end) : thunk->begin; - yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, yytext)); - thunk->action(yytext, yyleng); + yythunk *thunk= &ctx->thunks[pos]; + int yyleng= thunk->end ? yyText(ctx, thunk->begin, thunk->end) : thunk->begin; + yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, ctx->text)); + thunk->action(ctx, ctx->text, yyleng); } - yythunkpos= 0; + ctx->thunkpos= 0; } -YY_LOCAL(void) yyCommit() +YY_LOCAL(void) yyCommit(yycontext *ctx) { - if ((yylimit -= yypos)) + if ((ctx->limit -= ctx->pos)) { - memmove(yybuf, yybuf + yypos, yylimit); + memmove(ctx->buf, ctx->buf + ctx->pos, ctx->limit); } - yybegin -= yypos; - yyend -= yypos; - yypos= yythunkpos= 0; + ctx->begin -= ctx->pos; + ctx->end -= ctx->pos; + ctx->pos= ctx->thunkpos= 0; } -YY_LOCAL(int) yyAccept(int tp0) +YY_LOCAL(int) yyAccept(yycontext *ctx, int tp0) { if (tp0) { @@ -200,602 +217,696 @@ YY_LOCAL(int) yyAccept(int tp0) } else { - yyDone(); - yyCommit(); + yyDone(ctx); + yyCommit(ctx); } return 1; } -YY_LOCAL(void) yyPush(char *text, int count) { yyval += count; } -YY_LOCAL(void) yyPop(char *text, int count) { yyval -= count; } -YY_LOCAL(void) yySet(char *text, int count) { yyval[count]= yy; } +YY_LOCAL(void) yyPush(yycontext *ctx, char *text, int count) { ctx->val += count; } +YY_LOCAL(void) yyPop(yycontext *ctx, char *text, int count) { ctx->val -= count; } +YY_LOCAL(void) yySet(yycontext *ctx, char *text, int count) { ctx->val[count]= ctx->yy; } #endif /* YY_PART */ -#define YYACCEPT yyAccept(yythunkpos0) +#define YYACCEPT yyAccept(ctx, yythunkpos0) -YY_RULE(int) yy_EndOfLine(); /* 32 */ -YY_RULE(int) yy_Comment(); /* 31 */ -YY_RULE(int) yy_Space(); /* 30 */ -YY_RULE(int) yy_Range(); /* 29 */ -YY_RULE(int) yy_Char(); /* 28 */ -YY_RULE(int) yy_IdentCont(); /* 27 */ -YY_RULE(int) yy_IdentStart(); /* 26 */ -YY_RULE(int) yy_END(); /* 25 */ -YY_RULE(int) yy_BEGIN(); /* 24 */ -YY_RULE(int) yy_DOT(); /* 23 */ -YY_RULE(int) yy_Class(); /* 22 */ -YY_RULE(int) yy_Literal(); /* 21 */ -YY_RULE(int) yy_CLOSE(); /* 20 */ -YY_RULE(int) yy_OPEN(); /* 19 */ -YY_RULE(int) yy_PLUS(); /* 18 */ -YY_RULE(int) yy_STAR(); /* 17 */ -YY_RULE(int) yy_QUESTION(); /* 16 */ -YY_RULE(int) yy_Primary(); /* 15 */ -YY_RULE(int) yy_NOT(); /* 14 */ -YY_RULE(int) yy_Suffix(); /* 13 */ -YY_RULE(int) yy_Action(); /* 12 */ -YY_RULE(int) yy_AND(); /* 11 */ -YY_RULE(int) yy_Prefix(); /* 10 */ -YY_RULE(int) yy_SLASH(); /* 9 */ -YY_RULE(int) yy_Sequence(); /* 8 */ -YY_RULE(int) yy_Expression(); /* 7 */ -YY_RULE(int) yy_LEFTARROW(); /* 6 */ -YY_RULE(int) yy_Identifier(); /* 5 */ -YY_RULE(int) yy_EndOfFile(); /* 4 */ -YY_RULE(int) yy_Definition(); /* 3 */ -YY_RULE(int) yy_Spacing(); /* 2 */ -YY_RULE(int) yy_Grammar(); /* 1 */ +YY_RULE(int) yy_EndOfLine(yycontext *ctx); /* 32 */ +YY_RULE(int) yy_Comment(yycontext *ctx); /* 31 */ +YY_RULE(int) yy_Space(yycontext *ctx); /* 30 */ +YY_RULE(int) yy_Range(yycontext *ctx); /* 29 */ +YY_RULE(int) yy_Char(yycontext *ctx); /* 28 */ +YY_RULE(int) yy_IdentCont(yycontext *ctx); /* 27 */ +YY_RULE(int) yy_IdentStart(yycontext *ctx); /* 26 */ +YY_RULE(int) yy_END(yycontext *ctx); /* 25 */ +YY_RULE(int) yy_BEGIN(yycontext *ctx); /* 24 */ +YY_RULE(int) yy_DOT(yycontext *ctx); /* 23 */ +YY_RULE(int) yy_Class(yycontext *ctx); /* 22 */ +YY_RULE(int) yy_Literal(yycontext *ctx); /* 21 */ +YY_RULE(int) yy_CLOSE(yycontext *ctx); /* 20 */ +YY_RULE(int) yy_OPEN(yycontext *ctx); /* 19 */ +YY_RULE(int) yy_PLUS(yycontext *ctx); /* 18 */ +YY_RULE(int) yy_STAR(yycontext *ctx); /* 17 */ +YY_RULE(int) yy_QUESTION(yycontext *ctx); /* 16 */ +YY_RULE(int) yy_Primary(yycontext *ctx); /* 15 */ +YY_RULE(int) yy_NOT(yycontext *ctx); /* 14 */ +YY_RULE(int) yy_Suffix(yycontext *ctx); /* 13 */ +YY_RULE(int) yy_Action(yycontext *ctx); /* 12 */ +YY_RULE(int) yy_AND(yycontext *ctx); /* 11 */ +YY_RULE(int) yy_Prefix(yycontext *ctx); /* 10 */ +YY_RULE(int) yy_SLASH(yycontext *ctx); /* 9 */ +YY_RULE(int) yy_Sequence(yycontext *ctx); /* 8 */ +YY_RULE(int) yy_Expression(yycontext *ctx); /* 7 */ +YY_RULE(int) yy_LEFTARROW(yycontext *ctx); /* 6 */ +YY_RULE(int) yy_Identifier(yycontext *ctx); /* 5 */ +YY_RULE(int) yy_EndOfFile(yycontext *ctx); /* 4 */ +YY_RULE(int) yy_Definition(yycontext *ctx); /* 3 */ +YY_RULE(int) yy_Spacing(yycontext *ctx); /* 2 */ +YY_RULE(int) yy_Grammar(yycontext *ctx); /* 1 */ -YY_ACTION(void) yy_7_Primary(char *yytext, int yyleng) +YY_ACTION(void) yy_7_Primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_7_Primary\n")); push(makePredicate("YY_END")); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_6_Primary(char *yytext, int yyleng) +YY_ACTION(void) yy_6_Primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_6_Primary\n")); push(makePredicate("YY_BEGIN")); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_5_Primary(char *yytext, int yyleng) +YY_ACTION(void) yy_5_Primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_5_Primary\n")); push(makeAction(yytext)); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_4_Primary(char *yytext, int yyleng) +YY_ACTION(void) yy_4_Primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_4_Primary\n")); push(makeDot()); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_3_Primary(char *yytext, int yyleng) +YY_ACTION(void) yy_3_Primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_3_Primary\n")); push(makeClass(yytext)); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_2_Primary(char *yytext, int yyleng) +YY_ACTION(void) yy_2_Primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_2_Primary\n")); push(makeString(yytext)); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_Primary(char *yytext, int yyleng) +YY_ACTION(void) yy_1_Primary(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_Primary\n")); push(makeName(findRule(yytext))); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_3_Suffix(char *yytext, int yyleng) +YY_ACTION(void) yy_3_Suffix(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_3_Suffix\n")); push(makePlus (pop())); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_2_Suffix(char *yytext, int yyleng) +YY_ACTION(void) yy_2_Suffix(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_2_Suffix\n")); push(makeStar (pop())); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_Suffix(char *yytext, int yyleng) +YY_ACTION(void) yy_1_Suffix(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_Suffix\n")); push(makeQuery(pop())); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_3_Prefix(char *yytext, int yyleng) +YY_ACTION(void) yy_3_Prefix(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_3_Prefix\n")); push(makePeekNot(pop())); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_2_Prefix(char *yytext, int yyleng) +YY_ACTION(void) yy_2_Prefix(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_2_Prefix\n")); push(makePeekFor(pop())); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_Prefix(char *yytext, int yyleng) +YY_ACTION(void) yy_1_Prefix(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_Prefix\n")); push(makePredicate(yytext)); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_2_Sequence(char *yytext, int yyleng) +YY_ACTION(void) yy_2_Sequence(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_2_Sequence\n")); push(makePredicate("1")); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_Sequence(char *yytext, int yyleng) +YY_ACTION(void) yy_1_Sequence(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_Sequence\n")); Node *f= pop(); push(Sequence_append(pop(), f)); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_Expression(char *yytext, int yyleng) +YY_ACTION(void) yy_1_Expression(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_Expression\n")); Node *f= pop(); push(Alternate_append(pop(), f)); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_2_Definition(char *yytext, int yyleng) +YY_ACTION(void) yy_2_Definition(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_2_Definition\n")); Node *e= pop(); Rule_setExpression(pop(), e); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_ACTION(void) yy_1_Definition(char *yytext, int yyleng) +YY_ACTION(void) yy_1_Definition(yycontext *ctx, char *yytext, int yyleng) { +#define yy ctx->yy +#define yypos ctx->pos +#define yythunkpos ctx->thunkpos yyprintf((stderr, "do yy_1_Definition\n")); if (push(beginRule(findRule(yytext)))->rule.expression) fprintf(stderr, "rule '%s' redefined\n", yytext); ; +#undef yythunkpos +#undef yypos +#undef yy } -YY_RULE(int) yy_EndOfLine() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_EndOfLine(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "EndOfLine")); - { int yypos2= yypos, yythunkpos2= yythunkpos; if (!yymatchString("\r\n")) goto l3; goto l2; - l3:; yypos= yypos2; yythunkpos= yythunkpos2; if (!yymatchChar('\n')) goto l4; goto l2; - l4:; yypos= yypos2; yythunkpos= yythunkpos2; if (!yymatchChar('\r')) goto l1; + { int yypos2= ctx->pos, yythunkpos2= ctx->thunkpos; if (!yymatchString(ctx, "\r\n")) goto l3; goto l2; + l3:; ctx->pos= yypos2; ctx->thunkpos= yythunkpos2; if (!yymatchChar(ctx, '\n')) goto l4; goto l2; + l4:; ctx->pos= yypos2; ctx->thunkpos= yythunkpos2; if (!yymatchChar(ctx, '\r')) goto l1; } l2:; - yyprintf((stderr, " ok %s @ %s\n", "EndOfLine", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "EndOfLine", ctx->buf+ctx->pos)); return 1; - l1:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "EndOfLine", yybuf+yypos)); + l1:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "EndOfLine", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Comment() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "Comment")); if (!yymatchChar('#')) goto l5; +YY_RULE(int) yy_Comment(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "Comment")); if (!yymatchChar(ctx, '#')) goto l5; l6:; - { int yypos7= yypos, yythunkpos7= yythunkpos; - { int yypos8= yypos, yythunkpos8= yythunkpos; if (!yy_EndOfLine()) goto l8; goto l7; - l8:; yypos= yypos8; yythunkpos= yythunkpos8; - } if (!yymatchDot()) goto l7; goto l6; - l7:; yypos= yypos7; yythunkpos= yythunkpos7; - } if (!yy_EndOfLine()) goto l5; - yyprintf((stderr, " ok %s @ %s\n", "Comment", yybuf+yypos)); + { int yypos7= ctx->pos, yythunkpos7= ctx->thunkpos; + { int yypos8= ctx->pos, yythunkpos8= ctx->thunkpos; if (!yy_EndOfLine(ctx)) goto l8; goto l7; + l8:; ctx->pos= yypos8; ctx->thunkpos= yythunkpos8; + } if (!yymatchDot(ctx)) goto l7; goto l6; + l7:; ctx->pos= yypos7; ctx->thunkpos= yythunkpos7; + } if (!yy_EndOfLine(ctx)) goto l5; + yyprintf((stderr, " ok %s @ %s\n", "Comment", ctx->buf+ctx->pos)); return 1; - l5:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Comment", yybuf+yypos)); + l5:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Comment", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Space() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_Space(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "Space")); - { int yypos10= yypos, yythunkpos10= yythunkpos; if (!yymatchChar(' ')) goto l11; goto l10; - l11:; yypos= yypos10; yythunkpos= yythunkpos10; if (!yymatchChar('\t')) goto l12; goto l10; - l12:; yypos= yypos10; yythunkpos= yythunkpos10; if (!yy_EndOfLine()) goto l9; + { int yypos10= ctx->pos, yythunkpos10= ctx->thunkpos; if (!yymatchChar(ctx, ' ')) goto l11; goto l10; + l11:; ctx->pos= yypos10; ctx->thunkpos= yythunkpos10; if (!yymatchChar(ctx, '\t')) goto l12; goto l10; + l12:; ctx->pos= yypos10; ctx->thunkpos= yythunkpos10; if (!yy_EndOfLine(ctx)) goto l9; } l10:; - yyprintf((stderr, " ok %s @ %s\n", "Space", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "Space", ctx->buf+ctx->pos)); return 1; - l9:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Space", yybuf+yypos)); + l9:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Space", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Range() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_Range(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "Range")); - { int yypos14= yypos, yythunkpos14= yythunkpos; if (!yy_Char()) goto l15; if (!yymatchChar('-')) goto l15; if (!yy_Char()) goto l15; goto l14; - l15:; yypos= yypos14; yythunkpos= yythunkpos14; if (!yy_Char()) goto l13; + { int yypos14= ctx->pos, yythunkpos14= ctx->thunkpos; if (!yy_Char(ctx)) goto l15; if (!yymatchChar(ctx, '-')) goto l15; if (!yy_Char(ctx)) goto l15; goto l14; + l15:; ctx->pos= yypos14; ctx->thunkpos= yythunkpos14; if (!yy_Char(ctx)) goto l13; } l14:; - yyprintf((stderr, " ok %s @ %s\n", "Range", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "Range", ctx->buf+ctx->pos)); return 1; - l13:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Range", yybuf+yypos)); + l13:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Range", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Char() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_Char(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "Char")); - { int yypos17= yypos, yythunkpos17= yythunkpos; if (!yymatchChar('\\')) goto l18; if (!yymatchClass((unsigned char *)"\000\000\000\000\204\000\000\000\000\000\000\070\146\100\124\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l18; goto l17; - l18:; yypos= yypos17; yythunkpos= yythunkpos17; if (!yymatchChar('\\')) goto l19; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\017\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l19; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l19; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l19; goto l17; - l19:; yypos= yypos17; yythunkpos= yythunkpos17; if (!yymatchChar('\\')) goto l20; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l20; - { int yypos21= yypos, yythunkpos21= yythunkpos; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l21; goto l22; - l21:; yypos= yypos21; yythunkpos= yythunkpos21; + { int yypos17= ctx->pos, yythunkpos17= ctx->thunkpos; if (!yymatchChar(ctx, '\\')) goto l18; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\204\000\000\000\000\000\000\070\146\100\124\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l18; goto l17; + l18:; ctx->pos= yypos17; ctx->thunkpos= yythunkpos17; if (!yymatchChar(ctx, '\\')) goto l19; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\017\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l19; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l19; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l19; goto l17; + l19:; ctx->pos= yypos17; ctx->thunkpos= yythunkpos17; if (!yymatchChar(ctx, '\\')) goto l20; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l20; + { int yypos21= ctx->pos, yythunkpos21= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l21; goto l22; + l21:; ctx->pos= yypos21; ctx->thunkpos= yythunkpos21; } l22:; goto l17; - l20:; yypos= yypos17; yythunkpos= yythunkpos17; if (!yymatchChar('\\')) goto l23; if (!yymatchChar('-')) goto l23; goto l17; - l23:; yypos= yypos17; yythunkpos= yythunkpos17; - { int yypos24= yypos, yythunkpos24= yythunkpos; if (!yymatchChar('\\')) goto l24; goto l16; - l24:; yypos= yypos24; yythunkpos= yythunkpos24; - } if (!yymatchDot()) goto l16; + l20:; ctx->pos= yypos17; ctx->thunkpos= yythunkpos17; if (!yymatchChar(ctx, '\\')) goto l23; if (!yymatchChar(ctx, '-')) goto l23; goto l17; + l23:; ctx->pos= yypos17; ctx->thunkpos= yythunkpos17; + { int yypos24= ctx->pos, yythunkpos24= ctx->thunkpos; if (!yymatchChar(ctx, '\\')) goto l24; goto l16; + l24:; ctx->pos= yypos24; ctx->thunkpos= yythunkpos24; + } if (!yymatchDot(ctx)) goto l16; } l17:; - yyprintf((stderr, " ok %s @ %s\n", "Char", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "Char", ctx->buf+ctx->pos)); return 1; - l16:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Char", yybuf+yypos)); + l16:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Char", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_IdentCont() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_IdentCont(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "IdentCont")); - { int yypos26= yypos, yythunkpos26= yythunkpos; if (!yy_IdentStart()) goto l27; goto l26; - l27:; yypos= yypos26; yythunkpos= yythunkpos26; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; + { int yypos26= ctx->pos, yythunkpos26= ctx->thunkpos; if (!yy_IdentStart(ctx)) goto l27; goto l26; + l27:; ctx->pos= yypos26; ctx->thunkpos= yythunkpos26; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; } l26:; - yyprintf((stderr, " ok %s @ %s\n", "IdentCont", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "IdentCont", ctx->buf+ctx->pos)); return 1; - l25:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "IdentCont", yybuf+yypos)); + l25:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "IdentCont", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_IdentStart() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "IdentStart")); if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l28; - yyprintf((stderr, " ok %s @ %s\n", "IdentStart", yybuf+yypos)); +YY_RULE(int) yy_IdentStart(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "IdentStart")); if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l28; + yyprintf((stderr, " ok %s @ %s\n", "IdentStart", ctx->buf+ctx->pos)); return 1; - l28:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "IdentStart", yybuf+yypos)); + l28:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "IdentStart", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_END() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "END")); if (!yymatchChar('>')) goto l29; if (!yy_Spacing()) goto l29; - yyprintf((stderr, " ok %s @ %s\n", "END", yybuf+yypos)); +YY_RULE(int) yy_END(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "END")); if (!yymatchChar(ctx, '>')) goto l29; if (!yy_Spacing(ctx)) goto l29; + yyprintf((stderr, " ok %s @ %s\n", "END", ctx->buf+ctx->pos)); return 1; - l29:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "END", yybuf+yypos)); + l29:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "END", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_BEGIN() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "BEGIN")); if (!yymatchChar('<')) goto l30; if (!yy_Spacing()) goto l30; - yyprintf((stderr, " ok %s @ %s\n", "BEGIN", yybuf+yypos)); +YY_RULE(int) yy_BEGIN(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "BEGIN")); if (!yymatchChar(ctx, '<')) goto l30; if (!yy_Spacing(ctx)) goto l30; + yyprintf((stderr, " ok %s @ %s\n", "BEGIN", ctx->buf+ctx->pos)); return 1; - l30:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "BEGIN", yybuf+yypos)); + l30:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "BEGIN", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_DOT() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "DOT")); if (!yymatchChar('.')) goto l31; if (!yy_Spacing()) goto l31; - yyprintf((stderr, " ok %s @ %s\n", "DOT", yybuf+yypos)); +YY_RULE(int) yy_DOT(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "DOT")); if (!yymatchChar(ctx, '.')) goto l31; if (!yy_Spacing(ctx)) goto l31; + yyprintf((stderr, " ok %s @ %s\n", "DOT", ctx->buf+ctx->pos)); return 1; - l31:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "DOT", yybuf+yypos)); + l31:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "DOT", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Class() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "Class")); if (!yymatchChar('[')) goto l32; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l32; +YY_RULE(int) yy_Class(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "Class")); if (!yymatchChar(ctx, '[')) goto l32; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l32; l33:; - { int yypos34= yypos, yythunkpos34= yythunkpos; - { int yypos35= yypos, yythunkpos35= yythunkpos; if (!yymatchChar(']')) goto l35; goto l34; - l35:; yypos= yypos35; yythunkpos= yythunkpos35; - } if (!yy_Range()) goto l34; goto l33; - l34:; yypos= yypos34; yythunkpos= yythunkpos34; - } yyText(yybegin, yyend); if (!(YY_END)) goto l32; if (!yymatchChar(']')) goto l32; if (!yy_Spacing()) goto l32; - yyprintf((stderr, " ok %s @ %s\n", "Class", yybuf+yypos)); + { int yypos34= ctx->pos, yythunkpos34= ctx->thunkpos; + { int yypos35= ctx->pos, yythunkpos35= ctx->thunkpos; if (!yymatchChar(ctx, ']')) goto l35; goto l34; + l35:; ctx->pos= yypos35; ctx->thunkpos= yythunkpos35; + } if (!yy_Range(ctx)) goto l34; goto l33; + l34:; ctx->pos= yypos34; ctx->thunkpos= yythunkpos34; + } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l32; if (!yymatchChar(ctx, ']')) goto l32; if (!yy_Spacing(ctx)) goto l32; + yyprintf((stderr, " ok %s @ %s\n", "Class", ctx->buf+ctx->pos)); return 1; - l32:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Class", yybuf+yypos)); + l32:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Class", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Literal() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_Literal(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "Literal")); - { int yypos37= yypos, yythunkpos37= yythunkpos; if (!yymatchClass((unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l38; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l38; + { int yypos37= ctx->pos, yythunkpos37= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l38; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l38; l39:; - { int yypos40= yypos, yythunkpos40= yythunkpos; - { int yypos41= yypos, yythunkpos41= yythunkpos; if (!yymatchClass((unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l41; goto l40; - l41:; yypos= yypos41; yythunkpos= yythunkpos41; - } if (!yy_Char()) goto l40; goto l39; - l40:; yypos= yypos40; yythunkpos= yythunkpos40; - } yyText(yybegin, yyend); if (!(YY_END)) goto l38; if (!yymatchClass((unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l38; if (!yy_Spacing()) goto l38; goto l37; - l38:; yypos= yypos37; yythunkpos= yythunkpos37; if (!yymatchClass((unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l36; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l36; + { int yypos40= ctx->pos, yythunkpos40= ctx->thunkpos; + { int yypos41= ctx->pos, yythunkpos41= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l41; goto l40; + l41:; ctx->pos= yypos41; ctx->thunkpos= yythunkpos41; + } if (!yy_Char(ctx)) goto l40; goto l39; + l40:; ctx->pos= yypos40; ctx->thunkpos= yythunkpos40; + } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l38; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l38; if (!yy_Spacing(ctx)) goto l38; goto l37; + l38:; ctx->pos= yypos37; ctx->thunkpos= yythunkpos37; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l36; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l36; l42:; - { int yypos43= yypos, yythunkpos43= yythunkpos; - { int yypos44= yypos, yythunkpos44= yythunkpos; if (!yymatchClass((unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l44; goto l43; - l44:; yypos= yypos44; yythunkpos= yythunkpos44; - } if (!yy_Char()) goto l43; goto l42; - l43:; yypos= yypos43; yythunkpos= yythunkpos43; - } yyText(yybegin, yyend); if (!(YY_END)) goto l36; if (!yymatchClass((unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l36; if (!yy_Spacing()) goto l36; + { int yypos43= ctx->pos, yythunkpos43= ctx->thunkpos; + { int yypos44= ctx->pos, yythunkpos44= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l44; goto l43; + l44:; ctx->pos= yypos44; ctx->thunkpos= yythunkpos44; + } if (!yy_Char(ctx)) goto l43; goto l42; + l43:; ctx->pos= yypos43; ctx->thunkpos= yythunkpos43; + } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l36; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l36; if (!yy_Spacing(ctx)) goto l36; } l37:; - yyprintf((stderr, " ok %s @ %s\n", "Literal", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "Literal", ctx->buf+ctx->pos)); return 1; - l36:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Literal", yybuf+yypos)); + l36:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Literal", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_CLOSE() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "CLOSE")); if (!yymatchChar(')')) goto l45; if (!yy_Spacing()) goto l45; - yyprintf((stderr, " ok %s @ %s\n", "CLOSE", yybuf+yypos)); +YY_RULE(int) yy_CLOSE(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "CLOSE")); if (!yymatchChar(ctx, ')')) goto l45; if (!yy_Spacing(ctx)) goto l45; + yyprintf((stderr, " ok %s @ %s\n", "CLOSE", ctx->buf+ctx->pos)); return 1; - l45:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "CLOSE", yybuf+yypos)); + l45:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "CLOSE", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_OPEN() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "OPEN")); if (!yymatchChar('(')) goto l46; if (!yy_Spacing()) goto l46; - yyprintf((stderr, " ok %s @ %s\n", "OPEN", yybuf+yypos)); +YY_RULE(int) yy_OPEN(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "OPEN")); if (!yymatchChar(ctx, '(')) goto l46; if (!yy_Spacing(ctx)) goto l46; + yyprintf((stderr, " ok %s @ %s\n", "OPEN", ctx->buf+ctx->pos)); return 1; - l46:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "OPEN", yybuf+yypos)); + l46:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "OPEN", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_PLUS() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "PLUS")); if (!yymatchChar('+')) goto l47; if (!yy_Spacing()) goto l47; - yyprintf((stderr, " ok %s @ %s\n", "PLUS", yybuf+yypos)); +YY_RULE(int) yy_PLUS(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "PLUS")); if (!yymatchChar(ctx, '+')) goto l47; if (!yy_Spacing(ctx)) goto l47; + yyprintf((stderr, " ok %s @ %s\n", "PLUS", ctx->buf+ctx->pos)); return 1; - l47:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "PLUS", yybuf+yypos)); + l47:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PLUS", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_STAR() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "STAR")); if (!yymatchChar('*')) goto l48; if (!yy_Spacing()) goto l48; - yyprintf((stderr, " ok %s @ %s\n", "STAR", yybuf+yypos)); +YY_RULE(int) yy_STAR(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "STAR")); if (!yymatchChar(ctx, '*')) goto l48; if (!yy_Spacing(ctx)) goto l48; + yyprintf((stderr, " ok %s @ %s\n", "STAR", ctx->buf+ctx->pos)); return 1; - l48:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "STAR", yybuf+yypos)); + l48:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "STAR", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_QUESTION() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "QUESTION")); if (!yymatchChar('?')) goto l49; if (!yy_Spacing()) goto l49; - yyprintf((stderr, " ok %s @ %s\n", "QUESTION", yybuf+yypos)); +YY_RULE(int) yy_QUESTION(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "QUESTION")); if (!yymatchChar(ctx, '?')) goto l49; if (!yy_Spacing(ctx)) goto l49; + yyprintf((stderr, " ok %s @ %s\n", "QUESTION", ctx->buf+ctx->pos)); return 1; - l49:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "QUESTION", yybuf+yypos)); + l49:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "QUESTION", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Primary() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_Primary(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "Primary")); - { int yypos51= yypos, yythunkpos51= yythunkpos; if (!yy_Identifier()) goto l52; - { int yypos53= yypos, yythunkpos53= yythunkpos; if (!yy_LEFTARROW()) goto l53; goto l52; - l53:; yypos= yypos53; yythunkpos= yythunkpos53; - } yyDo(yy_1_Primary, yybegin, yyend); goto l51; - l52:; yypos= yypos51; yythunkpos= yythunkpos51; if (!yy_OPEN()) goto l54; if (!yy_Expression()) goto l54; if (!yy_CLOSE()) goto l54; goto l51; - l54:; yypos= yypos51; yythunkpos= yythunkpos51; if (!yy_Literal()) goto l55; yyDo(yy_2_Primary, yybegin, yyend); goto l51; - l55:; yypos= yypos51; yythunkpos= yythunkpos51; if (!yy_Class()) goto l56; yyDo(yy_3_Primary, yybegin, yyend); goto l51; - l56:; yypos= yypos51; yythunkpos= yythunkpos51; if (!yy_DOT()) goto l57; yyDo(yy_4_Primary, yybegin, yyend); goto l51; - l57:; yypos= yypos51; yythunkpos= yythunkpos51; if (!yy_Action()) goto l58; yyDo(yy_5_Primary, yybegin, yyend); goto l51; - l58:; yypos= yypos51; yythunkpos= yythunkpos51; if (!yy_BEGIN()) goto l59; yyDo(yy_6_Primary, yybegin, yyend); goto l51; - l59:; yypos= yypos51; yythunkpos= yythunkpos51; if (!yy_END()) goto l50; yyDo(yy_7_Primary, yybegin, yyend); + { int yypos51= ctx->pos, yythunkpos51= ctx->thunkpos; if (!yy_Identifier(ctx)) goto l52; + { int yypos53= ctx->pos, yythunkpos53= ctx->thunkpos; if (!yy_LEFTARROW(ctx)) goto l53; goto l52; + l53:; ctx->pos= yypos53; ctx->thunkpos= yythunkpos53; + } yyDo(ctx, yy_1_Primary, ctx->begin, ctx->end); goto l51; + l52:; ctx->pos= yypos51; ctx->thunkpos= yythunkpos51; if (!yy_OPEN(ctx)) goto l54; if (!yy_Expression(ctx)) goto l54; if (!yy_CLOSE(ctx)) goto l54; goto l51; + l54:; ctx->pos= yypos51; ctx->thunkpos= yythunkpos51; if (!yy_Literal(ctx)) goto l55; yyDo(ctx, yy_2_Primary, ctx->begin, ctx->end); goto l51; + l55:; ctx->pos= yypos51; ctx->thunkpos= yythunkpos51; if (!yy_Class(ctx)) goto l56; yyDo(ctx, yy_3_Primary, ctx->begin, ctx->end); goto l51; + l56:; ctx->pos= yypos51; ctx->thunkpos= yythunkpos51; if (!yy_DOT(ctx)) goto l57; yyDo(ctx, yy_4_Primary, ctx->begin, ctx->end); goto l51; + l57:; ctx->pos= yypos51; ctx->thunkpos= yythunkpos51; if (!yy_Action(ctx)) goto l58; yyDo(ctx, yy_5_Primary, ctx->begin, ctx->end); goto l51; + l58:; ctx->pos= yypos51; ctx->thunkpos= yythunkpos51; if (!yy_BEGIN(ctx)) goto l59; yyDo(ctx, yy_6_Primary, ctx->begin, ctx->end); goto l51; + l59:; ctx->pos= yypos51; ctx->thunkpos= yythunkpos51; if (!yy_END(ctx)) goto l50; yyDo(ctx, yy_7_Primary, ctx->begin, ctx->end); } l51:; - yyprintf((stderr, " ok %s @ %s\n", "Primary", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "Primary", ctx->buf+ctx->pos)); return 1; - l50:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Primary", yybuf+yypos)); + l50:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Primary", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_NOT() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "NOT")); if (!yymatchChar('!')) goto l60; if (!yy_Spacing()) goto l60; - yyprintf((stderr, " ok %s @ %s\n", "NOT", yybuf+yypos)); +YY_RULE(int) yy_NOT(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "NOT")); if (!yymatchChar(ctx, '!')) goto l60; if (!yy_Spacing(ctx)) goto l60; + yyprintf((stderr, " ok %s @ %s\n", "NOT", ctx->buf+ctx->pos)); return 1; - l60:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "NOT", yybuf+yypos)); + l60:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NOT", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Suffix() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "Suffix")); if (!yy_Primary()) goto l61; - { int yypos62= yypos, yythunkpos62= yythunkpos; - { int yypos64= yypos, yythunkpos64= yythunkpos; if (!yy_QUESTION()) goto l65; yyDo(yy_1_Suffix, yybegin, yyend); goto l64; - l65:; yypos= yypos64; yythunkpos= yythunkpos64; if (!yy_STAR()) goto l66; yyDo(yy_2_Suffix, yybegin, yyend); goto l64; - l66:; yypos= yypos64; yythunkpos= yythunkpos64; if (!yy_PLUS()) goto l62; yyDo(yy_3_Suffix, yybegin, yyend); +YY_RULE(int) yy_Suffix(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "Suffix")); if (!yy_Primary(ctx)) goto l61; + { int yypos62= ctx->pos, yythunkpos62= ctx->thunkpos; + { int yypos64= ctx->pos, yythunkpos64= ctx->thunkpos; if (!yy_QUESTION(ctx)) goto l65; yyDo(ctx, yy_1_Suffix, ctx->begin, ctx->end); goto l64; + l65:; ctx->pos= yypos64; ctx->thunkpos= yythunkpos64; if (!yy_STAR(ctx)) goto l66; yyDo(ctx, yy_2_Suffix, ctx->begin, ctx->end); goto l64; + l66:; ctx->pos= yypos64; ctx->thunkpos= yythunkpos64; if (!yy_PLUS(ctx)) goto l62; yyDo(ctx, yy_3_Suffix, ctx->begin, ctx->end); } l64:; goto l63; - l62:; yypos= yypos62; yythunkpos= yythunkpos62; + l62:; ctx->pos= yypos62; ctx->thunkpos= yythunkpos62; } l63:; - yyprintf((stderr, " ok %s @ %s\n", "Suffix", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "Suffix", ctx->buf+ctx->pos)); return 1; - l61:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Suffix", yybuf+yypos)); + l61:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Suffix", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Action() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "Action")); if (!yymatchChar('{')) goto l67; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l67; +YY_RULE(int) yy_Action(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "Action")); if (!yymatchChar(ctx, '{')) goto l67; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l67; l68:; - { int yypos69= yypos, yythunkpos69= yythunkpos; if (!yymatchClass((unsigned char *)"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\337\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377")) goto l69; goto l68; - l69:; yypos= yypos69; yythunkpos= yythunkpos69; - } yyText(yybegin, yyend); if (!(YY_END)) goto l67; if (!yymatchChar('}')) goto l67; if (!yy_Spacing()) goto l67; - yyprintf((stderr, " ok %s @ %s\n", "Action", yybuf+yypos)); + { int yypos69= ctx->pos, yythunkpos69= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\337\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377")) goto l69; goto l68; + l69:; ctx->pos= yypos69; ctx->thunkpos= yythunkpos69; + } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l67; if (!yymatchChar(ctx, '}')) goto l67; if (!yy_Spacing(ctx)) goto l67; + yyprintf((stderr, " ok %s @ %s\n", "Action", ctx->buf+ctx->pos)); return 1; - l67:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Action", yybuf+yypos)); + l67:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Action", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_AND() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "AND")); if (!yymatchChar('&')) goto l70; if (!yy_Spacing()) goto l70; - yyprintf((stderr, " ok %s @ %s\n", "AND", yybuf+yypos)); +YY_RULE(int) yy_AND(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "AND")); if (!yymatchChar(ctx, '&')) goto l70; if (!yy_Spacing(ctx)) goto l70; + yyprintf((stderr, " ok %s @ %s\n", "AND", ctx->buf+ctx->pos)); return 1; - l70:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "AND", yybuf+yypos)); + l70:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "AND", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Prefix() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_Prefix(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "Prefix")); - { int yypos72= yypos, yythunkpos72= yythunkpos; if (!yy_AND()) goto l73; if (!yy_Action()) goto l73; yyDo(yy_1_Prefix, yybegin, yyend); goto l72; - l73:; yypos= yypos72; yythunkpos= yythunkpos72; if (!yy_AND()) goto l74; if (!yy_Suffix()) goto l74; yyDo(yy_2_Prefix, yybegin, yyend); goto l72; - l74:; yypos= yypos72; yythunkpos= yythunkpos72; if (!yy_NOT()) goto l75; if (!yy_Suffix()) goto l75; yyDo(yy_3_Prefix, yybegin, yyend); goto l72; - l75:; yypos= yypos72; yythunkpos= yythunkpos72; if (!yy_Suffix()) goto l71; + { int yypos72= ctx->pos, yythunkpos72= ctx->thunkpos; if (!yy_AND(ctx)) goto l73; if (!yy_Action(ctx)) goto l73; yyDo(ctx, yy_1_Prefix, ctx->begin, ctx->end); goto l72; + l73:; ctx->pos= yypos72; ctx->thunkpos= yythunkpos72; if (!yy_AND(ctx)) goto l74; if (!yy_Suffix(ctx)) goto l74; yyDo(ctx, yy_2_Prefix, ctx->begin, ctx->end); goto l72; + l74:; ctx->pos= yypos72; ctx->thunkpos= yythunkpos72; if (!yy_NOT(ctx)) goto l75; if (!yy_Suffix(ctx)) goto l75; yyDo(ctx, yy_3_Prefix, ctx->begin, ctx->end); goto l72; + l75:; ctx->pos= yypos72; ctx->thunkpos= yythunkpos72; if (!yy_Suffix(ctx)) goto l71; } l72:; - yyprintf((stderr, " ok %s @ %s\n", "Prefix", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "Prefix", ctx->buf+ctx->pos)); return 1; - l71:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Prefix", yybuf+yypos)); + l71:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Prefix", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_SLASH() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "SLASH")); if (!yymatchChar('/')) goto l76; if (!yy_Spacing()) goto l76; - yyprintf((stderr, " ok %s @ %s\n", "SLASH", yybuf+yypos)); +YY_RULE(int) yy_SLASH(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "SLASH")); if (!yymatchChar(ctx, '/')) goto l76; if (!yy_Spacing(ctx)) goto l76; + yyprintf((stderr, " ok %s @ %s\n", "SLASH", ctx->buf+ctx->pos)); return 1; - l76:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "SLASH", yybuf+yypos)); + l76:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "SLASH", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Sequence() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_Sequence(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "Sequence")); - { int yypos78= yypos, yythunkpos78= yythunkpos; if (!yy_Prefix()) goto l79; + { int yypos78= ctx->pos, yythunkpos78= ctx->thunkpos; if (!yy_Prefix(ctx)) goto l79; l80:; - { int yypos81= yypos, yythunkpos81= yythunkpos; if (!yy_Prefix()) goto l81; yyDo(yy_1_Sequence, yybegin, yyend); goto l80; - l81:; yypos= yypos81; yythunkpos= yythunkpos81; + { int yypos81= ctx->pos, yythunkpos81= ctx->thunkpos; if (!yy_Prefix(ctx)) goto l81; yyDo(ctx, yy_1_Sequence, ctx->begin, ctx->end); goto l80; + l81:; ctx->pos= yypos81; ctx->thunkpos= yythunkpos81; } goto l78; - l79:; yypos= yypos78; yythunkpos= yythunkpos78; yyDo(yy_2_Sequence, yybegin, yyend); + l79:; ctx->pos= yypos78; ctx->thunkpos= yythunkpos78; yyDo(ctx, yy_2_Sequence, ctx->begin, ctx->end); } l78:; - yyprintf((stderr, " ok %s @ %s\n", "Sequence", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "Sequence", ctx->buf+ctx->pos)); return 1; - l77:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Sequence", yybuf+yypos)); + l77:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Sequence", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Expression() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "Expression")); if (!yy_Sequence()) goto l82; +YY_RULE(int) yy_Expression(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "Expression")); if (!yy_Sequence(ctx)) goto l82; l83:; - { int yypos84= yypos, yythunkpos84= yythunkpos; if (!yy_SLASH()) goto l84; if (!yy_Sequence()) goto l84; yyDo(yy_1_Expression, yybegin, yyend); goto l83; - l84:; yypos= yypos84; yythunkpos= yythunkpos84; + { int yypos84= ctx->pos, yythunkpos84= ctx->thunkpos; if (!yy_SLASH(ctx)) goto l84; if (!yy_Sequence(ctx)) goto l84; yyDo(ctx, yy_1_Expression, ctx->begin, ctx->end); goto l83; + l84:; ctx->pos= yypos84; ctx->thunkpos= yythunkpos84; } - yyprintf((stderr, " ok %s @ %s\n", "Expression", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "Expression", ctx->buf+ctx->pos)); return 1; - l82:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Expression", yybuf+yypos)); + l82:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Expression", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_LEFTARROW() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "LEFTARROW")); if (!yymatchString("<-")) goto l85; if (!yy_Spacing()) goto l85; - yyprintf((stderr, " ok %s @ %s\n", "LEFTARROW", yybuf+yypos)); +YY_RULE(int) yy_LEFTARROW(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "LEFTARROW")); if (!yymatchString(ctx, "<-")) goto l85; if (!yy_Spacing(ctx)) goto l85; + yyprintf((stderr, " ok %s @ %s\n", "LEFTARROW", ctx->buf+ctx->pos)); return 1; - l85:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "LEFTARROW", yybuf+yypos)); + l85:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "LEFTARROW", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Identifier() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "Identifier")); yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l86; if (!yy_IdentStart()) goto l86; +YY_RULE(int) yy_Identifier(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "Identifier")); yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l86; if (!yy_IdentStart(ctx)) goto l86; l87:; - { int yypos88= yypos, yythunkpos88= yythunkpos; if (!yy_IdentCont()) goto l88; goto l87; - l88:; yypos= yypos88; yythunkpos= yythunkpos88; - } yyText(yybegin, yyend); if (!(YY_END)) goto l86; if (!yy_Spacing()) goto l86; - yyprintf((stderr, " ok %s @ %s\n", "Identifier", yybuf+yypos)); + { int yypos88= ctx->pos, yythunkpos88= ctx->thunkpos; if (!yy_IdentCont(ctx)) goto l88; goto l87; + l88:; ctx->pos= yypos88; ctx->thunkpos= yythunkpos88; + } yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l86; if (!yy_Spacing(ctx)) goto l86; + yyprintf((stderr, " ok %s @ %s\n", "Identifier", ctx->buf+ctx->pos)); return 1; - l86:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Identifier", yybuf+yypos)); + l86:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Identifier", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_EndOfFile() -{ int yypos0= yypos, yythunkpos0= yythunkpos; +YY_RULE(int) yy_EndOfFile(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyprintf((stderr, "%s\n", "EndOfFile")); - { int yypos90= yypos, yythunkpos90= yythunkpos; if (!yymatchDot()) goto l90; goto l89; - l90:; yypos= yypos90; yythunkpos= yythunkpos90; + { int yypos90= ctx->pos, yythunkpos90= ctx->thunkpos; if (!yymatchDot(ctx)) goto l90; goto l89; + l90:; ctx->pos= yypos90; ctx->thunkpos= yythunkpos90; } - yyprintf((stderr, " ok %s @ %s\n", "EndOfFile", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "EndOfFile", ctx->buf+ctx->pos)); return 1; - l89:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "EndOfFile", yybuf+yypos)); + l89:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "EndOfFile", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Definition() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "Definition")); if (!yy_Identifier()) goto l91; yyDo(yy_1_Definition, yybegin, yyend); if (!yy_LEFTARROW()) goto l91; if (!yy_Expression()) goto l91; yyDo(yy_2_Definition, yybegin, yyend); yyText(yybegin, yyend); if (!( YYACCEPT )) goto l91; - yyprintf((stderr, " ok %s @ %s\n", "Definition", yybuf+yypos)); +YY_RULE(int) yy_Definition(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "Definition")); if (!yy_Identifier(ctx)) goto l91; yyDo(ctx, yy_1_Definition, ctx->begin, ctx->end); if (!yy_LEFTARROW(ctx)) goto l91; if (!yy_Expression(ctx)) goto l91; yyDo(ctx, yy_2_Definition, ctx->begin, ctx->end); yyText(ctx, ctx->begin, ctx->end); if (!( YYACCEPT )) goto l91; + yyprintf((stderr, " ok %s @ %s\n", "Definition", ctx->buf+ctx->pos)); return 1; - l91:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Definition", yybuf+yypos)); + l91:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Definition", ctx->buf+ctx->pos)); return 0; } -YY_RULE(int) yy_Spacing() +YY_RULE(int) yy_Spacing(yycontext *ctx) { yyprintf((stderr, "%s\n", "Spacing")); l93:; - { int yypos94= yypos, yythunkpos94= yythunkpos; - { int yypos95= yypos, yythunkpos95= yythunkpos; if (!yy_Space()) goto l96; goto l95; - l96:; yypos= yypos95; yythunkpos= yythunkpos95; if (!yy_Comment()) goto l94; + { int yypos94= ctx->pos, yythunkpos94= ctx->thunkpos; + { int yypos95= ctx->pos, yythunkpos95= ctx->thunkpos; if (!yy_Space(ctx)) goto l96; goto l95; + l96:; ctx->pos= yypos95; ctx->thunkpos= yythunkpos95; if (!yy_Comment(ctx)) goto l94; } l95:; goto l93; - l94:; yypos= yypos94; yythunkpos= yythunkpos94; + l94:; ctx->pos= yypos94; ctx->thunkpos= yythunkpos94; } - yyprintf((stderr, " ok %s @ %s\n", "Spacing", yybuf+yypos)); + yyprintf((stderr, " ok %s @ %s\n", "Spacing", ctx->buf+ctx->pos)); return 1; } -YY_RULE(int) yy_Grammar() -{ int yypos0= yypos, yythunkpos0= yythunkpos; - yyprintf((stderr, "%s\n", "Grammar")); if (!yy_Spacing()) goto l97; if (!yy_Definition()) goto l97; +YY_RULE(int) yy_Grammar(yycontext *ctx) +{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; + yyprintf((stderr, "%s\n", "Grammar")); if (!yy_Spacing(ctx)) goto l97; if (!yy_Definition(ctx)) goto l97; l98:; - { int yypos99= yypos, yythunkpos99= yythunkpos; if (!yy_Definition()) goto l99; goto l98; - l99:; yypos= yypos99; yythunkpos= yythunkpos99; - } if (!yy_EndOfFile()) goto l97; - yyprintf((stderr, " ok %s @ %s\n", "Grammar", yybuf+yypos)); + { int yypos99= ctx->pos, yythunkpos99= ctx->thunkpos; if (!yy_Definition(ctx)) goto l99; goto l98; + l99:; ctx->pos= yypos99; ctx->thunkpos= yythunkpos99; + } if (!yy_EndOfFile(ctx)) goto l97; + yyprintf((stderr, " ok %s @ %s\n", "Grammar", ctx->buf+ctx->pos)); return 1; - l97:; yypos= yypos0; yythunkpos= yythunkpos0; - yyprintf((stderr, " fail %s @ %s\n", "Grammar", yybuf+yypos)); + l97:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "Grammar", ctx->buf+ctx->pos)); return 0; } #ifndef YY_PART -typedef int (*yyrule)(); +typedef int (*yyrule)(yycontext *ctx); -YY_PARSE(int) YYPARSEFROM(yyrule yystart) +YY_PARSE(int) YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart) { int yyok; - if (!yybuflen) + if (!yyctx->buflen) { - yybuflen= 1024; - yybuf= malloc(yybuflen); - yytextlen= 1024; - yytext= malloc(yytextlen); - yythunkslen= 32; - yythunks= malloc(sizeof(yythunk) * yythunkslen); - yyvalslen= 32; - yyvals= malloc(sizeof(YYSTYPE) * yyvalslen); - yybegin= yyend= yypos= yylimit= yythunkpos= 0; + yyctx->buflen= 1024; + yyctx->buf= (char *)malloc(yyctx->buflen); + yyctx->textlen= 1024; + yyctx->text= (char *)malloc(yyctx->textlen); + yyctx->thunkslen= 32; + yyctx->thunks= (yythunk *)malloc(sizeof(yythunk) * yyctx->thunkslen); + yyctx->valslen= 32; + yyctx->vals= (YYSTYPE *)malloc(sizeof(YYSTYPE) * yyctx->valslen); + yyctx->begin= yyctx->end= yyctx->pos= yyctx->limit= yyctx->thunkpos= 0; } - yybegin= yyend= yypos; - yythunkpos= 0; - yyval= yyvals; - yyok= yystart(); - if (yyok) yyDone(); - yyCommit(); + yyctx->begin= yyctx->end= yyctx->pos; + yyctx->thunkpos= 0; + yyctx->val= yyctx->vals; + yyok= yystart(yyctx); + if (yyok) yyDone(yyctx); + yyCommit(yyctx); return yyok; - (void)yyrefill; - (void)yymatchDot; - (void)yymatchChar; - (void)yymatchString; - (void)yymatchClass; - (void)yyDo; - (void)yyText; - (void)yyDone; - (void)yyCommit; - (void)yyAccept; - (void)yyPush; - (void)yyPop; - (void)yySet; - (void)yytextmax; } -YY_PARSE(int) YYPARSE(void) +YY_PARSE(int) YYPARSE(YY_CTX_PARAM) { - return YYPARSEFROM(yy_Grammar); + return YYPARSEFROM(YY_CTX_ARG_ yy_Grammar); } #endif diff --git a/version.h b/version.h index 6adda85..dcfc63d 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ #define PEG_MAJOR 0 #define PEG_MINOR 1 -#define PEG_LEVEL 8 +#define PEG_LEVEL 9