1 /* A recursive-descent parser generated by peg 0.1.9 */
2 
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #define YYRULECOUNT 36
7 
8 # include "tree.h"
9 # include "version.h"
10 
11 # include <stdio.h>
12 # include <stdlib.h>
13 # include <unistd.h>
14 # include <string.h>
15 # include <libgen.h>
16 # include <assert.h>
17 
18   typedef struct Header Header;
19 
20   struct Header {
21     char   *text;
22     Header *next;
23   };
24 
25   FILE *input= 0;
26 
27   int   verboseFlag= 0;
28 
29   static int	 lineNumber= 0;
30   static char	*fileName= 0;
31   static char	*trailer= 0;
32   static Header	*headers= 0;
33 
34   void makeHeader(char *text);
35   void makeTrailer(char *text);
36 
37   void yyerror(char *message);
38 
39 # define YY_INPUT(buf, result, max)		\
40   {						\
41     int c= getc(input);				\
42     if ('\n' == c || '\r' == c) ++lineNumber;	\
43     result= (EOF == c) ? 0 : (*(buf)= c, 1);	\
44   }
45 
46 # define YY_LOCAL(T)	static T
47 # define YY_RULE(T)	static T
48 
49 #ifndef YY_LOCAL
50 #define YY_LOCAL(T)	static T
51 #endif
52 #ifndef YY_ACTION
53 #define YY_ACTION(T)	static T
54 #endif
55 #ifndef YY_RULE
56 #define YY_RULE(T)	static T
57 #endif
58 #ifndef YY_PARSE
59 #define YY_PARSE(T)	T
60 #endif
61 #ifndef YYPARSE
62 #define YYPARSE		yyparse
63 #endif
64 #ifndef YYPARSEFROM
65 #define YYPARSEFROM	yyparsefrom
66 #endif
67 #ifndef YY_INPUT
68 #define YY_INPUT(buf, result, max_size)			\
69   {							\
70     int yyc= getchar();					\
71     result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1);	\
72     yyprintf((stderr, "<%c>", yyc));			\
73   }
74 #endif
75 #ifndef YY_BEGIN
76 #define YY_BEGIN	( ctx->begin= ctx->pos, 1)
77 #endif
78 #ifndef YY_END
79 #define YY_END		( ctx->end= ctx->pos, 1)
80 #endif
81 #ifdef YY_DEBUG
82 # define yyprintf(args)	fprintf args
83 #else
84 # define yyprintf(args)
85 #endif
86 #ifndef YYSTYPE
87 #define YYSTYPE	int
88 #endif
89 
90 #ifndef YY_PART
91 
92 typedef struct _yycontext yycontext;
93 typedef void (*yyaction)(yycontext *ctx, char *yytext, int yyleng);
94 typedef struct _yythunk { int begin, end;  yyaction  action;  struct _yythunk *next; } yythunk;
95 
96 struct _yycontext {
97   char     *buf;
98   int       buflen;
99   int       pos;
100   int       limit;
101   char     *text;
102   int       textlen;
103   int       begin;
104   int       end;
105   int       textmax;
106   yythunk  *thunks;
107   int       thunkslen;
108   int       thunkpos;
109   YYSTYPE   yy;
110   YYSTYPE  *val;
111   YYSTYPE  *vals;
112   int       valslen;
113 #ifdef YY_CTX_MEMBERS
114   YY_CTX_MEMBERS
115 #endif
116 };
117 
118 #ifdef YY_CTX_LOCAL
119 #define YY_CTX_PARAM_	yycontext *yyctx,
120 #define YY_CTX_PARAM	yycontext *yyctx
121 #define YY_CTX_ARG_	yyctx,
122 #define YY_CTX_ARG	yyctx
123 #else
124 #define YY_CTX_PARAM_
125 #define YY_CTX_PARAM
126 #define YY_CTX_ARG_
127 #define YY_CTX_ARG
128 yycontext yyctx0;
129 yycontext *yyctx= &yyctx0;
130 #endif
131 
yyrefill(yycontext * ctx)132 YY_LOCAL(int) yyrefill(yycontext *ctx)
133 {
134   int yyn;
135   while (ctx->buflen - ctx->pos < 512)
136     {
137       ctx->buflen *= 2;
138       ctx->buf= (char *)realloc(ctx->buf, ctx->buflen);
139     }
140   YY_INPUT((ctx->buf + ctx->pos), yyn, (ctx->buflen - ctx->pos));
141   if (!yyn) return 0;
142   ctx->limit += yyn;
143   return 1;
144 }
145 
yymatchDot(yycontext * ctx)146 YY_LOCAL(int) yymatchDot(yycontext *ctx)
147 {
148   if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;
149   ++ctx->pos;
150   return 1;
151 }
152 
yymatchChar(yycontext * ctx,int c)153 YY_LOCAL(int) yymatchChar(yycontext *ctx, int c)
154 {
155   if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;
156   if ((unsigned char)ctx->buf[ctx->pos] == c)
157     {
158       ++ctx->pos;
159       yyprintf((stderr, "  ok   yymatchChar(ctx, %c) @ %s\n", c, ctx->buf+ctx->pos));
160       return 1;
161     }
162   yyprintf((stderr, "  fail yymatchChar(ctx, %c) @ %s\n", c, ctx->buf+ctx->pos));
163   return 0;
164 }
165 
yymatchString(yycontext * ctx,char * s)166 YY_LOCAL(int) yymatchString(yycontext *ctx, char *s)
167 {
168   int yysav= ctx->pos;
169   while (*s)
170     {
171       if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;
172       if (ctx->buf[ctx->pos] != *s)
173         {
174           ctx->pos= yysav;
175           return 0;
176         }
177       ++s;
178       ++ctx->pos;
179     }
180   return 1;
181 }
182 
yymatchClass(yycontext * ctx,unsigned char * bits)183 YY_LOCAL(int) yymatchClass(yycontext *ctx, unsigned char *bits)
184 {
185   int c;
186   if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;
187   c= (unsigned char)ctx->buf[ctx->pos];
188   if (bits[c >> 3] & (1 << (c & 7)))
189     {
190       ++ctx->pos;
191       yyprintf((stderr, "  ok   yymatchClass @ %s\n", ctx->buf+ctx->pos));
192       return 1;
193     }
194   yyprintf((stderr, "  fail yymatchClass @ %s\n", ctx->buf+ctx->pos));
195   return 0;
196 }
197 
yyDo(yycontext * ctx,yyaction action,int begin,int end)198 YY_LOCAL(void) yyDo(yycontext *ctx, yyaction action, int begin, int end)
199 {
200   while (ctx->thunkpos >= ctx->thunkslen)
201     {
202       ctx->thunkslen *= 2;
203       ctx->thunks= (yythunk *)realloc(ctx->thunks, sizeof(yythunk) * ctx->thunkslen);
204     }
205   ctx->thunks[ctx->thunkpos].begin=  begin;
206   ctx->thunks[ctx->thunkpos].end=    end;
207   ctx->thunks[ctx->thunkpos].action= action;
208   ++ctx->thunkpos;
209 }
210 
yyText(yycontext * ctx,int begin,int end)211 YY_LOCAL(int) yyText(yycontext *ctx, int begin, int end)
212 {
213   int yyleng= end - begin;
214   if (yyleng <= 0)
215     yyleng= 0;
216   else
217     {
218       while (ctx->textlen < (yyleng + 1))
219 	{
220 	  ctx->textlen *= 2;
221 	  ctx->text= (char *)realloc(ctx->text, ctx->textlen);
222 	}
223       memcpy(ctx->text, ctx->buf + begin, yyleng);
224     }
225   ctx->text[yyleng]= '\0';
226   return yyleng;
227 }
228 
yyDone(yycontext * ctx)229 YY_LOCAL(void) yyDone(yycontext *ctx)
230 {
231   int pos;
232   for (pos= 0;  pos < ctx->thunkpos;  ++pos)
233     {
234       yythunk *thunk= &ctx->thunks[pos];
235       int yyleng= thunk->end ? yyText(ctx, thunk->begin, thunk->end) : thunk->begin;
236       yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, ctx->text));
237       thunk->action(ctx, ctx->text, yyleng);
238     }
239   ctx->thunkpos= 0;
240 }
241 
yyCommit(yycontext * ctx)242 YY_LOCAL(void) yyCommit(yycontext *ctx)
243 {
244   if ((ctx->limit -= ctx->pos))
245     {
246       memmove(ctx->buf, ctx->buf + ctx->pos, ctx->limit);
247     }
248   ctx->begin -= ctx->pos;
249   ctx->end -= ctx->pos;
250   ctx->pos= ctx->thunkpos= 0;
251 }
252 
yyAccept(yycontext * ctx,int tp0)253 YY_LOCAL(int) yyAccept(yycontext *ctx, int tp0)
254 {
255   if (tp0)
256     {
257       fprintf(stderr, "accept denied at %d\n", tp0);
258       return 0;
259     }
260   else
261     {
262       yyDone(ctx);
263       yyCommit(ctx);
264     }
265   return 1;
266 }
267 
yyPush(yycontext * ctx,char * text,int count)268 YY_LOCAL(void) yyPush(yycontext *ctx, char *text, int count)  { ctx->val += count; }
yyPop(yycontext * ctx,char * text,int count)269 YY_LOCAL(void) yyPop(yycontext *ctx, char *text, int count)   { ctx->val -= count; }
yySet(yycontext * ctx,char * text,int count)270 YY_LOCAL(void) yySet(yycontext *ctx, char *text, int count)   { ctx->val[count]= ctx->yy; }
271 
272 #endif /* YY_PART */
273 
274 #define	YYACCEPT	yyAccept(ctx, yythunkpos0)
275 
276 YY_RULE(int) yy_end_of_line(yycontext *ctx); /* 36 */
277 YY_RULE(int) yy_comment(yycontext *ctx); /* 35 */
278 YY_RULE(int) yy_space(yycontext *ctx); /* 34 */
279 YY_RULE(int) yy_braces(yycontext *ctx); /* 33 */
280 YY_RULE(int) yy_range(yycontext *ctx); /* 32 */
281 YY_RULE(int) yy_char(yycontext *ctx); /* 31 */
282 YY_RULE(int) yy_END(yycontext *ctx); /* 30 */
283 YY_RULE(int) yy_BEGIN(yycontext *ctx); /* 29 */
284 YY_RULE(int) yy_DOT(yycontext *ctx); /* 28 */
285 YY_RULE(int) yy_class(yycontext *ctx); /* 27 */
286 YY_RULE(int) yy_literal(yycontext *ctx); /* 26 */
287 YY_RULE(int) yy_CLOSE(yycontext *ctx); /* 25 */
288 YY_RULE(int) yy_OPEN(yycontext *ctx); /* 24 */
289 YY_RULE(int) yy_COLON(yycontext *ctx); /* 23 */
290 YY_RULE(int) yy_PLUS(yycontext *ctx); /* 22 */
291 YY_RULE(int) yy_STAR(yycontext *ctx); /* 21 */
292 YY_RULE(int) yy_QUESTION(yycontext *ctx); /* 20 */
293 YY_RULE(int) yy_primary(yycontext *ctx); /* 19 */
294 YY_RULE(int) yy_NOT(yycontext *ctx); /* 18 */
295 YY_RULE(int) yy_suffix(yycontext *ctx); /* 17 */
296 YY_RULE(int) yy_action(yycontext *ctx); /* 16 */
297 YY_RULE(int) yy_AND(yycontext *ctx); /* 15 */
298 YY_RULE(int) yy_prefix(yycontext *ctx); /* 14 */
299 YY_RULE(int) yy_BAR(yycontext *ctx); /* 13 */
300 YY_RULE(int) yy_sequence(yycontext *ctx); /* 12 */
301 YY_RULE(int) yy_SEMICOLON(yycontext *ctx); /* 11 */
302 YY_RULE(int) yy_expression(yycontext *ctx); /* 10 */
303 YY_RULE(int) yy_EQUAL(yycontext *ctx); /* 9 */
304 YY_RULE(int) yy_identifier(yycontext *ctx); /* 8 */
305 YY_RULE(int) yy_RPERCENT(yycontext *ctx); /* 7 */
306 YY_RULE(int) yy_end_of_file(yycontext *ctx); /* 6 */
307 YY_RULE(int) yy_trailer(yycontext *ctx); /* 5 */
308 YY_RULE(int) yy_definition(yycontext *ctx); /* 4 */
309 YY_RULE(int) yy_declaration(yycontext *ctx); /* 3 */
310 YY_RULE(int) yy__(yycontext *ctx); /* 2 */
311 YY_RULE(int) yy_grammar(yycontext *ctx); /* 1 */
312 
yy_9_primary(yycontext * ctx,char * yytext,int yyleng)313 YY_ACTION(void) yy_9_primary(yycontext *ctx, char *yytext, int yyleng)
314 {
315 #define yy ctx->yy
316 #define yypos ctx->pos
317 #define yythunkpos ctx->thunkpos
318   yyprintf((stderr, "do yy_9_primary\n"));
319    push(makePredicate("YY_END")); ;
320 #undef yythunkpos
321 #undef yypos
322 #undef yy
323 }
yy_8_primary(yycontext * ctx,char * yytext,int yyleng)324 YY_ACTION(void) yy_8_primary(yycontext *ctx, char *yytext, int yyleng)
325 {
326 #define yy ctx->yy
327 #define yypos ctx->pos
328 #define yythunkpos ctx->thunkpos
329   yyprintf((stderr, "do yy_8_primary\n"));
330    push(makePredicate("YY_BEGIN")); ;
331 #undef yythunkpos
332 #undef yypos
333 #undef yy
334 }
yy_7_primary(yycontext * ctx,char * yytext,int yyleng)335 YY_ACTION(void) yy_7_primary(yycontext *ctx, char *yytext, int yyleng)
336 {
337 #define yy ctx->yy
338 #define yypos ctx->pos
339 #define yythunkpos ctx->thunkpos
340   yyprintf((stderr, "do yy_7_primary\n"));
341    push(makeAction(yytext)); ;
342 #undef yythunkpos
343 #undef yypos
344 #undef yy
345 }
yy_6_primary(yycontext * ctx,char * yytext,int yyleng)346 YY_ACTION(void) yy_6_primary(yycontext *ctx, char *yytext, int yyleng)
347 {
348 #define yy ctx->yy
349 #define yypos ctx->pos
350 #define yythunkpos ctx->thunkpos
351   yyprintf((stderr, "do yy_6_primary\n"));
352    push(makeDot()); ;
353 #undef yythunkpos
354 #undef yypos
355 #undef yy
356 }
yy_5_primary(yycontext * ctx,char * yytext,int yyleng)357 YY_ACTION(void) yy_5_primary(yycontext *ctx, char *yytext, int yyleng)
358 {
359 #define yy ctx->yy
360 #define yypos ctx->pos
361 #define yythunkpos ctx->thunkpos
362   yyprintf((stderr, "do yy_5_primary\n"));
363    push(makeClass(yytext)); ;
364 #undef yythunkpos
365 #undef yypos
366 #undef yy
367 }
yy_4_primary(yycontext * ctx,char * yytext,int yyleng)368 YY_ACTION(void) yy_4_primary(yycontext *ctx, char *yytext, int yyleng)
369 {
370 #define yy ctx->yy
371 #define yypos ctx->pos
372 #define yythunkpos ctx->thunkpos
373   yyprintf((stderr, "do yy_4_primary\n"));
374    push(makeString(yytext)); ;
375 #undef yythunkpos
376 #undef yypos
377 #undef yy
378 }
yy_3_primary(yycontext * ctx,char * yytext,int yyleng)379 YY_ACTION(void) yy_3_primary(yycontext *ctx, char *yytext, int yyleng)
380 {
381 #define yy ctx->yy
382 #define yypos ctx->pos
383 #define yythunkpos ctx->thunkpos
384   yyprintf((stderr, "do yy_3_primary\n"));
385    push(makeName(findRule(yytext))); ;
386 #undef yythunkpos
387 #undef yypos
388 #undef yy
389 }
yy_2_primary(yycontext * ctx,char * yytext,int yyleng)390 YY_ACTION(void) yy_2_primary(yycontext *ctx, char *yytext, int yyleng)
391 {
392 #define yy ctx->yy
393 #define yypos ctx->pos
394 #define yythunkpos ctx->thunkpos
395   yyprintf((stderr, "do yy_2_primary\n"));
396    Node *name= makeName(findRule(yytext));  name->name.variable= pop();  push(name); ;
397 #undef yythunkpos
398 #undef yypos
399 #undef yy
400 }
yy_1_primary(yycontext * ctx,char * yytext,int yyleng)401 YY_ACTION(void) yy_1_primary(yycontext *ctx, char *yytext, int yyleng)
402 {
403 #define yy ctx->yy
404 #define yypos ctx->pos
405 #define yythunkpos ctx->thunkpos
406   yyprintf((stderr, "do yy_1_primary\n"));
407    push(makeVariable(yytext)); ;
408 #undef yythunkpos
409 #undef yypos
410 #undef yy
411 }
yy_3_suffix(yycontext * ctx,char * yytext,int yyleng)412 YY_ACTION(void) yy_3_suffix(yycontext *ctx, char *yytext, int yyleng)
413 {
414 #define yy ctx->yy
415 #define yypos ctx->pos
416 #define yythunkpos ctx->thunkpos
417   yyprintf((stderr, "do yy_3_suffix\n"));
418    push(makePlus (pop())); ;
419 #undef yythunkpos
420 #undef yypos
421 #undef yy
422 }
yy_2_suffix(yycontext * ctx,char * yytext,int yyleng)423 YY_ACTION(void) yy_2_suffix(yycontext *ctx, char *yytext, int yyleng)
424 {
425 #define yy ctx->yy
426 #define yypos ctx->pos
427 #define yythunkpos ctx->thunkpos
428   yyprintf((stderr, "do yy_2_suffix\n"));
429    push(makeStar (pop())); ;
430 #undef yythunkpos
431 #undef yypos
432 #undef yy
433 }
yy_1_suffix(yycontext * ctx,char * yytext,int yyleng)434 YY_ACTION(void) yy_1_suffix(yycontext *ctx, char *yytext, int yyleng)
435 {
436 #define yy ctx->yy
437 #define yypos ctx->pos
438 #define yythunkpos ctx->thunkpos
439   yyprintf((stderr, "do yy_1_suffix\n"));
440    push(makeQuery(pop())); ;
441 #undef yythunkpos
442 #undef yypos
443 #undef yy
444 }
yy_3_prefix(yycontext * ctx,char * yytext,int yyleng)445 YY_ACTION(void) yy_3_prefix(yycontext *ctx, char *yytext, int yyleng)
446 {
447 #define yy ctx->yy
448 #define yypos ctx->pos
449 #define yythunkpos ctx->thunkpos
450   yyprintf((stderr, "do yy_3_prefix\n"));
451    push(makePeekNot(pop())); ;
452 #undef yythunkpos
453 #undef yypos
454 #undef yy
455 }
yy_2_prefix(yycontext * ctx,char * yytext,int yyleng)456 YY_ACTION(void) yy_2_prefix(yycontext *ctx, char *yytext, int yyleng)
457 {
458 #define yy ctx->yy
459 #define yypos ctx->pos
460 #define yythunkpos ctx->thunkpos
461   yyprintf((stderr, "do yy_2_prefix\n"));
462    push(makePeekFor(pop())); ;
463 #undef yythunkpos
464 #undef yypos
465 #undef yy
466 }
yy_1_prefix(yycontext * ctx,char * yytext,int yyleng)467 YY_ACTION(void) yy_1_prefix(yycontext *ctx, char *yytext, int yyleng)
468 {
469 #define yy ctx->yy
470 #define yypos ctx->pos
471 #define yythunkpos ctx->thunkpos
472   yyprintf((stderr, "do yy_1_prefix\n"));
473    push(makePredicate(yytext)); ;
474 #undef yythunkpos
475 #undef yypos
476 #undef yy
477 }
yy_1_sequence(yycontext * ctx,char * yytext,int yyleng)478 YY_ACTION(void) yy_1_sequence(yycontext *ctx, char *yytext, int yyleng)
479 {
480 #define yy ctx->yy
481 #define yypos ctx->pos
482 #define yythunkpos ctx->thunkpos
483   yyprintf((stderr, "do yy_1_sequence\n"));
484    Node *f= pop();  push(Sequence_append(pop(), f)); ;
485 #undef yythunkpos
486 #undef yypos
487 #undef yy
488 }
yy_1_expression(yycontext * ctx,char * yytext,int yyleng)489 YY_ACTION(void) yy_1_expression(yycontext *ctx, char *yytext, int yyleng)
490 {
491 #define yy ctx->yy
492 #define yypos ctx->pos
493 #define yythunkpos ctx->thunkpos
494   yyprintf((stderr, "do yy_1_expression\n"));
495    Node *f= pop();  push(Alternate_append(pop(), f)); ;
496 #undef yythunkpos
497 #undef yypos
498 #undef yy
499 }
yy_2_definition(yycontext * ctx,char * yytext,int yyleng)500 YY_ACTION(void) yy_2_definition(yycontext *ctx, char *yytext, int yyleng)
501 {
502 #define yy ctx->yy
503 #define yypos ctx->pos
504 #define yythunkpos ctx->thunkpos
505   yyprintf((stderr, "do yy_2_definition\n"));
506    Node *e= pop();  Rule_setExpression(pop(), e); ;
507 #undef yythunkpos
508 #undef yypos
509 #undef yy
510 }
yy_1_definition(yycontext * ctx,char * yytext,int yyleng)511 YY_ACTION(void) yy_1_definition(yycontext *ctx, char *yytext, int yyleng)
512 {
513 #define yy ctx->yy
514 #define yypos ctx->pos
515 #define yythunkpos ctx->thunkpos
516   yyprintf((stderr, "do yy_1_definition\n"));
517    if (push(beginRule(findRule(yytext)))->rule.expression)
518 							    fprintf(stderr, "rule '%s' redefined\n", yytext); ;
519 #undef yythunkpos
520 #undef yypos
521 #undef yy
522 }
yy_1_trailer(yycontext * ctx,char * yytext,int yyleng)523 YY_ACTION(void) yy_1_trailer(yycontext *ctx, char *yytext, int yyleng)
524 {
525 #define yy ctx->yy
526 #define yypos ctx->pos
527 #define yythunkpos ctx->thunkpos
528   yyprintf((stderr, "do yy_1_trailer\n"));
529    makeTrailer(yytext); ;
530 #undef yythunkpos
531 #undef yypos
532 #undef yy
533 }
yy_1_declaration(yycontext * ctx,char * yytext,int yyleng)534 YY_ACTION(void) yy_1_declaration(yycontext *ctx, char *yytext, int yyleng)
535 {
536 #define yy ctx->yy
537 #define yypos ctx->pos
538 #define yythunkpos ctx->thunkpos
539   yyprintf((stderr, "do yy_1_declaration\n"));
540    makeHeader(yytext); ;
541 #undef yythunkpos
542 #undef yypos
543 #undef yy
544 }
545 
yy_end_of_line(yycontext * ctx)546 YY_RULE(int) yy_end_of_line(yycontext *ctx)
547 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
548   yyprintf((stderr, "%s\n", "end_of_line"));
549   {  int yypos2= ctx->pos, yythunkpos2= ctx->thunkpos;  if (!yymatchString(ctx, "\r\n")) goto l3;  goto l2;
550   l3:;	  ctx->pos= yypos2; ctx->thunkpos= yythunkpos2;  if (!yymatchChar(ctx, '\n')) goto l4;  goto l2;
551   l4:;	  ctx->pos= yypos2; ctx->thunkpos= yythunkpos2;  if (!yymatchChar(ctx, '\r')) goto l1;
552   }
553   l2:;
554   yyprintf((stderr, "  ok   %s @ %s\n", "end_of_line", ctx->buf+ctx->pos));
555   return 1;
556   l1:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
557   yyprintf((stderr, "  fail %s @ %s\n", "end_of_line", ctx->buf+ctx->pos));
558   return 0;
559 }
yy_comment(yycontext * ctx)560 YY_RULE(int) yy_comment(yycontext *ctx)
561 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
562   yyprintf((stderr, "%s\n", "comment"));  if (!yymatchChar(ctx, '#')) goto l5;
563   l6:;
564   {  int yypos7= ctx->pos, yythunkpos7= ctx->thunkpos;
565   {  int yypos8= ctx->pos, yythunkpos8= ctx->thunkpos;  if (!yy_end_of_line(ctx)) goto l8;  goto l7;
566   l8:;	  ctx->pos= yypos8; ctx->thunkpos= yythunkpos8;
567   }  if (!yymatchDot(ctx)) goto l7;  goto l6;
568   l7:;	  ctx->pos= yypos7; ctx->thunkpos= yythunkpos7;
569   }  if (!yy_end_of_line(ctx)) goto l5;
570   yyprintf((stderr, "  ok   %s @ %s\n", "comment", ctx->buf+ctx->pos));
571   return 1;
572   l5:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
573   yyprintf((stderr, "  fail %s @ %s\n", "comment", ctx->buf+ctx->pos));
574   return 0;
575 }
yy_space(yycontext * ctx)576 YY_RULE(int) yy_space(yycontext *ctx)
577 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
578   yyprintf((stderr, "%s\n", "space"));
579   {  int yypos10= ctx->pos, yythunkpos10= ctx->thunkpos;  if (!yymatchChar(ctx, ' ')) goto l11;  goto l10;
580   l11:;	  ctx->pos= yypos10; ctx->thunkpos= yythunkpos10;  if (!yymatchChar(ctx, '\t')) goto l12;  goto l10;
581   l12:;	  ctx->pos= yypos10; ctx->thunkpos= yythunkpos10;  if (!yy_end_of_line(ctx)) goto l9;
582   }
583   l10:;
584   yyprintf((stderr, "  ok   %s @ %s\n", "space", ctx->buf+ctx->pos));
585   return 1;
586   l9:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
587   yyprintf((stderr, "  fail %s @ %s\n", "space", ctx->buf+ctx->pos));
588   return 0;
589 }
yy_braces(yycontext * ctx)590 YY_RULE(int) yy_braces(yycontext *ctx)
591 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
592   yyprintf((stderr, "%s\n", "braces"));
593   {  int yypos14= ctx->pos, yythunkpos14= ctx->thunkpos;  if (!yymatchChar(ctx, '{')) goto l15;
594   l16:;
595   {  int yypos17= ctx->pos, yythunkpos17= ctx->thunkpos;  if (!yy_braces(ctx)) goto l17;  goto l16;
596   l17:;	  ctx->pos= yypos17; ctx->thunkpos= yythunkpos17;
597   }  if (!yymatchChar(ctx, '}')) goto l15;  goto l14;
598   l15:;	  ctx->pos= yypos14; ctx->thunkpos= yythunkpos14;
599   {  int yypos18= ctx->pos, yythunkpos18= ctx->thunkpos;  if (!yymatchChar(ctx, '}')) goto l18;  goto l13;
600   l18:;	  ctx->pos= yypos18; ctx->thunkpos= yythunkpos18;
601   }  if (!yymatchDot(ctx)) goto l13;
602   }
603   l14:;
604   yyprintf((stderr, "  ok   %s @ %s\n", "braces", ctx->buf+ctx->pos));
605   return 1;
606   l13:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
607   yyprintf((stderr, "  fail %s @ %s\n", "braces", ctx->buf+ctx->pos));
608   return 0;
609 }
yy_range(yycontext * ctx)610 YY_RULE(int) yy_range(yycontext *ctx)
611 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
612   yyprintf((stderr, "%s\n", "range"));
613   {  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;
614   l21:;	  ctx->pos= yypos20; ctx->thunkpos= yythunkpos20;  if (!yy_char(ctx)) goto l19;
615   }
616   l20:;
617   yyprintf((stderr, "  ok   %s @ %s\n", "range", ctx->buf+ctx->pos));
618   return 1;
619   l19:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
620   yyprintf((stderr, "  fail %s @ %s\n", "range", ctx->buf+ctx->pos));
621   return 0;
622 }
yy_char(yycontext * ctx)623 YY_RULE(int) yy_char(yycontext *ctx)
624 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
625   yyprintf((stderr, "%s\n", "char"));
626   {  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;
627   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;
628   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;
629   {  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;
630   l27:;	  ctx->pos= yypos27; ctx->thunkpos= yythunkpos27;
631   }
632   l28:;	  goto l23;
633   l26:;	  ctx->pos= yypos23; ctx->thunkpos= yythunkpos23;
634   {  int yypos29= ctx->pos, yythunkpos29= ctx->thunkpos;  if (!yymatchChar(ctx, '\\')) goto l29;  goto l22;
635   l29:;	  ctx->pos= yypos29; ctx->thunkpos= yythunkpos29;
636   }  if (!yymatchDot(ctx)) goto l22;
637   }
638   l23:;
639   yyprintf((stderr, "  ok   %s @ %s\n", "char", ctx->buf+ctx->pos));
640   return 1;
641   l22:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
642   yyprintf((stderr, "  fail %s @ %s\n", "char", ctx->buf+ctx->pos));
643   return 0;
644 }
yy_END(yycontext * ctx)645 YY_RULE(int) yy_END(yycontext *ctx)
646 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
647   yyprintf((stderr, "%s\n", "END"));  if (!yymatchChar(ctx, '>')) goto l30;  if (!yy__(ctx)) goto l30;
648   yyprintf((stderr, "  ok   %s @ %s\n", "END", ctx->buf+ctx->pos));
649   return 1;
650   l30:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
651   yyprintf((stderr, "  fail %s @ %s\n", "END", ctx->buf+ctx->pos));
652   return 0;
653 }
yy_BEGIN(yycontext * ctx)654 YY_RULE(int) yy_BEGIN(yycontext *ctx)
655 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
656   yyprintf((stderr, "%s\n", "BEGIN"));  if (!yymatchChar(ctx, '<')) goto l31;  if (!yy__(ctx)) goto l31;
657   yyprintf((stderr, "  ok   %s @ %s\n", "BEGIN", ctx->buf+ctx->pos));
658   return 1;
659   l31:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
660   yyprintf((stderr, "  fail %s @ %s\n", "BEGIN", ctx->buf+ctx->pos));
661   return 0;
662 }
yy_DOT(yycontext * ctx)663 YY_RULE(int) yy_DOT(yycontext *ctx)
664 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
665   yyprintf((stderr, "%s\n", "DOT"));  if (!yymatchChar(ctx, '.')) goto l32;  if (!yy__(ctx)) goto l32;
666   yyprintf((stderr, "  ok   %s @ %s\n", "DOT", ctx->buf+ctx->pos));
667   return 1;
668   l32:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
669   yyprintf((stderr, "  fail %s @ %s\n", "DOT", ctx->buf+ctx->pos));
670   return 0;
671 }
yy_class(yycontext * ctx)672 YY_RULE(int) yy_class(yycontext *ctx)
673 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
674   yyprintf((stderr, "%s\n", "class"));  if (!yymatchChar(ctx, '[')) goto l33;  yyText(ctx, ctx->begin, ctx->end);  if (!(YY_BEGIN)) goto l33;
675   l34:;
676   {  int yypos35= ctx->pos, yythunkpos35= ctx->thunkpos;
677   {  int yypos36= ctx->pos, yythunkpos36= ctx->thunkpos;  if (!yymatchChar(ctx, ']')) goto l36;  goto l35;
678   l36:;	  ctx->pos= yypos36; ctx->thunkpos= yythunkpos36;
679   }  if (!yy_range(ctx)) goto l35;  goto l34;
680   l35:;	  ctx->pos= yypos35; ctx->thunkpos= yythunkpos35;
681   }  yyText(ctx, ctx->begin, ctx->end);  if (!(YY_END)) goto l33;  if (!yymatchChar(ctx, ']')) goto l33;  if (!yy__(ctx)) goto l33;
682   yyprintf((stderr, "  ok   %s @ %s\n", "class", ctx->buf+ctx->pos));
683   return 1;
684   l33:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
685   yyprintf((stderr, "  fail %s @ %s\n", "class", ctx->buf+ctx->pos));
686   return 0;
687 }
yy_literal(yycontext * ctx)688 YY_RULE(int) yy_literal(yycontext *ctx)
689 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
690   yyprintf((stderr, "%s\n", "literal"));
691   {  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;
692   l40:;
693   {  int yypos41= ctx->pos, yythunkpos41= ctx->thunkpos;
694   {  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;
695   l42:;	  ctx->pos= yypos42; ctx->thunkpos= yythunkpos42;
696   }  if (!yy_char(ctx)) goto l41;  goto l40;
697   l41:;	  ctx->pos= yypos41; ctx->thunkpos= yythunkpos41;
698   }  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;
699   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;
700   l43:;
701   {  int yypos44= ctx->pos, yythunkpos44= ctx->thunkpos;
702   {  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;
703   l45:;	  ctx->pos= yypos45; ctx->thunkpos= yythunkpos45;
704   }  if (!yy_char(ctx)) goto l44;  goto l43;
705   l44:;	  ctx->pos= yypos44; ctx->thunkpos= yythunkpos44;
706   }  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;
707   }
708   l38:;
709   yyprintf((stderr, "  ok   %s @ %s\n", "literal", ctx->buf+ctx->pos));
710   return 1;
711   l37:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
712   yyprintf((stderr, "  fail %s @ %s\n", "literal", ctx->buf+ctx->pos));
713   return 0;
714 }
yy_CLOSE(yycontext * ctx)715 YY_RULE(int) yy_CLOSE(yycontext *ctx)
716 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
717   yyprintf((stderr, "%s\n", "CLOSE"));  if (!yymatchChar(ctx, ')')) goto l46;  if (!yy__(ctx)) goto l46;
718   yyprintf((stderr, "  ok   %s @ %s\n", "CLOSE", ctx->buf+ctx->pos));
719   return 1;
720   l46:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
721   yyprintf((stderr, "  fail %s @ %s\n", "CLOSE", ctx->buf+ctx->pos));
722   return 0;
723 }
yy_OPEN(yycontext * ctx)724 YY_RULE(int) yy_OPEN(yycontext *ctx)
725 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
726   yyprintf((stderr, "%s\n", "OPEN"));  if (!yymatchChar(ctx, '(')) goto l47;  if (!yy__(ctx)) goto l47;
727   yyprintf((stderr, "  ok   %s @ %s\n", "OPEN", ctx->buf+ctx->pos));
728   return 1;
729   l47:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
730   yyprintf((stderr, "  fail %s @ %s\n", "OPEN", ctx->buf+ctx->pos));
731   return 0;
732 }
yy_COLON(yycontext * ctx)733 YY_RULE(int) yy_COLON(yycontext *ctx)
734 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
735   yyprintf((stderr, "%s\n", "COLON"));  if (!yymatchChar(ctx, ':')) goto l48;  if (!yy__(ctx)) goto l48;
736   yyprintf((stderr, "  ok   %s @ %s\n", "COLON", ctx->buf+ctx->pos));
737   return 1;
738   l48:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
739   yyprintf((stderr, "  fail %s @ %s\n", "COLON", ctx->buf+ctx->pos));
740   return 0;
741 }
yy_PLUS(yycontext * ctx)742 YY_RULE(int) yy_PLUS(yycontext *ctx)
743 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
744   yyprintf((stderr, "%s\n", "PLUS"));  if (!yymatchChar(ctx, '+')) goto l49;  if (!yy__(ctx)) goto l49;
745   yyprintf((stderr, "  ok   %s @ %s\n", "PLUS", ctx->buf+ctx->pos));
746   return 1;
747   l49:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
748   yyprintf((stderr, "  fail %s @ %s\n", "PLUS", ctx->buf+ctx->pos));
749   return 0;
750 }
yy_STAR(yycontext * ctx)751 YY_RULE(int) yy_STAR(yycontext *ctx)
752 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
753   yyprintf((stderr, "%s\n", "STAR"));  if (!yymatchChar(ctx, '*')) goto l50;  if (!yy__(ctx)) goto l50;
754   yyprintf((stderr, "  ok   %s @ %s\n", "STAR", ctx->buf+ctx->pos));
755   return 1;
756   l50:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
757   yyprintf((stderr, "  fail %s @ %s\n", "STAR", ctx->buf+ctx->pos));
758   return 0;
759 }
yy_QUESTION(yycontext * ctx)760 YY_RULE(int) yy_QUESTION(yycontext *ctx)
761 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
762   yyprintf((stderr, "%s\n", "QUESTION"));  if (!yymatchChar(ctx, '?')) goto l51;  if (!yy__(ctx)) goto l51;
763   yyprintf((stderr, "  ok   %s @ %s\n", "QUESTION", ctx->buf+ctx->pos));
764   return 1;
765   l51:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
766   yyprintf((stderr, "  fail %s @ %s\n", "QUESTION", ctx->buf+ctx->pos));
767   return 0;
768 }
yy_primary(yycontext * ctx)769 YY_RULE(int) yy_primary(yycontext *ctx)
770 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
771   yyprintf((stderr, "%s\n", "primary"));
772   {  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;
773   {  int yypos55= ctx->pos, yythunkpos55= ctx->thunkpos;  if (!yy_EQUAL(ctx)) goto l55;  goto l54;
774   l55:;	  ctx->pos= yypos55; ctx->thunkpos= yythunkpos55;
775   }  yyDo(ctx, yy_2_primary, ctx->begin, ctx->end);  goto l53;
776   l54:;	  ctx->pos= yypos53; ctx->thunkpos= yythunkpos53;  if (!yy_identifier(ctx)) goto l56;
777   {  int yypos57= ctx->pos, yythunkpos57= ctx->thunkpos;  if (!yy_EQUAL(ctx)) goto l57;  goto l56;
778   l57:;	  ctx->pos= yypos57; ctx->thunkpos= yythunkpos57;
779   }  yyDo(ctx, yy_3_primary, ctx->begin, ctx->end);  goto l53;
780   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;
781   l58:;	  ctx->pos= yypos53; ctx->thunkpos= yythunkpos53;  if (!yy_literal(ctx)) goto l59;  yyDo(ctx, yy_4_primary, ctx->begin, ctx->end);  goto l53;
782   l59:;	  ctx->pos= yypos53; ctx->thunkpos= yythunkpos53;  if (!yy_class(ctx)) goto l60;  yyDo(ctx, yy_5_primary, ctx->begin, ctx->end);  goto l53;
783   l60:;	  ctx->pos= yypos53; ctx->thunkpos= yythunkpos53;  if (!yy_DOT(ctx)) goto l61;  yyDo(ctx, yy_6_primary, ctx->begin, ctx->end);  goto l53;
784   l61:;	  ctx->pos= yypos53; ctx->thunkpos= yythunkpos53;  if (!yy_action(ctx)) goto l62;  yyDo(ctx, yy_7_primary, ctx->begin, ctx->end);  goto l53;
785   l62:;	  ctx->pos= yypos53; ctx->thunkpos= yythunkpos53;  if (!yy_BEGIN(ctx)) goto l63;  yyDo(ctx, yy_8_primary, ctx->begin, ctx->end);  goto l53;
786   l63:;	  ctx->pos= yypos53; ctx->thunkpos= yythunkpos53;  if (!yy_END(ctx)) goto l52;  yyDo(ctx, yy_9_primary, ctx->begin, ctx->end);
787   }
788   l53:;
789   yyprintf((stderr, "  ok   %s @ %s\n", "primary", ctx->buf+ctx->pos));
790   return 1;
791   l52:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
792   yyprintf((stderr, "  fail %s @ %s\n", "primary", ctx->buf+ctx->pos));
793   return 0;
794 }
yy_NOT(yycontext * ctx)795 YY_RULE(int) yy_NOT(yycontext *ctx)
796 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
797   yyprintf((stderr, "%s\n", "NOT"));  if (!yymatchChar(ctx, '!')) goto l64;  if (!yy__(ctx)) goto l64;
798   yyprintf((stderr, "  ok   %s @ %s\n", "NOT", ctx->buf+ctx->pos));
799   return 1;
800   l64:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
801   yyprintf((stderr, "  fail %s @ %s\n", "NOT", ctx->buf+ctx->pos));
802   return 0;
803 }
yy_suffix(yycontext * ctx)804 YY_RULE(int) yy_suffix(yycontext *ctx)
805 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
806   yyprintf((stderr, "%s\n", "suffix"));  if (!yy_primary(ctx)) goto l65;
807   {  int yypos66= ctx->pos, yythunkpos66= ctx->thunkpos;
808   {  int yypos68= ctx->pos, yythunkpos68= ctx->thunkpos;  if (!yy_QUESTION(ctx)) goto l69;  yyDo(ctx, yy_1_suffix, ctx->begin, ctx->end);  goto l68;
809   l69:;	  ctx->pos= yypos68; ctx->thunkpos= yythunkpos68;  if (!yy_STAR(ctx)) goto l70;  yyDo(ctx, yy_2_suffix, ctx->begin, ctx->end);  goto l68;
810   l70:;	  ctx->pos= yypos68; ctx->thunkpos= yythunkpos68;  if (!yy_PLUS(ctx)) goto l66;  yyDo(ctx, yy_3_suffix, ctx->begin, ctx->end);
811   }
812   l68:;	  goto l67;
813   l66:;	  ctx->pos= yypos66; ctx->thunkpos= yythunkpos66;
814   }
815   l67:;
816   yyprintf((stderr, "  ok   %s @ %s\n", "suffix", ctx->buf+ctx->pos));
817   return 1;
818   l65:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
819   yyprintf((stderr, "  fail %s @ %s\n", "suffix", ctx->buf+ctx->pos));
820   return 0;
821 }
yy_action(yycontext * ctx)822 YY_RULE(int) yy_action(yycontext *ctx)
823 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
824   yyprintf((stderr, "%s\n", "action"));  if (!yymatchChar(ctx, '{')) goto l71;  yyText(ctx, ctx->begin, ctx->end);  if (!(YY_BEGIN)) goto l71;
825   l72:;
826   {  int yypos73= ctx->pos, yythunkpos73= ctx->thunkpos;  if (!yy_braces(ctx)) goto l73;  goto l72;
827   l73:;	  ctx->pos= yypos73; ctx->thunkpos= yythunkpos73;
828   }  yyText(ctx, ctx->begin, ctx->end);  if (!(YY_END)) goto l71;  if (!yymatchChar(ctx, '}')) goto l71;  if (!yy__(ctx)) goto l71;
829   yyprintf((stderr, "  ok   %s @ %s\n", "action", ctx->buf+ctx->pos));
830   return 1;
831   l71:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
832   yyprintf((stderr, "  fail %s @ %s\n", "action", ctx->buf+ctx->pos));
833   return 0;
834 }
yy_AND(yycontext * ctx)835 YY_RULE(int) yy_AND(yycontext *ctx)
836 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
837   yyprintf((stderr, "%s\n", "AND"));  if (!yymatchChar(ctx, '&')) goto l74;  if (!yy__(ctx)) goto l74;
838   yyprintf((stderr, "  ok   %s @ %s\n", "AND", ctx->buf+ctx->pos));
839   return 1;
840   l74:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
841   yyprintf((stderr, "  fail %s @ %s\n", "AND", ctx->buf+ctx->pos));
842   return 0;
843 }
yy_prefix(yycontext * ctx)844 YY_RULE(int) yy_prefix(yycontext *ctx)
845 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
846   yyprintf((stderr, "%s\n", "prefix"));
847   {  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;
848   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;
849   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;
850   l79:;	  ctx->pos= yypos76; ctx->thunkpos= yythunkpos76;  if (!yy_suffix(ctx)) goto l75;
851   }
852   l76:;
853   yyprintf((stderr, "  ok   %s @ %s\n", "prefix", ctx->buf+ctx->pos));
854   return 1;
855   l75:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
856   yyprintf((stderr, "  fail %s @ %s\n", "prefix", ctx->buf+ctx->pos));
857   return 0;
858 }
yy_BAR(yycontext * ctx)859 YY_RULE(int) yy_BAR(yycontext *ctx)
860 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
861   yyprintf((stderr, "%s\n", "BAR"));  if (!yymatchChar(ctx, '|')) goto l80;  if (!yy__(ctx)) goto l80;
862   yyprintf((stderr, "  ok   %s @ %s\n", "BAR", ctx->buf+ctx->pos));
863   return 1;
864   l80:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
865   yyprintf((stderr, "  fail %s @ %s\n", "BAR", ctx->buf+ctx->pos));
866   return 0;
867 }
yy_sequence(yycontext * ctx)868 YY_RULE(int) yy_sequence(yycontext *ctx)
869 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
870   yyprintf((stderr, "%s\n", "sequence"));  if (!yy_prefix(ctx)) goto l81;
871   l82:;
872   {  int yypos83= ctx->pos, yythunkpos83= ctx->thunkpos;  if (!yy_prefix(ctx)) goto l83;  yyDo(ctx, yy_1_sequence, ctx->begin, ctx->end);  goto l82;
873   l83:;	  ctx->pos= yypos83; ctx->thunkpos= yythunkpos83;
874   }
875   yyprintf((stderr, "  ok   %s @ %s\n", "sequence", ctx->buf+ctx->pos));
876   return 1;
877   l81:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
878   yyprintf((stderr, "  fail %s @ %s\n", "sequence", ctx->buf+ctx->pos));
879   return 0;
880 }
yy_SEMICOLON(yycontext * ctx)881 YY_RULE(int) yy_SEMICOLON(yycontext *ctx)
882 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
883   yyprintf((stderr, "%s\n", "SEMICOLON"));  if (!yymatchChar(ctx, ';')) goto l84;  if (!yy__(ctx)) goto l84;
884   yyprintf((stderr, "  ok   %s @ %s\n", "SEMICOLON", ctx->buf+ctx->pos));
885   return 1;
886   l84:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
887   yyprintf((stderr, "  fail %s @ %s\n", "SEMICOLON", ctx->buf+ctx->pos));
888   return 0;
889 }
yy_expression(yycontext * ctx)890 YY_RULE(int) yy_expression(yycontext *ctx)
891 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
892   yyprintf((stderr, "%s\n", "expression"));  if (!yy_sequence(ctx)) goto l85;
893   l86:;
894   {  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;
895   l87:;	  ctx->pos= yypos87; ctx->thunkpos= yythunkpos87;
896   }
897   yyprintf((stderr, "  ok   %s @ %s\n", "expression", ctx->buf+ctx->pos));
898   return 1;
899   l85:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
900   yyprintf((stderr, "  fail %s @ %s\n", "expression", ctx->buf+ctx->pos));
901   return 0;
902 }
yy_EQUAL(yycontext * ctx)903 YY_RULE(int) yy_EQUAL(yycontext *ctx)
904 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
905   yyprintf((stderr, "%s\n", "EQUAL"));  if (!yymatchChar(ctx, '=')) goto l88;  if (!yy__(ctx)) goto l88;
906   yyprintf((stderr, "  ok   %s @ %s\n", "EQUAL", ctx->buf+ctx->pos));
907   return 1;
908   l88:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
909   yyprintf((stderr, "  fail %s @ %s\n", "EQUAL", ctx->buf+ctx->pos));
910   return 0;
911 }
yy_identifier(yycontext * ctx)912 YY_RULE(int) yy_identifier(yycontext *ctx)
913 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
914   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;
915   l90:;
916   {  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;
917   l91:;	  ctx->pos= yypos91; ctx->thunkpos= yythunkpos91;
918   }  yyText(ctx, ctx->begin, ctx->end);  if (!(YY_END)) goto l89;  if (!yy__(ctx)) goto l89;
919   yyprintf((stderr, "  ok   %s @ %s\n", "identifier", ctx->buf+ctx->pos));
920   return 1;
921   l89:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
922   yyprintf((stderr, "  fail %s @ %s\n", "identifier", ctx->buf+ctx->pos));
923   return 0;
924 }
yy_RPERCENT(yycontext * ctx)925 YY_RULE(int) yy_RPERCENT(yycontext *ctx)
926 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
927   yyprintf((stderr, "%s\n", "RPERCENT"));  if (!yymatchString(ctx, "%}")) goto l92;  if (!yy__(ctx)) goto l92;
928   yyprintf((stderr, "  ok   %s @ %s\n", "RPERCENT", ctx->buf+ctx->pos));
929   return 1;
930   l92:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
931   yyprintf((stderr, "  fail %s @ %s\n", "RPERCENT", ctx->buf+ctx->pos));
932   return 0;
933 }
yy_end_of_file(yycontext * ctx)934 YY_RULE(int) yy_end_of_file(yycontext *ctx)
935 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
936   yyprintf((stderr, "%s\n", "end_of_file"));
937   {  int yypos94= ctx->pos, yythunkpos94= ctx->thunkpos;  if (!yymatchDot(ctx)) goto l94;  goto l93;
938   l94:;	  ctx->pos= yypos94; ctx->thunkpos= yythunkpos94;
939   }
940   yyprintf((stderr, "  ok   %s @ %s\n", "end_of_file", ctx->buf+ctx->pos));
941   return 1;
942   l93:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
943   yyprintf((stderr, "  fail %s @ %s\n", "end_of_file", ctx->buf+ctx->pos));
944   return 0;
945 }
yy_trailer(yycontext * ctx)946 YY_RULE(int) yy_trailer(yycontext *ctx)
947 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
948   yyprintf((stderr, "%s\n", "trailer"));  if (!yymatchString(ctx, "%%")) goto l95;  yyText(ctx, ctx->begin, ctx->end);  if (!(YY_BEGIN)) goto l95;
949   l96:;
950   {  int yypos97= ctx->pos, yythunkpos97= ctx->thunkpos;  if (!yymatchDot(ctx)) goto l97;  goto l96;
951   l97:;	  ctx->pos= yypos97; ctx->thunkpos= yythunkpos97;
952   }  yyText(ctx, ctx->begin, ctx->end);  if (!(YY_END)) goto l95;  yyDo(ctx, yy_1_trailer, ctx->begin, ctx->end);
953   yyprintf((stderr, "  ok   %s @ %s\n", "trailer", ctx->buf+ctx->pos));
954   return 1;
955   l95:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
956   yyprintf((stderr, "  fail %s @ %s\n", "trailer", ctx->buf+ctx->pos));
957   return 0;
958 }
yy_definition(yycontext * ctx)959 YY_RULE(int) yy_definition(yycontext *ctx)
960 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
961   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);
962   {  int yypos99= ctx->pos, yythunkpos99= ctx->thunkpos;  if (!yy_SEMICOLON(ctx)) goto l99;  goto l100;
963   l99:;	  ctx->pos= yypos99; ctx->thunkpos= yythunkpos99;
964   }
965   l100:;
966   yyprintf((stderr, "  ok   %s @ %s\n", "definition", ctx->buf+ctx->pos));
967   return 1;
968   l98:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
969   yyprintf((stderr, "  fail %s @ %s\n", "definition", ctx->buf+ctx->pos));
970   return 0;
971 }
yy_declaration(yycontext * ctx)972 YY_RULE(int) yy_declaration(yycontext *ctx)
973 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
974   yyprintf((stderr, "%s\n", "declaration"));  if (!yymatchString(ctx, "%{")) goto l101;  yyText(ctx, ctx->begin, ctx->end);  if (!(YY_BEGIN)) goto l101;
975   l102:;
976   {  int yypos103= ctx->pos, yythunkpos103= ctx->thunkpos;
977   {  int yypos104= ctx->pos, yythunkpos104= ctx->thunkpos;  if (!yymatchString(ctx, "%}")) goto l104;  goto l103;
978   l104:;	  ctx->pos= yypos104; ctx->thunkpos= yythunkpos104;
979   }  if (!yymatchDot(ctx)) goto l103;  goto l102;
980   l103:;	  ctx->pos= yypos103; ctx->thunkpos= yythunkpos103;
981   }  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);
982   yyprintf((stderr, "  ok   %s @ %s\n", "declaration", ctx->buf+ctx->pos));
983   return 1;
984   l101:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
985   yyprintf((stderr, "  fail %s @ %s\n", "declaration", ctx->buf+ctx->pos));
986   return 0;
987 }
yy__(yycontext * ctx)988 YY_RULE(int) yy__(yycontext *ctx)
989 {
990   yyprintf((stderr, "%s\n", "_"));
991   l106:;
992   {  int yypos107= ctx->pos, yythunkpos107= ctx->thunkpos;
993   {  int yypos108= ctx->pos, yythunkpos108= ctx->thunkpos;  if (!yy_space(ctx)) goto l109;  goto l108;
994   l109:;	  ctx->pos= yypos108; ctx->thunkpos= yythunkpos108;  if (!yy_comment(ctx)) goto l107;
995   }
996   l108:;	  goto l106;
997   l107:;	  ctx->pos= yypos107; ctx->thunkpos= yythunkpos107;
998   }
999   yyprintf((stderr, "  ok   %s @ %s\n", "_", ctx->buf+ctx->pos));
1000   return 1;
1001 }
yy_grammar(yycontext * ctx)1002 YY_RULE(int) yy_grammar(yycontext *ctx)
1003 {  int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
1004   yyprintf((stderr, "%s\n", "grammar"));  if (!yy__(ctx)) goto l110;
1005   {  int yypos113= ctx->pos, yythunkpos113= ctx->thunkpos;  if (!yy_declaration(ctx)) goto l114;  goto l113;
1006   l114:;	  ctx->pos= yypos113; ctx->thunkpos= yythunkpos113;  if (!yy_definition(ctx)) goto l110;
1007   }
1008   l113:;
1009   l111:;
1010   {  int yypos112= ctx->pos, yythunkpos112= ctx->thunkpos;
1011   {  int yypos115= ctx->pos, yythunkpos115= ctx->thunkpos;  if (!yy_declaration(ctx)) goto l116;  goto l115;
1012   l116:;	  ctx->pos= yypos115; ctx->thunkpos= yythunkpos115;  if (!yy_definition(ctx)) goto l112;
1013   }
1014   l115:;	  goto l111;
1015   l112:;	  ctx->pos= yypos112; ctx->thunkpos= yythunkpos112;
1016   }
1017   {  int yypos117= ctx->pos, yythunkpos117= ctx->thunkpos;  if (!yy_trailer(ctx)) goto l117;  goto l118;
1018   l117:;	  ctx->pos= yypos117; ctx->thunkpos= yythunkpos117;
1019   }
1020   l118:;	  if (!yy_end_of_file(ctx)) goto l110;
1021   yyprintf((stderr, "  ok   %s @ %s\n", "grammar", ctx->buf+ctx->pos));
1022   return 1;
1023   l110:;	  ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
1024   yyprintf((stderr, "  fail %s @ %s\n", "grammar", ctx->buf+ctx->pos));
1025   return 0;
1026 }
1027 
1028 #ifndef YY_PART
1029 
1030 typedef int (*yyrule)(yycontext *ctx);
1031 
YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart)1032 YY_PARSE(int) YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart)
1033 {
1034   int yyok;
1035   if (!yyctx->buflen)
1036     {
1037       yyctx->buflen= 1024;
1038       yyctx->buf= (char *)malloc(yyctx->buflen);
1039       yyctx->textlen= 1024;
1040       yyctx->text= (char *)malloc(yyctx->textlen);
1041       yyctx->thunkslen= 32;
1042       yyctx->thunks= (yythunk *)malloc(sizeof(yythunk) * yyctx->thunkslen);
1043       yyctx->valslen= 32;
1044       yyctx->vals= (YYSTYPE *)malloc(sizeof(YYSTYPE) * yyctx->valslen);
1045       yyctx->begin= yyctx->end= yyctx->pos= yyctx->limit= yyctx->thunkpos= 0;
1046     }
1047   yyctx->begin= yyctx->end= yyctx->pos;
1048   yyctx->thunkpos= 0;
1049   yyctx->val= yyctx->vals;
1050   yyok= yystart(yyctx);
1051   if (yyok) yyDone(yyctx);
1052   yyCommit(yyctx);
1053   return yyok;
1054 }
1055 
YYPARSE(YY_CTX_PARAM)1056 YY_PARSE(int) YYPARSE(YY_CTX_PARAM)
1057 {
1058   return YYPARSEFROM(YY_CTX_ARG_ yy_grammar);
1059 }
1060 
1061 #endif
1062 
1063 
yyerror(char * message)1064 void yyerror(char *message)
1065 {
1066   fprintf(stderr, "%s:%d: %s", fileName, lineNumber, message);
1067   if (yyctx->text[0]) fprintf(stderr, " near token '%s'", yyctx->text);
1068   if (yyctx->pos < yyctx->limit || !feof(input))
1069     {
1070       yyctx->buf[yyctx->limit]= '\0';
1071       fprintf(stderr, " before text \"");
1072       while (yyctx->pos < yyctx->limit)
1073 	{
1074 	  if ('\n' == yyctx->buf[yyctx->pos] || '\r' == yyctx->buf[yyctx->pos]) break;
1075 	  fputc(yyctx->buf[yyctx->pos++], stderr);
1076 	}
1077       if (yyctx->pos == yyctx->limit)
1078 	{
1079 	  int c;
1080 	  while (EOF != (c= fgetc(input)) && '\n' != c && '\r' != c)
1081 	    fputc(c, stderr);
1082 	}
1083       fputc('\"', stderr);
1084     }
1085   fprintf(stderr, "\n");
1086   exit(1);
1087 }
1088 
makeHeader(char * text)1089 void makeHeader(char *text)
1090 {
1091   Header *header= (Header *)malloc(sizeof(Header));
1092   header->text= strdup(text);
1093   header->next= headers;
1094   headers= header;
1095 }
1096 
makeTrailer(char * text)1097 void makeTrailer(char *text)
1098 {
1099   trailer= strdup(text);
1100 }
1101 
version(char * name)1102 static void version(char *name)
1103 {
1104   printf("%s version %d.%d.%d\n", name, PEG_MAJOR, PEG_MINOR, PEG_LEVEL);
1105 }
1106 
usage(char * name)1107 static void usage(char *name)
1108 {
1109   version(name);
1110   fprintf(stderr, "usage: %s [<option>...] [<file>...]\n", name);
1111   fprintf(stderr, "where <option> can be\n");
1112   fprintf(stderr, "  -h          print this help information\n");
1113   fprintf(stderr, "  -o <ofile>  write output to <ofile>\n");
1114   fprintf(stderr, "  -v          be verbose\n");
1115   fprintf(stderr, "  -V          print version number and exit\n");
1116   fprintf(stderr, "if no <file> is given, input is read from stdin\n");
1117   fprintf(stderr, "if no <ofile> is given, output is written to stdout\n");
1118   exit(1);
1119 }
1120 
main(int argc,char ** argv)1121 int main(int argc, char **argv)
1122 {
1123   Node *n;
1124   int   c;
1125 
1126   output= stdout;
1127   input= stdin;
1128   lineNumber= 1;
1129   fileName= "<stdin>";
1130 
1131   while (-1 != (c= getopt(argc, argv, "Vho:v")))
1132     {
1133       switch (c)
1134 	{
1135 	case 'V':
1136 	  version(basename(argv[0]));
1137 	  exit(0);
1138 
1139 	case 'h':
1140 	  usage(basename(argv[0]));
1141 	  break;
1142 
1143 	case 'o':
1144 	  if (!(output= fopen(optarg, "w")))
1145 	    {
1146 	      perror(optarg);
1147 	      exit(1);
1148 	    }
1149 	  break;
1150 
1151 	case 'v':
1152 	  verboseFlag= 1;
1153 	  break;
1154 
1155 	default:
1156 	  fprintf(stderr, "for usage try: %s -h\n", argv[0]);
1157 	  exit(1);
1158 	}
1159     }
1160   argc -= optind;
1161   argv += optind;
1162 
1163   if (argc)
1164     {
1165       for (;  argc;  --argc, ++argv)
1166 	{
1167 	  if (!strcmp(*argv, "-"))
1168 	    {
1169 	      input= stdin;
1170 	      fileName= "<stdin>";
1171 	    }
1172 	  else
1173 	    {
1174 	      if (!(input= fopen(*argv, "r")))
1175 		{
1176 		  perror(*argv);
1177 		  exit(1);
1178 		}
1179 	      fileName= *argv;
1180 	    }
1181 	  lineNumber= 1;
1182 	  if (!yyparse())
1183 	    yyerror("syntax error");
1184 	  if (input != stdin)
1185 	    fclose(input);
1186 	}
1187     }
1188   else
1189     if (!yyparse())
1190       yyerror("syntax error");
1191 
1192   if (verboseFlag)
1193     for (n= rules;  n;  n= n->any.next)
1194       Rule_print(n);
1195 
1196   Rule_compile_c_header();
1197 
1198   for (; headers;  headers= headers->next)
1199     fprintf(output, "%s\n", headers->text);
1200 
1201   if (rules)
1202     Rule_compile_c(rules);
1203 
1204   if (trailer)
1205     fprintf(output, "%s\n", trailer);
1206 
1207   return 0;
1208 }
1209 
1210