/vendor/peg/leg.c

http://github.com/feyeleanor/RubyGoLightly · C · 1083 lines · 1024 code · 58 blank · 1 comment · 212 complexity · a0ee8b59d7f7d24a4bfcc2fe68929607 MD5 · raw file

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