diff --git a/compile.c b/compile.c index 8fa2013..731e5b7 100644 --- a/compile.c +++ b/compile.c @@ -121,6 +121,10 @@ static void jump(int n) { fprintf(output, " goto l%d;", n); } static void save(int n) { fprintf(output, " int yypos%d= G->pos, yythunkpos%d= G->thunkpos;", n, n); } static void restore(int n) { fprintf(output, " G->pos= yypos%d; G->thunkpos= yythunkpos%d;", n, n); } +static void callErrBlock(Node * node) { + fprintf(output, " { YY_XTYPE YY_XVAR = (YY_XTYPE) G->data; %s; }", ((struct Any*) node)->errblock); +} + static void Node_compile_c_ko(Node *node, int ko) { assert(node); @@ -136,9 +140,15 @@ static void Node_compile_c_ko(Node *node, int ko) break; case Name: - fprintf(output, " if (!yy_%s(G)) goto l%d;", node->name.rule->rule.name, ko); - if (node->name.variable) - fprintf(output, " yyDo(G, yySet, %d, 0);", node->name.variable->variable.offset); + { + fprintf(output, " if (!yy_%s(G)) {", node->name.rule->rule.name); + if(((struct Any*) node)->errblock) { + callErrBlock(node); + } + fprintf(output, " goto l%d; }", ko); + if (node->name.variable) + fprintf(output, " yyDo(G, yySet, %d, 0);", node->name.variable->variable.offset); + } break; case Character: @@ -435,7 +445,7 @@ typedef struct _GREG {\n\ YY_LOCAL(int) yyrefill(GREG *G)\n\ {\n\ int yyn;\n\ - YY_XTYPE YY_XVAR = (YY_XTYPE)G->data;\n\ + YY_XTYPE YY_XVAR = (YY_XTYPE) G->data;\n\ while (G->buflen - G->pos < 512)\n\ {\n\ G->buflen *= 2;\n\ diff --git a/greg.c b/greg.c index 19be1cf..2d53f02 100644 --- a/greg.c +++ b/greg.c @@ -1,10 +1,10 @@ -/* A recursive-descent parser generated by greg 0.2.0 */ +/* A recursive-descent parser generated by greg 0.4.1 */ #include #include #include struct _GREG; -#define YYRULECOUNT 36 +#define YYRULECOUNT 37 # include "greg.h" @@ -59,72 +59,85 @@ struct _GREG; #define YY_FREE free #endif #ifndef YY_LOCAL -#define YY_LOCAL(T) static T +#define YY_LOCAL(T) static T #endif #ifndef YY_ACTION -#define YY_ACTION(T) static T +#define YY_ACTION(T) static T #endif #ifndef YY_RULE -#define YY_RULE(T) static T +#define YY_RULE(T) static T #endif #ifndef YY_PARSE -#define YY_PARSE(T) T +#define YY_PARSE(T) T #endif #ifndef YY_NAME #define YY_NAME(N) yy##N #endif #ifndef YY_INPUT -#define YY_INPUT(buf, result, max_size) \ - { \ - int yyc= getchar(); \ - result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \ - yyprintf((stderr, "<%c>", yyc)); \ +#define YY_INPUT(buf, result, max_size) \ + { \ + int yyc= getchar(); \ + result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \ + yyprintf((stderr, "<%c>", yyc)); \ } #endif #ifndef YY_BEGIN -#define YY_BEGIN ( G->begin= G->pos, 1) +#define YY_BEGIN ( G->begin= G->pos, 1) #endif #ifndef YY_END -#define YY_END ( G->end= G->pos, 1) +#define YY_END ( G->end= G->pos, 1) #endif #ifdef YY_DEBUG -# define yyprintf(args) fprintf args +# define yyprintf(args) fprintf args #else # define yyprintf(args) #endif #ifndef YYSTYPE -#define YYSTYPE int +#define YYSTYPE int +#endif +#ifndef YY_XTYPE +#define YY_XTYPE void * +#endif +#ifndef YY_XVAR +#define YY_XVAR yyxvar +#endif + +#ifndef YY_STACK_SIZE +#define YY_STACK_SIZE 128 #endif #ifndef YY_PART #define yydata G->data #define yy G->ss -typedef void (*yyaction)(struct _GREG *G, char *yytext, int yyleng); +struct _yythunk; // forward declaration +typedef void (*yyaction)(struct _GREG *G, char *yytext, int yyleng, struct _yythunk *thunkpos, YY_XTYPE YY_XVAR); typedef struct _yythunk { int begin, end; yyaction action; struct _yythunk *next; } yythunk; typedef struct _GREG { char *buf; int buflen; - int pos; - int limit; + int offset; + int pos; + int limit; char *text; - int textlen; - int begin; - int end; + int textlen; + int begin; + int end; yythunk *thunks; - int thunkslen; + int thunkslen; int thunkpos; YYSTYPE ss; YYSTYPE *val; YYSTYPE *vals; int valslen; - void *data; + YY_XTYPE data; } GREG; YY_LOCAL(int) yyrefill(GREG *G) { int yyn; + YY_XTYPE YY_XVAR = (YY_XTYPE) G->data; while (G->buflen - G->pos < 512) { G->buflen *= 2; @@ -209,10 +222,10 @@ YY_LOCAL(int) yyText(GREG *G, int begin, int end) else { while (G->textlen < (yyleng - 1)) - { - G->textlen *= 2; - G->text= YY_REALLOC(G->text, G->textlen, G->data); - } + { + G->textlen *= 2; + G->text= YY_REALLOC(G->text, G->textlen, G->data); + } memcpy(G->text, G->buf + begin, yyleng); } G->text[yyleng]= '\0'; @@ -222,12 +235,12 @@ YY_LOCAL(int) yyText(GREG *G, int begin, int end) YY_LOCAL(void) yyDone(GREG *G) { int pos; - for (pos= 0; pos < G->thunkpos; ++pos) + for (pos= 0; pos < G->thunkpos; ++pos) { yythunk *thunk= &G->thunks[pos]; int yyleng= thunk->end ? yyText(G, thunk->begin, thunk->end) : thunk->begin; yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, G->text)); - thunk->action(G, G->text, yyleng); + thunk->action(G, G->text, yyleng, thunk, G->data); } G->thunkpos= 0; } @@ -238,6 +251,7 @@ YY_LOCAL(void) yyCommit(GREG *G) { memmove(G->buf, G->buf + G->pos, G->limit); } + G->offset += G->pos; G->begin -= G->pos; G->end -= G->pos; G->pos= G->thunkpos= 0; @@ -258,20 +272,21 @@ YY_LOCAL(int) yyAccept(GREG *G, int tp0) return 1; } -YY_LOCAL(void) yyPush(GREG *G, char *text, int count) { G->val += count; } -YY_LOCAL(void) yyPop(GREG *G, char *text, int count) { G->val -= count; } -YY_LOCAL(void) yySet(GREG *G, char *text, int count) { G->val[count]= G->ss; } +YY_LOCAL(void) yyPush(GREG *G, char *text, int count, yythunk *thunk, YY_XTYPE YY_XVAR) { G->val += count; } +YY_LOCAL(void) yyPop(GREG *G, char *text, int count, yythunk *thunk, YY_XTYPE YY_XVAR) { G->val -= count; } +YY_LOCAL(void) yySet(GREG *G, char *text, int count, yythunk *thunk, YY_XTYPE YY_XVAR) { G->val[count]= G->ss; } #endif /* YY_PART */ -#define YYACCEPT yyAccept(G, yythunkpos0) +#define YYACCEPT yyAccept(G, yythunkpos0) -YY_RULE(int) yy_end_of_line(GREG *G); /* 36 */ -YY_RULE(int) yy_comment(GREG *G); /* 35 */ -YY_RULE(int) yy_space(GREG *G); /* 34 */ -YY_RULE(int) yy_braces(GREG *G); /* 33 */ -YY_RULE(int) yy_range(GREG *G); /* 32 */ -YY_RULE(int) yy_char(GREG *G); /* 31 */ +YY_RULE(int) yy_end_of_line(GREG *G); /* 37 */ +YY_RULE(int) yy_comment(GREG *G); /* 36 */ +YY_RULE(int) yy_space(GREG *G); /* 35 */ +YY_RULE(int) yy_braces(GREG *G); /* 34 */ +YY_RULE(int) yy_range(GREG *G); /* 33 */ +YY_RULE(int) yy_char(GREG *G); /* 32 */ +YY_RULE(int) yy_errblock(GREG *G); /* 31 */ YY_RULE(int) yy_END(GREG *G); /* 30 */ YY_RULE(int) yy_BEGIN(GREG *G); /* 29 */ YY_RULE(int) yy_DOT(GREG *G); /* 28 */ @@ -303,108 +318,113 @@ YY_RULE(int) yy_declaration(GREG *G); /* 3 */ YY_RULE(int) yy__(GREG *G); /* 2 */ YY_RULE(int) yy_grammar(GREG *G); /* 1 */ -YY_ACTION(void) yy_9_primary(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_10_primary(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) +{ + yyprintf((stderr, "do yy_10_primary\n")); + Node *node = pop(); ((struct Any *) node)->errblock = strdup(yytext); push(node); ; +} +YY_ACTION(void) yy_9_primary(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_9_primary\n")); push(makePredicate("YY_END")); ; } -YY_ACTION(void) yy_8_primary(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_8_primary(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_8_primary\n")); push(makePredicate("YY_BEGIN")); ; } -YY_ACTION(void) yy_7_primary(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_7_primary(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_7_primary\n")); push(makeAction(yytext)); ; } -YY_ACTION(void) yy_6_primary(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_6_primary(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_6_primary\n")); push(makeDot()); ; } -YY_ACTION(void) yy_5_primary(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_5_primary(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_5_primary\n")); push(makeClass(yytext)); ; } -YY_ACTION(void) yy_4_primary(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_4_primary(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_4_primary\n")); push(makeString(yytext)); ; } -YY_ACTION(void) yy_3_primary(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_3_primary(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_3_primary\n")); push(makeName(findRule(yytext))); ; } -YY_ACTION(void) yy_2_primary(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_2_primary(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_2_primary\n")); Node *name= makeName(findRule(yytext)); name->name.variable= pop(); push(name); ; } -YY_ACTION(void) yy_1_primary(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_1_primary(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_1_primary\n")); push(makeVariable(yytext)); ; } -YY_ACTION(void) yy_3_suffix(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_3_suffix(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_3_suffix\n")); push(makePlus (pop())); ; } -YY_ACTION(void) yy_2_suffix(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_2_suffix(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_2_suffix\n")); push(makeStar (pop())); ; } -YY_ACTION(void) yy_1_suffix(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_1_suffix(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_1_suffix\n")); push(makeQuery(pop())); ; } -YY_ACTION(void) yy_3_prefix(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_3_prefix(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_3_prefix\n")); push(makePeekNot(pop())); ; } -YY_ACTION(void) yy_2_prefix(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_2_prefix(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_2_prefix\n")); push(makePeekFor(pop())); ; } -YY_ACTION(void) yy_1_prefix(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_1_prefix(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_1_prefix\n")); push(makePredicate(yytext)); ; } -YY_ACTION(void) yy_1_sequence(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_1_sequence(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_1_sequence\n")); Node *f= pop(); push(Sequence_append(pop(), f)); ; } -YY_ACTION(void) yy_1_expression(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_1_expression(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_1_expression\n")); Node *f= pop(); push(Alternate_append(pop(), f)); ; } -YY_ACTION(void) yy_2_definition(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_2_definition(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_2_definition\n")); Node *e= pop(); Rule_setExpression(pop(), e); ; } -YY_ACTION(void) yy_1_definition(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_1_definition(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_1_definition\n")); if (push(beginRule(findRule(yytext)))->rule.expression) fprintf(stderr, "rule '%s' redefined\n", yytext); ; } -YY_ACTION(void) yy_1_trailer(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_1_trailer(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_1_trailer\n")); makeTrailer(yytext); ; } -YY_ACTION(void) yy_1_declaration(GREG *G, char *yytext, int yyleng) +YY_ACTION(void) yy_1_declaration(GREG *G, char *yytext, int yyleng, yythunk *thunk, YY_XTYPE YY_XVAR) { yyprintf((stderr, "do yy_1_declaration\n")); makeHeader(yytext); ; @@ -429,11 +449,11 @@ YY_RULE(int) yy_comment(GREG *G) yyprintf((stderr, "%s\n", "comment")); if (!yymatchChar(G, '#')) goto l5; l6:; { int yypos7= G->pos, yythunkpos7= G->thunkpos; - { int yypos8= G->pos, yythunkpos8= G->thunkpos; if (!yy_end_of_line(G)) goto l8; goto l7; + { int yypos8= G->pos, yythunkpos8= G->thunkpos; if (!yy_end_of_line(G)) { goto l8; } goto l7; l8:; G->pos= yypos8; G->thunkpos= yythunkpos8; } if (!yymatchDot(G)) goto l7; goto l6; l7:; G->pos= yypos7; G->thunkpos= yythunkpos7; - } if (!yy_end_of_line(G)) goto l5; + } if (!yy_end_of_line(G)) { goto l5; } yyprintf((stderr, " ok %s @ %s\n", "comment", G->buf+G->pos)); return 1; l5:; G->pos= yypos0; G->thunkpos= yythunkpos0; @@ -445,7 +465,7 @@ YY_RULE(int) yy_space(GREG *G) yyprintf((stderr, "%s\n", "space")); { int yypos10= G->pos, yythunkpos10= G->thunkpos; if (!yymatchChar(G, ' ')) goto l11; goto l10; l11:; G->pos= yypos10; G->thunkpos= yythunkpos10; if (!yymatchChar(G, '\t')) goto l12; goto l10; - l12:; G->pos= yypos10; G->thunkpos= yythunkpos10; if (!yy_end_of_line(G)) goto l9; + l12:; G->pos= yypos10; G->thunkpos= yythunkpos10; if (!yy_end_of_line(G)) { goto l9; } } l10:; yyprintf((stderr, " ok %s @ %s\n", "space", G->buf+G->pos)); @@ -480,8 +500,8 @@ YY_RULE(int) yy_braces(GREG *G) YY_RULE(int) yy_range(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; yyprintf((stderr, "%s\n", "range")); - { int yypos21= G->pos, yythunkpos21= G->thunkpos; if (!yy_char(G)) goto l22; if (!yymatchChar(G, '-')) goto l22; if (!yy_char(G)) goto l22; goto l21; - l22:; G->pos= yypos21; G->thunkpos= yythunkpos21; if (!yy_char(G)) goto l20; + { int yypos21= G->pos, yythunkpos21= G->thunkpos; if (!yy_char(G)) { goto l22; } if (!yymatchChar(G, '-')) goto l22; if (!yy_char(G)) { goto l22; } goto l21; + l22:; G->pos= yypos21; G->thunkpos= yythunkpos21; if (!yy_char(G)) { goto l20; } } l21:; yyprintf((stderr, " ok %s @ %s\n", "range", G->buf+G->pos)); @@ -512,385 +532,402 @@ YY_RULE(int) yy_char(GREG *G) yyprintf((stderr, " fail %s @ %s\n", "char", G->buf+G->pos)); return 0; } +YY_RULE(int) yy_errblock(GREG *G) +{ int yypos0= G->pos, yythunkpos0= G->thunkpos; + yyprintf((stderr, "%s\n", "errblock")); if (!yymatchString(G, "~{")) goto l31; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l31; + l32:; + { int yypos33= G->pos, yythunkpos33= G->thunkpos; if (!yy_braces(G)) { goto l33; } goto l32; + l33:; G->pos= yypos33; G->thunkpos= yythunkpos33; + } yyText(G, G->begin, G->end); if (!(YY_END)) goto l31; if (!yymatchChar(G, '}')) goto l31; if (!yy__(G)) { goto l31; } + yyprintf((stderr, " ok %s @ %s\n", "errblock", G->buf+G->pos)); + return 1; + l31:; G->pos= yypos0; G->thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "errblock", G->buf+G->pos)); + return 0; +} YY_RULE(int) yy_END(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "END")); if (!yymatchChar(G, '>')) goto l31; if (!yy__(G)) goto l31; + yyprintf((stderr, "%s\n", "END")); if (!yymatchChar(G, '>')) goto l34; if (!yy__(G)) { goto l34; } yyprintf((stderr, " ok %s @ %s\n", "END", G->buf+G->pos)); return 1; - l31:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l34:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "END", G->buf+G->pos)); return 0; } YY_RULE(int) yy_BEGIN(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "BEGIN")); if (!yymatchChar(G, '<')) goto l32; if (!yy__(G)) goto l32; + yyprintf((stderr, "%s\n", "BEGIN")); if (!yymatchChar(G, '<')) goto l35; if (!yy__(G)) { goto l35; } yyprintf((stderr, " ok %s @ %s\n", "BEGIN", G->buf+G->pos)); return 1; - l32:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l35:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "BEGIN", G->buf+G->pos)); return 0; } YY_RULE(int) yy_DOT(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "DOT")); if (!yymatchChar(G, '.')) goto l33; if (!yy__(G)) goto l33; + yyprintf((stderr, "%s\n", "DOT")); if (!yymatchChar(G, '.')) goto l36; if (!yy__(G)) { goto l36; } yyprintf((stderr, " ok %s @ %s\n", "DOT", G->buf+G->pos)); return 1; - l33:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l36:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "DOT", G->buf+G->pos)); return 0; } YY_RULE(int) yy_class(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "class")); if (!yymatchChar(G, '[')) goto l34; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l34; - l35:; - { int yypos36= G->pos, yythunkpos36= G->thunkpos; - { int yypos37= G->pos, yythunkpos37= G->thunkpos; if (!yymatchChar(G, ']')) goto l37; goto l36; - l37:; G->pos= yypos37; G->thunkpos= yythunkpos37; - } if (!yy_range(G)) goto l36; goto l35; - l36:; G->pos= yypos36; G->thunkpos= yythunkpos36; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l34; if (!yymatchChar(G, ']')) goto l34; if (!yy__(G)) goto l34; + yyprintf((stderr, "%s\n", "class")); if (!yymatchChar(G, '[')) goto l37; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l37; + l38:; + { int yypos39= G->pos, yythunkpos39= G->thunkpos; + { int yypos40= G->pos, yythunkpos40= G->thunkpos; if (!yymatchChar(G, ']')) goto l40; goto l39; + l40:; G->pos= yypos40; G->thunkpos= yythunkpos40; + } if (!yy_range(G)) { goto l39; } goto l38; + l39:; G->pos= yypos39; G->thunkpos= yythunkpos39; + } yyText(G, G->begin, G->end); if (!(YY_END)) goto l37; if (!yymatchChar(G, ']')) goto l37; if (!yy__(G)) { goto l37; } yyprintf((stderr, " ok %s @ %s\n", "class", G->buf+G->pos)); return 1; - l34:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l37:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "class", G->buf+G->pos)); return 0; } YY_RULE(int) yy_literal(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; yyprintf((stderr, "%s\n", "literal")); - { int yypos39= G->pos, yythunkpos39= G->thunkpos; if (!yymatchClass(G, (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 l40; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l40; - l41:; - { int yypos42= G->pos, yythunkpos42= G->thunkpos; - { int yypos43= G->pos, yythunkpos43= G->thunkpos; if (!yymatchClass(G, (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 l43; goto l42; - l43:; G->pos= yypos43; G->thunkpos= yythunkpos43; - } if (!yy_char(G)) goto l42; goto l41; - l42:; G->pos= yypos42; G->thunkpos= yythunkpos42; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l40; if (!yymatchClass(G, (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 l40; if (!yy__(G)) goto l40; goto l39; - l40:; G->pos= yypos39; G->thunkpos= yythunkpos39; if (!yymatchClass(G, (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 l38; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l38; + { int yypos42= G->pos, yythunkpos42= G->thunkpos; if (!yymatchClass(G, (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 l43; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l43; l44:; { int yypos45= G->pos, yythunkpos45= G->thunkpos; - { int yypos46= G->pos, yythunkpos46= G->thunkpos; if (!yymatchClass(G, (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 l46; goto l45; + { int yypos46= G->pos, yythunkpos46= G->thunkpos; if (!yymatchClass(G, (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 l46; goto l45; l46:; G->pos= yypos46; G->thunkpos= yythunkpos46; - } if (!yy_char(G)) goto l45; goto l44; + } if (!yy_char(G)) { goto l45; } goto l44; l45:; G->pos= yypos45; G->thunkpos= yythunkpos45; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l38; if (!yymatchClass(G, (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 l38; if (!yy__(G)) goto l38; + } yyText(G, G->begin, G->end); if (!(YY_END)) goto l43; if (!yymatchClass(G, (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 l43; if (!yy__(G)) { goto l43; } goto l42; + l43:; G->pos= yypos42; G->thunkpos= yythunkpos42; if (!yymatchClass(G, (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 l41; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l41; + l47:; + { int yypos48= G->pos, yythunkpos48= G->thunkpos; + { int yypos49= G->pos, yythunkpos49= G->thunkpos; if (!yymatchClass(G, (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 l49; goto l48; + l49:; G->pos= yypos49; G->thunkpos= yythunkpos49; + } if (!yy_char(G)) { goto l48; } goto l47; + l48:; G->pos= yypos48; G->thunkpos= yythunkpos48; + } yyText(G, G->begin, G->end); if (!(YY_END)) goto l41; if (!yymatchClass(G, (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 l41; if (!yy__(G)) { goto l41; } } - l39:; + l42:; yyprintf((stderr, " ok %s @ %s\n", "literal", G->buf+G->pos)); return 1; - l38:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l41:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "literal", G->buf+G->pos)); return 0; } YY_RULE(int) yy_CLOSE(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "CLOSE")); if (!yymatchChar(G, ')')) goto l47; if (!yy__(G)) goto l47; + yyprintf((stderr, "%s\n", "CLOSE")); if (!yymatchChar(G, ')')) goto l50; if (!yy__(G)) { goto l50; } yyprintf((stderr, " ok %s @ %s\n", "CLOSE", G->buf+G->pos)); return 1; - l47:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l50:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "CLOSE", G->buf+G->pos)); return 0; } YY_RULE(int) yy_OPEN(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "OPEN")); if (!yymatchChar(G, '(')) goto l48; if (!yy__(G)) goto l48; + yyprintf((stderr, "%s\n", "OPEN")); if (!yymatchChar(G, '(')) goto l51; if (!yy__(G)) { goto l51; } yyprintf((stderr, " ok %s @ %s\n", "OPEN", G->buf+G->pos)); return 1; - l48:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l51:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "OPEN", G->buf+G->pos)); return 0; } YY_RULE(int) yy_COLON(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "COLON")); if (!yymatchChar(G, ':')) goto l49; if (!yy__(G)) goto l49; + yyprintf((stderr, "%s\n", "COLON")); if (!yymatchChar(G, ':')) goto l52; if (!yy__(G)) { goto l52; } yyprintf((stderr, " ok %s @ %s\n", "COLON", G->buf+G->pos)); return 1; - l49:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l52:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "COLON", G->buf+G->pos)); return 0; } YY_RULE(int) yy_PLUS(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "PLUS")); if (!yymatchChar(G, '+')) goto l50; if (!yy__(G)) goto l50; + yyprintf((stderr, "%s\n", "PLUS")); if (!yymatchChar(G, '+')) goto l53; if (!yy__(G)) { goto l53; } yyprintf((stderr, " ok %s @ %s\n", "PLUS", G->buf+G->pos)); return 1; - l50:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l53:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "PLUS", G->buf+G->pos)); return 0; } YY_RULE(int) yy_STAR(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "STAR")); if (!yymatchChar(G, '*')) goto l51; if (!yy__(G)) goto l51; + yyprintf((stderr, "%s\n", "STAR")); if (!yymatchChar(G, '*')) goto l54; if (!yy__(G)) { goto l54; } yyprintf((stderr, " ok %s @ %s\n", "STAR", G->buf+G->pos)); return 1; - l51:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l54:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "STAR", G->buf+G->pos)); return 0; } YY_RULE(int) yy_QUESTION(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "QUESTION")); if (!yymatchChar(G, '?')) goto l52; if (!yy__(G)) goto l52; + yyprintf((stderr, "%s\n", "QUESTION")); if (!yymatchChar(G, '?')) goto l55; if (!yy__(G)) { goto l55; } yyprintf((stderr, " ok %s @ %s\n", "QUESTION", G->buf+G->pos)); return 1; - l52:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l55:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "QUESTION", G->buf+G->pos)); return 0; } YY_RULE(int) yy_primary(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; yyprintf((stderr, "%s\n", "primary")); - { int yypos54= G->pos, yythunkpos54= G->thunkpos; if (!yy_identifier(G)) goto l55; yyDo(G, yy_1_primary, G->begin, G->end); if (!yy_COLON(G)) goto l55; if (!yy_identifier(G)) goto l55; - { int yypos56= G->pos, yythunkpos56= G->thunkpos; if (!yy_EQUAL(G)) goto l56; goto l55; - l56:; G->pos= yypos56; G->thunkpos= yythunkpos56; - } yyDo(G, yy_2_primary, G->begin, G->end); goto l54; - l55:; G->pos= yypos54; G->thunkpos= yythunkpos54; if (!yy_identifier(G)) goto l57; - { int yypos58= G->pos, yythunkpos58= G->thunkpos; if (!yy_EQUAL(G)) goto l58; goto l57; - l58:; G->pos= yypos58; G->thunkpos= yythunkpos58; - } yyDo(G, yy_3_primary, G->begin, G->end); goto l54; - l57:; G->pos= yypos54; G->thunkpos= yythunkpos54; if (!yy_OPEN(G)) goto l59; if (!yy_expression(G)) goto l59; if (!yy_CLOSE(G)) goto l59; goto l54; - l59:; G->pos= yypos54; G->thunkpos= yythunkpos54; if (!yy_literal(G)) goto l60; yyDo(G, yy_4_primary, G->begin, G->end); goto l54; - l60:; G->pos= yypos54; G->thunkpos= yythunkpos54; if (!yy_class(G)) goto l61; yyDo(G, yy_5_primary, G->begin, G->end); goto l54; - l61:; G->pos= yypos54; G->thunkpos= yythunkpos54; if (!yy_DOT(G)) goto l62; yyDo(G, yy_6_primary, G->begin, G->end); goto l54; - l62:; G->pos= yypos54; G->thunkpos= yythunkpos54; if (!yy_action(G)) goto l63; yyDo(G, yy_7_primary, G->begin, G->end); goto l54; - l63:; G->pos= yypos54; G->thunkpos= yythunkpos54; if (!yy_BEGIN(G)) goto l64; yyDo(G, yy_8_primary, G->begin, G->end); goto l54; - l64:; G->pos= yypos54; G->thunkpos= yythunkpos54; if (!yy_END(G)) goto l53; yyDo(G, yy_9_primary, G->begin, G->end); + { int yypos57= G->pos, yythunkpos57= G->thunkpos; if (!yy_identifier(G)) { goto l58; } yyDo(G, yy_1_primary, G->begin, G->end); if (!yy_COLON(G)) { goto l58; } if (!yy_identifier(G)) { goto l58; } + { int yypos59= G->pos, yythunkpos59= G->thunkpos; if (!yy_EQUAL(G)) { goto l59; } goto l58; + l59:; G->pos= yypos59; G->thunkpos= yythunkpos59; + } yyDo(G, yy_2_primary, G->begin, G->end); goto l57; + l58:; G->pos= yypos57; G->thunkpos= yythunkpos57; if (!yy_identifier(G)) { goto l60; } + { int yypos61= G->pos, yythunkpos61= G->thunkpos; if (!yy_EQUAL(G)) { goto l61; } goto l60; + l61:; G->pos= yypos61; G->thunkpos= yythunkpos61; + } yyDo(G, yy_3_primary, G->begin, G->end); goto l57; + l60:; G->pos= yypos57; G->thunkpos= yythunkpos57; if (!yy_OPEN(G)) { goto l62; } if (!yy_expression(G)) { goto l62; } if (!yy_CLOSE(G)) { goto l62; } goto l57; + l62:; G->pos= yypos57; G->thunkpos= yythunkpos57; if (!yy_literal(G)) { goto l63; } yyDo(G, yy_4_primary, G->begin, G->end); goto l57; + l63:; G->pos= yypos57; G->thunkpos= yythunkpos57; if (!yy_class(G)) { goto l64; } yyDo(G, yy_5_primary, G->begin, G->end); goto l57; + l64:; G->pos= yypos57; G->thunkpos= yythunkpos57; if (!yy_DOT(G)) { goto l65; } yyDo(G, yy_6_primary, G->begin, G->end); goto l57; + l65:; G->pos= yypos57; G->thunkpos= yythunkpos57; if (!yy_action(G)) { goto l66; } yyDo(G, yy_7_primary, G->begin, G->end); goto l57; + l66:; G->pos= yypos57; G->thunkpos= yythunkpos57; if (!yy_BEGIN(G)) { goto l67; } yyDo(G, yy_8_primary, G->begin, G->end); goto l57; + l67:; G->pos= yypos57; G->thunkpos= yythunkpos57; if (!yy_END(G)) { goto l56; } yyDo(G, yy_9_primary, G->begin, G->end); + } + l57:; + { int yypos68= G->pos, yythunkpos68= G->thunkpos; if (!yy_errblock(G)) { goto l68; } yyDo(G, yy_10_primary, G->begin, G->end); goto l69; + l68:; G->pos= yypos68; G->thunkpos= yythunkpos68; } - l54:; + l69:; yyprintf((stderr, " ok %s @ %s\n", "primary", G->buf+G->pos)); return 1; - l53:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l56:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "primary", G->buf+G->pos)); return 0; } YY_RULE(int) yy_NOT(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "NOT")); if (!yymatchChar(G, '!')) goto l65; if (!yy__(G)) goto l65; + yyprintf((stderr, "%s\n", "NOT")); if (!yymatchChar(G, '!')) goto l70; if (!yy__(G)) { goto l70; } yyprintf((stderr, " ok %s @ %s\n", "NOT", G->buf+G->pos)); return 1; - l65:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l70:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "NOT", G->buf+G->pos)); return 0; } YY_RULE(int) yy_suffix(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "suffix")); if (!yy_primary(G)) goto l66; - { int yypos67= G->pos, yythunkpos67= G->thunkpos; - { int yypos69= G->pos, yythunkpos69= G->thunkpos; if (!yy_QUESTION(G)) goto l70; yyDo(G, yy_1_suffix, G->begin, G->end); goto l69; - l70:; G->pos= yypos69; G->thunkpos= yythunkpos69; if (!yy_STAR(G)) goto l71; yyDo(G, yy_2_suffix, G->begin, G->end); goto l69; - l71:; G->pos= yypos69; G->thunkpos= yythunkpos69; if (!yy_PLUS(G)) goto l67; yyDo(G, yy_3_suffix, G->begin, G->end); + yyprintf((stderr, "%s\n", "suffix")); if (!yy_primary(G)) { goto l71; } + { int yypos72= G->pos, yythunkpos72= G->thunkpos; + { int yypos74= G->pos, yythunkpos74= G->thunkpos; if (!yy_QUESTION(G)) { goto l75; } yyDo(G, yy_1_suffix, G->begin, G->end); goto l74; + l75:; G->pos= yypos74; G->thunkpos= yythunkpos74; if (!yy_STAR(G)) { goto l76; } yyDo(G, yy_2_suffix, G->begin, G->end); goto l74; + l76:; G->pos= yypos74; G->thunkpos= yythunkpos74; if (!yy_PLUS(G)) { goto l72; } yyDo(G, yy_3_suffix, G->begin, G->end); } - l69:; goto l68; - l67:; G->pos= yypos67; G->thunkpos= yythunkpos67; + l74:; goto l73; + l72:; G->pos= yypos72; G->thunkpos= yythunkpos72; } - l68:; + l73:; yyprintf((stderr, " ok %s @ %s\n", "suffix", G->buf+G->pos)); return 1; - l66:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l71:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "suffix", G->buf+G->pos)); return 0; } YY_RULE(int) yy_action(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "action")); if (!yymatchChar(G, '{')) goto l72; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l72; - l73:; - { int yypos74= G->pos, yythunkpos74= G->thunkpos; if (!yy_braces(G)) goto l74; goto l73; - l74:; G->pos= yypos74; G->thunkpos= yythunkpos74; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l72; if (!yymatchChar(G, '}')) goto l72; if (!yy__(G)) goto l72; + yyprintf((stderr, "%s\n", "action")); if (!yymatchChar(G, '{')) goto l77; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l77; + l78:; + { int yypos79= G->pos, yythunkpos79= G->thunkpos; if (!yy_braces(G)) { goto l79; } goto l78; + l79:; G->pos= yypos79; G->thunkpos= yythunkpos79; + } yyText(G, G->begin, G->end); if (!(YY_END)) goto l77; if (!yymatchChar(G, '}')) goto l77; if (!yy__(G)) { goto l77; } yyprintf((stderr, " ok %s @ %s\n", "action", G->buf+G->pos)); return 1; - l72:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l77:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "action", G->buf+G->pos)); return 0; } YY_RULE(int) yy_AND(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "AND")); if (!yymatchChar(G, '&')) goto l75; if (!yy__(G)) goto l75; + yyprintf((stderr, "%s\n", "AND")); if (!yymatchChar(G, '&')) goto l80; if (!yy__(G)) { goto l80; } yyprintf((stderr, " ok %s @ %s\n", "AND", G->buf+G->pos)); return 1; - l75:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l80:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "AND", G->buf+G->pos)); return 0; } YY_RULE(int) yy_prefix(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; yyprintf((stderr, "%s\n", "prefix")); - { int yypos77= G->pos, yythunkpos77= G->thunkpos; if (!yy_AND(G)) goto l78; if (!yy_action(G)) goto l78; yyDo(G, yy_1_prefix, G->begin, G->end); goto l77; - l78:; G->pos= yypos77; G->thunkpos= yythunkpos77; if (!yy_AND(G)) goto l79; if (!yy_suffix(G)) goto l79; yyDo(G, yy_2_prefix, G->begin, G->end); goto l77; - l79:; G->pos= yypos77; G->thunkpos= yythunkpos77; if (!yy_NOT(G)) goto l80; if (!yy_suffix(G)) goto l80; yyDo(G, yy_3_prefix, G->begin, G->end); goto l77; - l80:; G->pos= yypos77; G->thunkpos= yythunkpos77; if (!yy_suffix(G)) goto l76; + { int yypos82= G->pos, yythunkpos82= G->thunkpos; if (!yy_AND(G)) { goto l83; } if (!yy_action(G)) { goto l83; } yyDo(G, yy_1_prefix, G->begin, G->end); goto l82; + l83:; G->pos= yypos82; G->thunkpos= yythunkpos82; if (!yy_AND(G)) { goto l84; } if (!yy_suffix(G)) { goto l84; } yyDo(G, yy_2_prefix, G->begin, G->end); goto l82; + l84:; G->pos= yypos82; G->thunkpos= yythunkpos82; if (!yy_NOT(G)) { goto l85; } if (!yy_suffix(G)) { goto l85; } yyDo(G, yy_3_prefix, G->begin, G->end); goto l82; + l85:; G->pos= yypos82; G->thunkpos= yythunkpos82; if (!yy_suffix(G)) { goto l81; } } - l77:; + l82:; yyprintf((stderr, " ok %s @ %s\n", "prefix", G->buf+G->pos)); return 1; - l76:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l81:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "prefix", G->buf+G->pos)); return 0; } YY_RULE(int) yy_BAR(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "BAR")); if (!yymatchChar(G, '|')) goto l81; if (!yy__(G)) goto l81; + yyprintf((stderr, "%s\n", "BAR")); if (!yymatchChar(G, '|')) goto l86; if (!yy__(G)) { goto l86; } yyprintf((stderr, " ok %s @ %s\n", "BAR", G->buf+G->pos)); return 1; - l81:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l86:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "BAR", G->buf+G->pos)); return 0; } YY_RULE(int) yy_sequence(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "sequence")); if (!yy_prefix(G)) goto l82; - l83:; - { int yypos84= G->pos, yythunkpos84= G->thunkpos; if (!yy_prefix(G)) goto l84; yyDo(G, yy_1_sequence, G->begin, G->end); goto l83; - l84:; G->pos= yypos84; G->thunkpos= yythunkpos84; + yyprintf((stderr, "%s\n", "sequence")); if (!yy_prefix(G)) { goto l87; } + l88:; + { int yypos89= G->pos, yythunkpos89= G->thunkpos; if (!yy_prefix(G)) { goto l89; } yyDo(G, yy_1_sequence, G->begin, G->end); goto l88; + l89:; G->pos= yypos89; G->thunkpos= yythunkpos89; } yyprintf((stderr, " ok %s @ %s\n", "sequence", G->buf+G->pos)); return 1; - l82:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l87:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "sequence", G->buf+G->pos)); return 0; } YY_RULE(int) yy_SEMICOLON(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "SEMICOLON")); if (!yymatchChar(G, ';')) goto l85; if (!yy__(G)) goto l85; + yyprintf((stderr, "%s\n", "SEMICOLON")); if (!yymatchChar(G, ';')) goto l90; if (!yy__(G)) { goto l90; } yyprintf((stderr, " ok %s @ %s\n", "SEMICOLON", G->buf+G->pos)); return 1; - l85:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l90:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "SEMICOLON", G->buf+G->pos)); return 0; } YY_RULE(int) yy_expression(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "expression")); if (!yy_sequence(G)) goto l86; - l87:; - { int yypos88= G->pos, yythunkpos88= G->thunkpos; if (!yy_BAR(G)) goto l88; if (!yy_sequence(G)) goto l88; yyDo(G, yy_1_expression, G->begin, G->end); goto l87; - l88:; G->pos= yypos88; G->thunkpos= yythunkpos88; + yyprintf((stderr, "%s\n", "expression")); if (!yy_sequence(G)) { goto l91; } + l92:; + { int yypos93= G->pos, yythunkpos93= G->thunkpos; if (!yy_BAR(G)) { goto l93; } if (!yy_sequence(G)) { goto l93; } yyDo(G, yy_1_expression, G->begin, G->end); goto l92; + l93:; G->pos= yypos93; G->thunkpos= yythunkpos93; } yyprintf((stderr, " ok %s @ %s\n", "expression", G->buf+G->pos)); return 1; - l86:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l91:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "expression", G->buf+G->pos)); return 0; } YY_RULE(int) yy_EQUAL(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "EQUAL")); if (!yymatchChar(G, '=')) goto l89; if (!yy__(G)) goto l89; + yyprintf((stderr, "%s\n", "EQUAL")); if (!yymatchChar(G, '=')) goto l94; if (!yy__(G)) { goto l94; } yyprintf((stderr, " ok %s @ %s\n", "EQUAL", G->buf+G->pos)); return 1; - l89:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l94:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "EQUAL", G->buf+G->pos)); return 0; } YY_RULE(int) yy_identifier(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "identifier")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l90; if (!yymatchClass(G, (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 l90; - l91:; - { int yypos92= G->pos, yythunkpos92= G->thunkpos; if (!yymatchClass(G, (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 l92; goto l91; - l92:; G->pos= yypos92; G->thunkpos= yythunkpos92; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l90; if (!yy__(G)) goto l90; + yyprintf((stderr, "%s\n", "identifier")); yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l95; if (!yymatchClass(G, (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 l95; + l96:; + { int yypos97= G->pos, yythunkpos97= G->thunkpos; if (!yymatchClass(G, (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 l97; goto l96; + l97:; G->pos= yypos97; G->thunkpos= yythunkpos97; + } yyText(G, G->begin, G->end); if (!(YY_END)) goto l95; if (!yy__(G)) { goto l95; } yyprintf((stderr, " ok %s @ %s\n", "identifier", G->buf+G->pos)); return 1; - l90:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l95:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "identifier", G->buf+G->pos)); return 0; } YY_RULE(int) yy_RPERCENT(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "RPERCENT")); if (!yymatchString(G, "%}")) goto l93; if (!yy__(G)) goto l93; + yyprintf((stderr, "%s\n", "RPERCENT")); if (!yymatchString(G, "%}")) goto l98; if (!yy__(G)) { goto l98; } yyprintf((stderr, " ok %s @ %s\n", "RPERCENT", G->buf+G->pos)); return 1; - l93:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l98:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "RPERCENT", G->buf+G->pos)); return 0; } YY_RULE(int) yy_end_of_file(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; yyprintf((stderr, "%s\n", "end_of_file")); - { int yypos95= G->pos, yythunkpos95= G->thunkpos; if (!yymatchDot(G)) goto l95; goto l94; - l95:; G->pos= yypos95; G->thunkpos= yythunkpos95; + { int yypos100= G->pos, yythunkpos100= G->thunkpos; if (!yymatchDot(G)) goto l100; goto l99; + l100:; G->pos= yypos100; G->thunkpos= yythunkpos100; } yyprintf((stderr, " ok %s @ %s\n", "end_of_file", G->buf+G->pos)); return 1; - l94:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l99:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "end_of_file", G->buf+G->pos)); return 0; } YY_RULE(int) yy_trailer(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "trailer")); if (!yymatchString(G, "%%")) goto l96; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l96; - l97:; - { int yypos98= G->pos, yythunkpos98= G->thunkpos; if (!yymatchDot(G)) goto l98; goto l97; - l98:; G->pos= yypos98; G->thunkpos= yythunkpos98; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l96; yyDo(G, yy_1_trailer, G->begin, G->end); + yyprintf((stderr, "%s\n", "trailer")); if (!yymatchString(G, "%%")) goto l101; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l101; + l102:; + { int yypos103= G->pos, yythunkpos103= G->thunkpos; if (!yymatchDot(G)) goto l103; goto l102; + l103:; G->pos= yypos103; G->thunkpos= yythunkpos103; + } yyText(G, G->begin, G->end); if (!(YY_END)) goto l101; yyDo(G, yy_1_trailer, G->begin, G->end); yyprintf((stderr, " ok %s @ %s\n", "trailer", G->buf+G->pos)); return 1; - l96:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l101:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "trailer", G->buf+G->pos)); return 0; } YY_RULE(int) yy_definition(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "definition")); if (!yy_identifier(G)) goto l99; yyDo(G, yy_1_definition, G->begin, G->end); if (!yy_EQUAL(G)) goto l99; if (!yy_expression(G)) goto l99; yyDo(G, yy_2_definition, G->begin, G->end); - { int yypos100= G->pos, yythunkpos100= G->thunkpos; if (!yy_SEMICOLON(G)) goto l100; goto l101; - l100:; G->pos= yypos100; G->thunkpos= yythunkpos100; + yyprintf((stderr, "%s\n", "definition")); if (!yy_identifier(G)) { goto l104; } yyDo(G, yy_1_definition, G->begin, G->end); if (!yy_EQUAL(G)) { goto l104; } if (!yy_expression(G)) { goto l104; } yyDo(G, yy_2_definition, G->begin, G->end); + { int yypos105= G->pos, yythunkpos105= G->thunkpos; if (!yy_SEMICOLON(G)) { goto l105; } goto l106; + l105:; G->pos= yypos105; G->thunkpos= yythunkpos105; } - l101:; + l106:; yyprintf((stderr, " ok %s @ %s\n", "definition", G->buf+G->pos)); return 1; - l99:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l104:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "definition", G->buf+G->pos)); return 0; } YY_RULE(int) yy_declaration(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "declaration")); if (!yymatchString(G, "%{")) goto l102; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l102; - l103:; - { int yypos104= G->pos, yythunkpos104= G->thunkpos; - { int yypos105= G->pos, yythunkpos105= G->thunkpos; if (!yymatchString(G, "%}")) goto l105; goto l104; - l105:; G->pos= yypos105; G->thunkpos= yythunkpos105; - } if (!yymatchDot(G)) goto l104; goto l103; - l104:; G->pos= yypos104; G->thunkpos= yythunkpos104; - } yyText(G, G->begin, G->end); if (!(YY_END)) goto l102; if (!yy_RPERCENT(G)) goto l102; yyDo(G, yy_1_declaration, G->begin, G->end); + yyprintf((stderr, "%s\n", "declaration")); if (!yymatchString(G, "%{")) goto l107; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l107; + l108:; + { int yypos109= G->pos, yythunkpos109= G->thunkpos; + { int yypos110= G->pos, yythunkpos110= G->thunkpos; if (!yymatchString(G, "%}")) goto l110; goto l109; + l110:; G->pos= yypos110; G->thunkpos= yythunkpos110; + } if (!yymatchDot(G)) goto l109; goto l108; + l109:; G->pos= yypos109; G->thunkpos= yythunkpos109; + } yyText(G, G->begin, G->end); if (!(YY_END)) goto l107; if (!yy_RPERCENT(G)) { goto l107; } yyDo(G, yy_1_declaration, G->begin, G->end); yyprintf((stderr, " ok %s @ %s\n", "declaration", G->buf+G->pos)); return 1; - l102:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l107:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "declaration", G->buf+G->pos)); return 0; } YY_RULE(int) yy__(GREG *G) { yyprintf((stderr, "%s\n", "_")); - l107:; - { int yypos108= G->pos, yythunkpos108= G->thunkpos; - { int yypos109= G->pos, yythunkpos109= G->thunkpos; if (!yy_space(G)) goto l110; goto l109; - l110:; G->pos= yypos109; G->thunkpos= yythunkpos109; if (!yy_comment(G)) goto l108; + l112:; + { int yypos113= G->pos, yythunkpos113= G->thunkpos; + { int yypos114= G->pos, yythunkpos114= G->thunkpos; if (!yy_space(G)) { goto l115; } goto l114; + l115:; G->pos= yypos114; G->thunkpos= yythunkpos114; if (!yy_comment(G)) { goto l113; } } - l109:; goto l107; - l108:; G->pos= yypos108; G->thunkpos= yythunkpos108; + l114:; goto l112; + l113:; G->pos= yypos113; G->thunkpos= yythunkpos113; } yyprintf((stderr, " ok %s @ %s\n", "_", G->buf+G->pos)); return 1; } YY_RULE(int) yy_grammar(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; - yyprintf((stderr, "%s\n", "grammar")); if (!yy__(G)) goto l111; - { int yypos114= G->pos, yythunkpos114= G->thunkpos; if (!yy_declaration(G)) goto l115; goto l114; - l115:; G->pos= yypos114; G->thunkpos= yythunkpos114; if (!yy_definition(G)) goto l111; - } - l114:; - l112:; - { int yypos113= G->pos, yythunkpos113= G->thunkpos; - { int yypos116= G->pos, yythunkpos116= G->thunkpos; if (!yy_declaration(G)) goto l117; goto l116; - l117:; G->pos= yypos116; G->thunkpos= yythunkpos116; if (!yy_definition(G)) goto l113; + yyprintf((stderr, "%s\n", "grammar")); if (!yy__(G)) { goto l116; } + { int yypos119= G->pos, yythunkpos119= G->thunkpos; if (!yy_declaration(G)) { goto l120; } goto l119; + l120:; G->pos= yypos119; G->thunkpos= yythunkpos119; if (!yy_definition(G)) { goto l116; } } - l116:; goto l112; - l113:; G->pos= yypos113; G->thunkpos= yythunkpos113; + l119:; + l117:; + { int yypos118= G->pos, yythunkpos118= G->thunkpos; + { int yypos121= G->pos, yythunkpos121= G->thunkpos; if (!yy_declaration(G)) { goto l122; } goto l121; + l122:; G->pos= yypos121; G->thunkpos= yythunkpos121; if (!yy_definition(G)) { goto l118; } } - { int yypos118= G->pos, yythunkpos118= G->thunkpos; if (!yy_trailer(G)) goto l118; goto l119; + l121:; goto l117; l118:; G->pos= yypos118; G->thunkpos= yythunkpos118; } - l119:; if (!yy_end_of_file(G)) goto l111; + { int yypos123= G->pos, yythunkpos123= G->thunkpos; if (!yy_trailer(G)) { goto l123; } goto l124; + l123:; G->pos= yypos123; G->thunkpos= yythunkpos123; + } + l124:; if (!yy_end_of_file(G)) { goto l116; } yyprintf((stderr, " ok %s @ %s\n", "grammar", G->buf+G->pos)); return 1; - l111:; G->pos= yypos0; G->thunkpos= yythunkpos0; + l116:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "grammar", G->buf+G->pos)); return 0; } @@ -908,12 +945,13 @@ YY_PARSE(int) YY_NAME(parse_from)(GREG *G, yyrule yystart) G->buf= YY_ALLOC(G->buflen, G->data); G->textlen= 1024; G->text= YY_ALLOC(G->textlen, G->data); - G->thunkslen= 32; + G->thunkslen= YY_STACK_SIZE; G->thunks= YY_ALLOC(sizeof(yythunk) * G->thunkslen, G->data); - G->valslen= 32; + G->valslen= YY_STACK_SIZE; G->vals= YY_ALLOC(sizeof(YYSTYPE) * G->valslen, G->data); G->begin= G->end= G->pos= G->limit= G->thunkpos= 0; } + G->pos = 0; G->begin= G->end= G->pos; G->thunkpos= 0; G->val= G->vals; @@ -941,7 +979,7 @@ YY_PARSE(int) YY_NAME(parse)(GREG *G) return YY_NAME(parse_from)(G, yy_grammar); } -YY_PARSE(GREG *) YY_NAME(parse_new)(void *data) +YY_PARSE(GREG *) YY_NAME(parse_new)(YY_XTYPE data) { GREG *G = (GREG *)YY_CALLOC(1, sizeof(GREG), G->data); G->data = data; diff --git a/greg.g b/greg.g index 2dd462f..558e9ae 100644 --- a/greg.g +++ b/greg.g @@ -84,11 +84,12 @@ prefix= AND action { push(makePredicate(yytext)); } | suffix suffix= primary (QUESTION { push(makeQuery(pop())); } - | STAR { push(makeStar (pop())); } - | PLUS { push(makePlus (pop())); } - )? + | STAR { push(makeStar (pop())); } + | PLUS { push(makePlus (pop())); } + )? -primary= identifier { push(makeVariable(yytext)); } +primary= ( + identifier { push(makeVariable(yytext)); } COLON identifier !EQUAL { Node *name= makeName(findRule(yytext)); name->name.variable= pop(); push(name); } | identifier !EQUAL { push(makeName(findRule(yytext))); } | OPEN expression CLOSE @@ -98,6 +99,7 @@ primary= identifier { push(makeVariable(yytext)); } | action { push(makeAction(yytext)); } | BEGIN { push(makePredicate("YY_BEGIN")); } | END { push(makePredicate("YY_END")); } + ) (errblock { Node *node = pop(); ((struct Any *) node)->errblock = strdup(yytext); push(node); })? # Lexical syntax @@ -115,6 +117,8 @@ char= '\\' [abefnrtv'"\[\]\\] | '\\' [0-7][0-7]? | !'\\' . + +errblock= '~{' < braces* > '}' - action= '{' < braces* > '}' - braces= '{' (!'}' .)* '}' diff --git a/greg.h b/greg.h index 0f4bc39..a333bbc 100644 --- a/greg.h +++ b/greg.h @@ -20,7 +20,7 @@ #define GREG_MAJOR 0 #define GREG_MINOR 4 -#define GREG_LEVEL 0 +#define GREG_LEVEL 1 enum { Unknown= 0, Rule, Variable, Name, Dot, Character, String, Class, Action, Predicate, Alternate, Sequence, PeekFor, PeekNot, Query, Star, Plus }; @@ -31,23 +31,23 @@ enum { typedef union Node Node; -struct Rule { int type; Node *next; char *name; Node *variables; Node *expression; int id; int flags; }; -struct Variable { int type; Node *next; char *name; Node *value; int offset; }; -struct Name { int type; Node *next; Node *rule; Node *variable; }; -struct Dot { int type; Node *next; }; -struct Character { int type; Node *next; char *value; }; -struct String { int type; Node *next; char *value; }; -struct Class { int type; Node *next; unsigned char *value; }; -struct Action { int type; Node *next; char *text; Node *list; char *name; Node *rule; }; -struct Predicate { int type; Node *next; char *text; }; -struct Alternate { int type; Node *next; Node *first; Node *last; }; -struct Sequence { int type; Node *next; Node *first; Node *last; }; -struct PeekFor { int type; Node *next; Node *element; }; -struct PeekNot { int type; Node *next; Node *element; }; -struct Query { int type; Node *next; Node *element; }; -struct Star { int type; Node *next; Node *element; }; -struct Plus { int type; Node *next; Node *element; }; -struct Any { int type; Node *next; }; +struct Rule { int type; Node *next; char *errblock; char *name; Node *variables; Node *expression; int id; int flags; }; +struct Variable { int type; Node *next; char *errblock; char *name; Node *value; int offset; }; +struct Name { int type; Node *next; char *errblock; Node *rule; Node *variable; }; +struct Dot { int type; Node *next; char *errblock; }; +struct Character { int type; Node *next; char *errblock; char *value; }; +struct String { int type; Node *next; char *errblock; char *value; }; +struct Class { int type; Node *next; char *errblock; unsigned char *value; }; +struct Action { int type; Node *next; char *errblock; char *text; Node *list; char *name; Node *rule; }; +struct Predicate { int type; Node *next; char *errblock; char *text; }; +struct Alternate { int type; Node *next; char *errblock; Node *first; Node *last; }; +struct Sequence { int type; Node *next; char *errblock; Node *first; Node *last; }; +struct PeekFor { int type; Node *next; char *errblock; Node *element; }; +struct PeekNot { int type; Node *next; char *errblock; Node *element; }; +struct Query { int type; Node *next; char *errblock; Node *element; }; +struct Star { int type; Node *next; char *errblock; Node *element; }; +struct Plus { int type; Node *next; char *errblock; Node *element; }; +struct Any { int type; Node *next; char *errblock; }; union Node { diff --git a/tree.c b/tree.c index 0fec8f3..772256b 100644 --- a/tree.c +++ b/tree.c @@ -38,6 +38,7 @@ static inline Node *_newNode(int type, int size) { Node *node= calloc(1, size); node->type= type; + ((struct Any *) node)->errblock= NULL; return node; }