leg.c.bak 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  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 35
  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) { if (text) { } yyval += count; }
  225. YY_LOCAL(void) yyPop(char *text, int count) { if (text) { } yyval -= count; }
  226. YY_LOCAL(void) yySet(char *text, int count) { if (text) { } yyval[count]= yy; }
  227. #endif /* YY_PART */
  228. #define YYACCEPT yyAccept(yythunkpos0)
  229. YY_RULE(int) yy_end_of_line(); /* 35 */
  230. YY_RULE(int) yy_comment(); /* 34 */
  231. YY_RULE(int) yy_space(); /* 33 */
  232. YY_RULE(int) yy_range(); /* 32 */
  233. YY_RULE(int) yy_char(); /* 31 */
  234. YY_RULE(int) yy_END(); /* 30 */
  235. YY_RULE(int) yy_BEGIN(); /* 29 */
  236. YY_RULE(int) yy_DOT(); /* 28 */
  237. YY_RULE(int) yy_class(); /* 27 */
  238. YY_RULE(int) yy_literal(); /* 26 */
  239. YY_RULE(int) yy_CLOSE(); /* 25 */
  240. YY_RULE(int) yy_OPEN(); /* 24 */
  241. YY_RULE(int) yy_COLON(); /* 23 */
  242. YY_RULE(int) yy_PLUS(); /* 22 */
  243. YY_RULE(int) yy_STAR(); /* 21 */
  244. YY_RULE(int) yy_QUESTION(); /* 20 */
  245. YY_RULE(int) yy_primary(); /* 19 */
  246. YY_RULE(int) yy_NOT(); /* 18 */
  247. YY_RULE(int) yy_suffix(); /* 17 */
  248. YY_RULE(int) yy_action(); /* 16 */
  249. YY_RULE(int) yy_AND(); /* 15 */
  250. YY_RULE(int) yy_prefix(); /* 14 */
  251. YY_RULE(int) yy_BAR(); /* 13 */
  252. YY_RULE(int) yy_sequence(); /* 12 */
  253. YY_RULE(int) yy_SEMICOLON(); /* 11 */
  254. YY_RULE(int) yy_expression(); /* 10 */
  255. YY_RULE(int) yy_EQUAL(); /* 9 */
  256. YY_RULE(int) yy_identifier(); /* 8 */
  257. YY_RULE(int) yy_RPERCENT(); /* 7 */
  258. YY_RULE(int) yy_end_of_file(); /* 6 */
  259. YY_RULE(int) yy_trailer(); /* 5 */
  260. YY_RULE(int) yy_definition(); /* 4 */
  261. YY_RULE(int) yy_declaration(); /* 3 */
  262. YY_RULE(int) yy__(); /* 2 */
  263. YY_RULE(int) yy_grammar(); /* 1 */
  264. YY_ACTION(void) yy_9_primary(char *yytext, int yyleng)
  265. { if(yytext) { } if (yyleng) { }
  266. yyprintf((stderr, "do yy_9_primary\n"));
  267. push(makePredicate("YY_END")); ;
  268. }
  269. YY_ACTION(void) yy_8_primary(char *yytext, int yyleng)
  270. { if(yytext) { } if (yyleng) { }
  271. yyprintf((stderr, "do yy_8_primary\n"));
  272. push(makePredicate("YY_BEGIN")); ;
  273. }
  274. YY_ACTION(void) yy_7_primary(char *yytext, int yyleng)
  275. { if(yytext) { } if (yyleng) { }
  276. yyprintf((stderr, "do yy_7_primary\n"));
  277. push(makeAction(yytext)); ;
  278. }
  279. YY_ACTION(void) yy_6_primary(char *yytext, int yyleng)
  280. { if(yytext) { } if (yyleng) { }
  281. yyprintf((stderr, "do yy_6_primary\n"));
  282. push(makeDot()); ;
  283. }
  284. YY_ACTION(void) yy_5_primary(char *yytext, int yyleng)
  285. { if(yytext) { } if (yyleng) { }
  286. yyprintf((stderr, "do yy_5_primary\n"));
  287. push(makeClass(yytext)); ;
  288. }
  289. YY_ACTION(void) yy_4_primary(char *yytext, int yyleng)
  290. { if(yytext) { } if (yyleng) { }
  291. yyprintf((stderr, "do yy_4_primary\n"));
  292. push(makeString(yytext)); ;
  293. }
  294. YY_ACTION(void) yy_3_primary(char *yytext, int yyleng)
  295. { if(yytext) { } if (yyleng) { }
  296. yyprintf((stderr, "do yy_3_primary\n"));
  297. push(makeName(findRule(yytext))); ;
  298. }
  299. YY_ACTION(void) yy_2_primary(char *yytext, int yyleng)
  300. { if(yytext) { } if (yyleng) { }
  301. yyprintf((stderr, "do yy_2_primary\n"));
  302. Node *name= makeName(findRule(yytext)); name->name.variable= pop(); push(name); ;
  303. }
  304. YY_ACTION(void) yy_1_primary(char *yytext, int yyleng)
  305. { if(yytext) { } if (yyleng) { }
  306. yyprintf((stderr, "do yy_1_primary\n"));
  307. push(makeVariable(yytext)); ;
  308. }
  309. YY_ACTION(void) yy_3_suffix(char *yytext, int yyleng)
  310. { if(yytext) { } if (yyleng) { }
  311. yyprintf((stderr, "do yy_3_suffix\n"));
  312. push(makePlus (pop())); ;
  313. }
  314. YY_ACTION(void) yy_2_suffix(char *yytext, int yyleng)
  315. { if(yytext) { } if (yyleng) { }
  316. yyprintf((stderr, "do yy_2_suffix\n"));
  317. push(makeStar (pop())); ;
  318. }
  319. YY_ACTION(void) yy_1_suffix(char *yytext, int yyleng)
  320. { if(yytext) { } if (yyleng) { }
  321. yyprintf((stderr, "do yy_1_suffix\n"));
  322. push(makeQuery(pop())); ;
  323. }
  324. YY_ACTION(void) yy_3_prefix(char *yytext, int yyleng)
  325. { if(yytext) { } if (yyleng) { }
  326. yyprintf((stderr, "do yy_3_prefix\n"));
  327. push(makePeekNot(pop())); ;
  328. }
  329. YY_ACTION(void) yy_2_prefix(char *yytext, int yyleng)
  330. { if(yytext) { } if (yyleng) { }
  331. yyprintf((stderr, "do yy_2_prefix\n"));
  332. push(makePeekFor(pop())); ;
  333. }
  334. YY_ACTION(void) yy_1_prefix(char *yytext, int yyleng)
  335. { if(yytext) { } if (yyleng) { }
  336. yyprintf((stderr, "do yy_1_prefix\n"));
  337. push(makePredicate(yytext)); ;
  338. }
  339. YY_ACTION(void) yy_1_sequence(char *yytext, int yyleng)
  340. { if(yytext) { } if (yyleng) { }
  341. yyprintf((stderr, "do yy_1_sequence\n"));
  342. Node *f= pop(); push(Sequence_append(pop(), f)); ;
  343. }
  344. YY_ACTION(void) yy_1_expression(char *yytext, int yyleng)
  345. { if(yytext) { } if (yyleng) { }
  346. yyprintf((stderr, "do yy_1_expression\n"));
  347. Node *f= pop(); push(Alternate_append(pop(), f)); ;
  348. }
  349. YY_ACTION(void) yy_2_definition(char *yytext, int yyleng)
  350. { if(yytext) { } if (yyleng) { }
  351. yyprintf((stderr, "do yy_2_definition\n"));
  352. Node *e= pop(); Rule_setExpression(pop(), e); ;
  353. }
  354. YY_ACTION(void) yy_1_definition(char *yytext, int yyleng)
  355. { if(yytext) { } if (yyleng) { }
  356. yyprintf((stderr, "do yy_1_definition\n"));
  357. if (push(beginRule(findRule(yytext)))->rule.expression)
  358. fprintf(stderr, "rule '%s' redefined\n", yytext); ;
  359. }
  360. YY_ACTION(void) yy_1_trailer(char *yytext, int yyleng)
  361. { if(yytext) { } if (yyleng) { }
  362. yyprintf((stderr, "do yy_1_trailer\n"));
  363. makeTrailer(yytext); ;
  364. }
  365. YY_ACTION(void) yy_1_declaration(char *yytext, int yyleng)
  366. { if(yytext) { } if (yyleng) { }
  367. yyprintf((stderr, "do yy_1_declaration\n"));
  368. makeHeader(yytext); ;
  369. }
  370. YY_RULE(int) yy_end_of_line()
  371. { int yypos0= yypos, yythunkpos0= yythunkpos;
  372. yyprintf((stderr, "%s\n", "end_of_line"));
  373. { int yypos2= yypos, yythunkpos2= yythunkpos; if (!yymatchString("\r\n")) goto l3; goto l2;
  374. l3:; yypos= yypos2; yythunkpos= yythunkpos2; if (!yymatchChar('\n')) goto l4; goto l2;
  375. l4:; yypos= yypos2; yythunkpos= yythunkpos2; if (!yymatchChar('\r')) goto l1;
  376. }
  377. l2:;
  378. yyprintf((stderr, " ok %s @ %s\n", "end_of_line", yybuf+yypos));
  379. return 1;
  380. l1:; yypos= yypos0; yythunkpos= yythunkpos0;
  381. yyprintf((stderr, " fail %s @ %s\n", "end_of_line", yybuf+yypos));
  382. return 0;
  383. }
  384. YY_RULE(int) yy_comment()
  385. { int yypos0= yypos, yythunkpos0= yythunkpos;
  386. yyprintf((stderr, "%s\n", "comment")); if (!yymatchChar('#')) goto l5;
  387. l6:;
  388. { int yypos7= yypos, yythunkpos7= yythunkpos;
  389. { int yypos8= yypos, yythunkpos8= yythunkpos; if (!yy_end_of_line()) goto l8; goto l7;
  390. l8:; yypos= yypos8; yythunkpos= yythunkpos8;
  391. } if (!yymatchDot()) goto l7; goto l6;
  392. l7:; yypos= yypos7; yythunkpos= yythunkpos7;
  393. } if (!yy_end_of_line()) goto l5;
  394. yyprintf((stderr, " ok %s @ %s\n", "comment", yybuf+yypos));
  395. return 1;
  396. l5:; yypos= yypos0; yythunkpos= yythunkpos0;
  397. yyprintf((stderr, " fail %s @ %s\n", "comment", yybuf+yypos));
  398. return 0;
  399. }
  400. YY_RULE(int) yy_space()
  401. { int yypos0= yypos, yythunkpos0= yythunkpos;
  402. yyprintf((stderr, "%s\n", "space"));
  403. { int yypos10= yypos, yythunkpos10= yythunkpos; if (!yymatchChar(' ')) goto l11; goto l10;
  404. l11:; yypos= yypos10; yythunkpos= yythunkpos10; if (!yymatchChar('\t')) goto l12; goto l10;
  405. l12:; yypos= yypos10; yythunkpos= yythunkpos10; if (!yy_end_of_line()) goto l9;
  406. }
  407. l10:;
  408. yyprintf((stderr, " ok %s @ %s\n", "space", yybuf+yypos));
  409. return 1;
  410. l9:; yypos= yypos0; yythunkpos= yythunkpos0;
  411. yyprintf((stderr, " fail %s @ %s\n", "space", yybuf+yypos));
  412. return 0;
  413. }
  414. YY_RULE(int) yy_range()
  415. { int yypos0= yypos, yythunkpos0= yythunkpos;
  416. yyprintf((stderr, "%s\n", "range"));
  417. { int yypos14= yypos, yythunkpos14= yythunkpos; if (!yy_char()) goto l15; if (!yymatchChar('-')) goto l15; if (!yy_char()) goto l15; goto l14;
  418. l15:; yypos= yypos14; yythunkpos= yythunkpos14; if (!yy_char()) goto l13;
  419. }
  420. l14:;
  421. yyprintf((stderr, " ok %s @ %s\n", "range", yybuf+yypos));
  422. return 1;
  423. l13:; yypos= yypos0; yythunkpos= yythunkpos0;
  424. yyprintf((stderr, " fail %s @ %s\n", "range", yybuf+yypos));
  425. return 0;
  426. }
  427. YY_RULE(int) yy_char()
  428. { int yypos0= yypos, yythunkpos0= yythunkpos;
  429. yyprintf((stderr, "%s\n", "char"));
  430. { int yypos17= yypos, yythunkpos17= yythunkpos; if (!yymatchChar('\\')) goto l18; if (!yymatchClass((unsigned char *)"\000\000\000\000\204\000\000\000\000\000\000\070\146\100\124\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l18; goto l17;
  431. l18:; yypos= yypos17; yythunkpos= yythunkpos17; if (!yymatchChar('\\')) goto l19; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\017\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l19; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l19; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l19; goto l17;
  432. l19:; yypos= yypos17; yythunkpos= yythunkpos17; if (!yymatchChar('\\')) goto l20; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l20;
  433. { int yypos21= yypos, yythunkpos21= yythunkpos; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l21; goto l22;
  434. l21:; yypos= yypos21; yythunkpos= yythunkpos21;
  435. }
  436. l22:; goto l17;
  437. l20:; yypos= yypos17; yythunkpos= yythunkpos17;
  438. { int yypos23= yypos, yythunkpos23= yythunkpos; if (!yymatchChar('\\')) goto l23; goto l16;
  439. l23:; yypos= yypos23; yythunkpos= yythunkpos23;
  440. } if (!yymatchDot()) goto l16;
  441. }
  442. l17:;
  443. yyprintf((stderr, " ok %s @ %s\n", "char", yybuf+yypos));
  444. return 1;
  445. l16:; yypos= yypos0; yythunkpos= yythunkpos0;
  446. yyprintf((stderr, " fail %s @ %s\n", "char", yybuf+yypos));
  447. return 0;
  448. }
  449. YY_RULE(int) yy_END()
  450. { int yypos0= yypos, yythunkpos0= yythunkpos;
  451. yyprintf((stderr, "%s\n", "END")); if (!yymatchChar('>')) goto l24; if (!yy__()) goto l24;
  452. yyprintf((stderr, " ok %s @ %s\n", "END", yybuf+yypos));
  453. return 1;
  454. l24:; yypos= yypos0; yythunkpos= yythunkpos0;
  455. yyprintf((stderr, " fail %s @ %s\n", "END", yybuf+yypos));
  456. return 0;
  457. }
  458. YY_RULE(int) yy_BEGIN()
  459. { int yypos0= yypos, yythunkpos0= yythunkpos;
  460. yyprintf((stderr, "%s\n", "BEGIN")); if (!yymatchChar('<')) goto l25; if (!yy__()) goto l25;
  461. yyprintf((stderr, " ok %s @ %s\n", "BEGIN", yybuf+yypos));
  462. return 1;
  463. l25:; yypos= yypos0; yythunkpos= yythunkpos0;
  464. yyprintf((stderr, " fail %s @ %s\n", "BEGIN", yybuf+yypos));
  465. return 0;
  466. }
  467. YY_RULE(int) yy_DOT()
  468. { int yypos0= yypos, yythunkpos0= yythunkpos;
  469. yyprintf((stderr, "%s\n", "DOT")); if (!yymatchChar('.')) goto l26; if (!yy__()) goto l26;
  470. yyprintf((stderr, " ok %s @ %s\n", "DOT", yybuf+yypos));
  471. return 1;
  472. l26:; yypos= yypos0; yythunkpos= yythunkpos0;
  473. yyprintf((stderr, " fail %s @ %s\n", "DOT", yybuf+yypos));
  474. return 0;
  475. }
  476. YY_RULE(int) yy_class()
  477. { int yypos0= yypos, yythunkpos0= yythunkpos;
  478. yyprintf((stderr, "%s\n", "class")); if (!yymatchChar('[')) goto l27; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l27;
  479. l28:;
  480. { int yypos29= yypos, yythunkpos29= yythunkpos;
  481. { int yypos30= yypos, yythunkpos30= yythunkpos; if (!yymatchChar(']')) goto l30; goto l29;
  482. l30:; yypos= yypos30; yythunkpos= yythunkpos30;
  483. } if (!yy_range()) goto l29; goto l28;
  484. l29:; yypos= yypos29; yythunkpos= yythunkpos29;
  485. } yyText(yybegin, yyend); if (!(YY_END)) goto l27; if (!yymatchChar(']')) goto l27; if (!yy__()) goto l27;
  486. yyprintf((stderr, " ok %s @ %s\n", "class", yybuf+yypos));
  487. return 1;
  488. l27:; yypos= yypos0; yythunkpos= yythunkpos0;
  489. yyprintf((stderr, " fail %s @ %s\n", "class", yybuf+yypos));
  490. return 0;
  491. }
  492. YY_RULE(int) yy_literal()
  493. { int yypos0= yypos, yythunkpos0= yythunkpos;
  494. yyprintf((stderr, "%s\n", "literal"));
  495. { int yypos32= yypos, yythunkpos32= 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 l33; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l33;
  496. l34:;
  497. { int yypos35= yypos, yythunkpos35= yythunkpos;
  498. { int yypos36= yypos, yythunkpos36= 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 l36; goto l35;
  499. l36:; yypos= yypos36; yythunkpos= yythunkpos36;
  500. } if (!yy_char()) goto l35; goto l34;
  501. l35:; yypos= yypos35; yythunkpos= yythunkpos35;
  502. } yyText(yybegin, yyend); if (!(YY_END)) goto l33; 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 l33; if (!yy__()) goto l33; goto l32;
  503. l33:; yypos= yypos32; yythunkpos= yythunkpos32; 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 l31; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l31;
  504. l37:;
  505. { int yypos38= yypos, yythunkpos38= yythunkpos;
  506. { int yypos39= yypos, yythunkpos39= 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 l39; goto l38;
  507. l39:; yypos= yypos39; yythunkpos= yythunkpos39;
  508. } if (!yy_char()) goto l38; goto l37;
  509. l38:; yypos= yypos38; yythunkpos= yythunkpos38;
  510. } yyText(yybegin, yyend); if (!(YY_END)) goto l31; 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 l31; if (!yy__()) goto l31;
  511. }
  512. l32:;
  513. yyprintf((stderr, " ok %s @ %s\n", "literal", yybuf+yypos));
  514. return 1;
  515. l31:; yypos= yypos0; yythunkpos= yythunkpos0;
  516. yyprintf((stderr, " fail %s @ %s\n", "literal", yybuf+yypos));
  517. return 0;
  518. }
  519. YY_RULE(int) yy_CLOSE()
  520. { int yypos0= yypos, yythunkpos0= yythunkpos;
  521. yyprintf((stderr, "%s\n", "CLOSE")); if (!yymatchChar(')')) goto l40; if (!yy__()) goto l40;
  522. yyprintf((stderr, " ok %s @ %s\n", "CLOSE", yybuf+yypos));
  523. return 1;
  524. l40:; yypos= yypos0; yythunkpos= yythunkpos0;
  525. yyprintf((stderr, " fail %s @ %s\n", "CLOSE", yybuf+yypos));
  526. return 0;
  527. }
  528. YY_RULE(int) yy_OPEN()
  529. { int yypos0= yypos, yythunkpos0= yythunkpos;
  530. yyprintf((stderr, "%s\n", "OPEN")); if (!yymatchChar('(')) goto l41; if (!yy__()) goto l41;
  531. yyprintf((stderr, " ok %s @ %s\n", "OPEN", yybuf+yypos));
  532. return 1;
  533. l41:; yypos= yypos0; yythunkpos= yythunkpos0;
  534. yyprintf((stderr, " fail %s @ %s\n", "OPEN", yybuf+yypos));
  535. return 0;
  536. }
  537. YY_RULE(int) yy_COLON()
  538. { int yypos0= yypos, yythunkpos0= yythunkpos;
  539. yyprintf((stderr, "%s\n", "COLON")); if (!yymatchChar(':')) goto l42; if (!yy__()) goto l42;
  540. yyprintf((stderr, " ok %s @ %s\n", "COLON", yybuf+yypos));
  541. return 1;
  542. l42:; yypos= yypos0; yythunkpos= yythunkpos0;
  543. yyprintf((stderr, " fail %s @ %s\n", "COLON", yybuf+yypos));
  544. return 0;
  545. }
  546. YY_RULE(int) yy_PLUS()
  547. { int yypos0= yypos, yythunkpos0= yythunkpos;
  548. yyprintf((stderr, "%s\n", "PLUS")); if (!yymatchChar('+')) goto l43; if (!yy__()) goto l43;
  549. yyprintf((stderr, " ok %s @ %s\n", "PLUS", yybuf+yypos));
  550. return 1;
  551. l43:; yypos= yypos0; yythunkpos= yythunkpos0;
  552. yyprintf((stderr, " fail %s @ %s\n", "PLUS", yybuf+yypos));
  553. return 0;
  554. }
  555. YY_RULE(int) yy_STAR()
  556. { int yypos0= yypos, yythunkpos0= yythunkpos;
  557. yyprintf((stderr, "%s\n", "STAR")); if (!yymatchChar('*')) goto l44; if (!yy__()) goto l44;
  558. yyprintf((stderr, " ok %s @ %s\n", "STAR", yybuf+yypos));
  559. return 1;
  560. l44:; yypos= yypos0; yythunkpos= yythunkpos0;
  561. yyprintf((stderr, " fail %s @ %s\n", "STAR", yybuf+yypos));
  562. return 0;
  563. }
  564. YY_RULE(int) yy_QUESTION()
  565. { int yypos0= yypos, yythunkpos0= yythunkpos;
  566. yyprintf((stderr, "%s\n", "QUESTION")); if (!yymatchChar('?')) goto l45; if (!yy__()) goto l45;
  567. yyprintf((stderr, " ok %s @ %s\n", "QUESTION", yybuf+yypos));
  568. return 1;
  569. l45:; yypos= yypos0; yythunkpos= yythunkpos0;
  570. yyprintf((stderr, " fail %s @ %s\n", "QUESTION", yybuf+yypos));
  571. return 0;
  572. }
  573. YY_RULE(int) yy_primary()
  574. { int yypos0= yypos, yythunkpos0= yythunkpos;
  575. yyprintf((stderr, "%s\n", "primary"));
  576. { int yypos47= yypos, yythunkpos47= yythunkpos; if (!yy_identifier()) goto l48; yyDo(yy_1_primary, yybegin, yyend); if (!yy_COLON()) goto l48; if (!yy_identifier()) goto l48;
  577. { int yypos49= yypos, yythunkpos49= yythunkpos; if (!yy_EQUAL()) goto l49; goto l48;
  578. l49:; yypos= yypos49; yythunkpos= yythunkpos49;
  579. } yyDo(yy_2_primary, yybegin, yyend); goto l47;
  580. l48:; yypos= yypos47; yythunkpos= yythunkpos47; if (!yy_identifier()) goto l50;
  581. { int yypos51= yypos, yythunkpos51= yythunkpos; if (!yy_EQUAL()) goto l51; goto l50;
  582. l51:; yypos= yypos51; yythunkpos= yythunkpos51;
  583. } yyDo(yy_3_primary, yybegin, yyend); goto l47;
  584. l50:; yypos= yypos47; yythunkpos= yythunkpos47; if (!yy_OPEN()) goto l52; if (!yy_expression()) goto l52; if (!yy_CLOSE()) goto l52; goto l47;
  585. l52:; yypos= yypos47; yythunkpos= yythunkpos47; if (!yy_literal()) goto l53; yyDo(yy_4_primary, yybegin, yyend); goto l47;
  586. l53:; yypos= yypos47; yythunkpos= yythunkpos47; if (!yy_class()) goto l54; yyDo(yy_5_primary, yybegin, yyend); goto l47;
  587. l54:; yypos= yypos47; yythunkpos= yythunkpos47; if (!yy_DOT()) goto l55; yyDo(yy_6_primary, yybegin, yyend); goto l47;
  588. l55:; yypos= yypos47; yythunkpos= yythunkpos47; if (!yy_action()) goto l56; yyDo(yy_7_primary, yybegin, yyend); goto l47;
  589. l56:; yypos= yypos47; yythunkpos= yythunkpos47; if (!yy_BEGIN()) goto l57; yyDo(yy_8_primary, yybegin, yyend); goto l47;
  590. l57:; yypos= yypos47; yythunkpos= yythunkpos47; if (!yy_END()) goto l46; yyDo(yy_9_primary, yybegin, yyend);
  591. }
  592. l47:;
  593. yyprintf((stderr, " ok %s @ %s\n", "primary", yybuf+yypos));
  594. return 1;
  595. l46:; yypos= yypos0; yythunkpos= yythunkpos0;
  596. yyprintf((stderr, " fail %s @ %s\n", "primary", yybuf+yypos));
  597. return 0;
  598. }
  599. YY_RULE(int) yy_NOT()
  600. { int yypos0= yypos, yythunkpos0= yythunkpos;
  601. yyprintf((stderr, "%s\n", "NOT")); if (!yymatchChar('!')) goto l58; if (!yy__()) goto l58;
  602. yyprintf((stderr, " ok %s @ %s\n", "NOT", yybuf+yypos));
  603. return 1;
  604. l58:; yypos= yypos0; yythunkpos= yythunkpos0;
  605. yyprintf((stderr, " fail %s @ %s\n", "NOT", yybuf+yypos));
  606. return 0;
  607. }
  608. YY_RULE(int) yy_suffix()
  609. { int yypos0= yypos, yythunkpos0= yythunkpos;
  610. yyprintf((stderr, "%s\n", "suffix")); if (!yy_primary()) goto l59;
  611. { int yypos60= yypos, yythunkpos60= yythunkpos;
  612. { int yypos62= yypos, yythunkpos62= yythunkpos; if (!yy_QUESTION()) goto l63; yyDo(yy_1_suffix, yybegin, yyend); goto l62;
  613. l63:; yypos= yypos62; yythunkpos= yythunkpos62; if (!yy_STAR()) goto l64; yyDo(yy_2_suffix, yybegin, yyend); goto l62;
  614. l64:; yypos= yypos62; yythunkpos= yythunkpos62; if (!yy_PLUS()) goto l60; yyDo(yy_3_suffix, yybegin, yyend);
  615. }
  616. l62:; goto l61;
  617. l60:; yypos= yypos60; yythunkpos= yythunkpos60;
  618. }
  619. l61:;
  620. yyprintf((stderr, " ok %s @ %s\n", "suffix", yybuf+yypos));
  621. return 1;
  622. l59:; yypos= yypos0; yythunkpos= yythunkpos0;
  623. yyprintf((stderr, " fail %s @ %s\n", "suffix", yybuf+yypos));
  624. return 0;
  625. }
  626. YY_RULE(int) yy_action()
  627. { int yypos0= yypos, yythunkpos0= yythunkpos;
  628. yyprintf((stderr, "%s\n", "action")); if (!yymatchChar('{')) goto l65; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l65;
  629. l66:;
  630. { int yypos67= yypos, yythunkpos67= yythunkpos; if (!yymatchClass((unsigned char *)"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\337\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377")) goto l67; goto l66;
  631. l67:; yypos= yypos67; yythunkpos= yythunkpos67;
  632. } yyText(yybegin, yyend); if (!(YY_END)) goto l65; if (!yymatchChar('}')) goto l65; if (!yy__()) goto l65;
  633. yyprintf((stderr, " ok %s @ %s\n", "action", yybuf+yypos));
  634. return 1;
  635. l65:; yypos= yypos0; yythunkpos= yythunkpos0;
  636. yyprintf((stderr, " fail %s @ %s\n", "action", yybuf+yypos));
  637. return 0;
  638. }
  639. YY_RULE(int) yy_AND()
  640. { int yypos0= yypos, yythunkpos0= yythunkpos;
  641. yyprintf((stderr, "%s\n", "AND")); if (!yymatchChar('&')) goto l68; if (!yy__()) goto l68;
  642. yyprintf((stderr, " ok %s @ %s\n", "AND", yybuf+yypos));
  643. return 1;
  644. l68:; yypos= yypos0; yythunkpos= yythunkpos0;
  645. yyprintf((stderr, " fail %s @ %s\n", "AND", yybuf+yypos));
  646. return 0;
  647. }
  648. YY_RULE(int) yy_prefix()
  649. { int yypos0= yypos, yythunkpos0= yythunkpos;
  650. yyprintf((stderr, "%s\n", "prefix"));
  651. { int yypos70= yypos, yythunkpos70= yythunkpos; if (!yy_AND()) goto l71; if (!yy_action()) goto l71; yyDo(yy_1_prefix, yybegin, yyend); goto l70;
  652. l71:; yypos= yypos70; yythunkpos= yythunkpos70; if (!yy_AND()) goto l72; if (!yy_suffix()) goto l72; yyDo(yy_2_prefix, yybegin, yyend); goto l70;
  653. l72:; yypos= yypos70; yythunkpos= yythunkpos70; if (!yy_NOT()) goto l73; if (!yy_suffix()) goto l73; yyDo(yy_3_prefix, yybegin, yyend); goto l70;
  654. l73:; yypos= yypos70; yythunkpos= yythunkpos70; if (!yy_suffix()) goto l69;
  655. }
  656. l70:;
  657. yyprintf((stderr, " ok %s @ %s\n", "prefix", yybuf+yypos));
  658. return 1;
  659. l69:; yypos= yypos0; yythunkpos= yythunkpos0;
  660. yyprintf((stderr, " fail %s @ %s\n", "prefix", yybuf+yypos));
  661. return 0;
  662. }
  663. YY_RULE(int) yy_BAR()
  664. { int yypos0= yypos, yythunkpos0= yythunkpos;
  665. yyprintf((stderr, "%s\n", "BAR")); if (!yymatchChar('|')) goto l74; if (!yy__()) goto l74;
  666. yyprintf((stderr, " ok %s @ %s\n", "BAR", yybuf+yypos));
  667. return 1;
  668. l74:; yypos= yypos0; yythunkpos= yythunkpos0;
  669. yyprintf((stderr, " fail %s @ %s\n", "BAR", yybuf+yypos));
  670. return 0;
  671. }
  672. YY_RULE(int) yy_sequence()
  673. { int yypos0= yypos, yythunkpos0= yythunkpos;
  674. yyprintf((stderr, "%s\n", "sequence")); if (!yy_prefix()) goto l75;
  675. l76:;
  676. { int yypos77= yypos, yythunkpos77= yythunkpos; if (!yy_prefix()) goto l77; yyDo(yy_1_sequence, yybegin, yyend); goto l76;
  677. l77:; yypos= yypos77; yythunkpos= yythunkpos77;
  678. }
  679. yyprintf((stderr, " ok %s @ %s\n", "sequence", yybuf+yypos));
  680. return 1;
  681. l75:; yypos= yypos0; yythunkpos= yythunkpos0;
  682. yyprintf((stderr, " fail %s @ %s\n", "sequence", yybuf+yypos));
  683. return 0;
  684. }
  685. YY_RULE(int) yy_SEMICOLON()
  686. { int yypos0= yypos, yythunkpos0= yythunkpos;
  687. yyprintf((stderr, "%s\n", "SEMICOLON")); if (!yymatchChar(';')) goto l78; if (!yy__()) goto l78;
  688. yyprintf((stderr, " ok %s @ %s\n", "SEMICOLON", yybuf+yypos));
  689. return 1;
  690. l78:; yypos= yypos0; yythunkpos= yythunkpos0;
  691. yyprintf((stderr, " fail %s @ %s\n", "SEMICOLON", yybuf+yypos));
  692. return 0;
  693. }
  694. YY_RULE(int) yy_expression()
  695. { int yypos0= yypos, yythunkpos0= yythunkpos;
  696. yyprintf((stderr, "%s\n", "expression")); if (!yy_sequence()) goto l79;
  697. l80:;
  698. { int yypos81= yypos, yythunkpos81= yythunkpos; if (!yy_BAR()) goto l81; if (!yy_sequence()) goto l81; yyDo(yy_1_expression, yybegin, yyend); goto l80;
  699. l81:; yypos= yypos81; yythunkpos= yythunkpos81;
  700. }
  701. yyprintf((stderr, " ok %s @ %s\n", "expression", yybuf+yypos));
  702. return 1;
  703. l79:; yypos= yypos0; yythunkpos= yythunkpos0;
  704. yyprintf((stderr, " fail %s @ %s\n", "expression", yybuf+yypos));
  705. return 0;
  706. }
  707. YY_RULE(int) yy_EQUAL()
  708. { int yypos0= yypos, yythunkpos0= yythunkpos;
  709. yyprintf((stderr, "%s\n", "EQUAL")); if (!yymatchChar('=')) goto l82; if (!yy__()) goto l82;
  710. yyprintf((stderr, " ok %s @ %s\n", "EQUAL", yybuf+yypos));
  711. return 1;
  712. l82:; yypos= yypos0; yythunkpos= yythunkpos0;
  713. yyprintf((stderr, " fail %s @ %s\n", "EQUAL", yybuf+yypos));
  714. return 0;
  715. }
  716. YY_RULE(int) yy_identifier()
  717. { int yypos0= yypos, yythunkpos0= yythunkpos;
  718. yyprintf((stderr, "%s\n", "identifier")); yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l83; 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 l83;
  719. l84:;
  720. { int yypos85= yypos, yythunkpos85= 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 l85; goto l84;
  721. l85:; yypos= yypos85; yythunkpos= yythunkpos85;
  722. } yyText(yybegin, yyend); if (!(YY_END)) goto l83; if (!yy__()) goto l83;
  723. yyprintf((stderr, " ok %s @ %s\n", "identifier", yybuf+yypos));
  724. return 1;
  725. l83:; yypos= yypos0; yythunkpos= yythunkpos0;
  726. yyprintf((stderr, " fail %s @ %s\n", "identifier", yybuf+yypos));
  727. return 0;
  728. }
  729. YY_RULE(int) yy_RPERCENT()
  730. { int yypos0= yypos, yythunkpos0= yythunkpos;
  731. yyprintf((stderr, "%s\n", "RPERCENT")); if (!yymatchString("%}")) goto l86; if (!yy__()) goto l86;
  732. yyprintf((stderr, " ok %s @ %s\n", "RPERCENT", yybuf+yypos));
  733. return 1;
  734. l86:; yypos= yypos0; yythunkpos= yythunkpos0;
  735. yyprintf((stderr, " fail %s @ %s\n", "RPERCENT", yybuf+yypos));
  736. return 0;
  737. }
  738. YY_RULE(int) yy_end_of_file()
  739. { int yypos0= yypos, yythunkpos0= yythunkpos;
  740. yyprintf((stderr, "%s\n", "end_of_file"));
  741. { int yypos88= yypos, yythunkpos88= yythunkpos; if (!yymatchDot()) goto l88; goto l87;
  742. l88:; yypos= yypos88; yythunkpos= yythunkpos88;
  743. }
  744. yyprintf((stderr, " ok %s @ %s\n", "end_of_file", yybuf+yypos));
  745. return 1;
  746. l87:; yypos= yypos0; yythunkpos= yythunkpos0;
  747. yyprintf((stderr, " fail %s @ %s\n", "end_of_file", yybuf+yypos));
  748. return 0;
  749. }
  750. YY_RULE(int) yy_trailer()
  751. { int yypos0= yypos, yythunkpos0= yythunkpos;
  752. yyprintf((stderr, "%s\n", "trailer")); if (!yymatchString("%%")) goto l89; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l89;
  753. l90:;
  754. { int yypos91= yypos, yythunkpos91= yythunkpos; if (!yymatchDot()) goto l91; goto l90;
  755. l91:; yypos= yypos91; yythunkpos= yythunkpos91;
  756. } yyText(yybegin, yyend); if (!(YY_END)) goto l89; yyDo(yy_1_trailer, yybegin, yyend);
  757. yyprintf((stderr, " ok %s @ %s\n", "trailer", yybuf+yypos));
  758. return 1;
  759. l89:; yypos= yypos0; yythunkpos= yythunkpos0;
  760. yyprintf((stderr, " fail %s @ %s\n", "trailer", yybuf+yypos));
  761. return 0;
  762. }
  763. YY_RULE(int) yy_definition()
  764. { int yypos0= yypos, yythunkpos0= yythunkpos;
  765. yyprintf((stderr, "%s\n", "definition")); if (!yy_identifier()) goto l92; yyDo(yy_1_definition, yybegin, yyend); if (!yy_EQUAL()) goto l92; if (!yy_expression()) goto l92; yyDo(yy_2_definition, yybegin, yyend);
  766. { int yypos93= yypos, yythunkpos93= yythunkpos; if (!yy_SEMICOLON()) goto l93; goto l94;
  767. l93:; yypos= yypos93; yythunkpos= yythunkpos93;
  768. }
  769. l94:;
  770. yyprintf((stderr, " ok %s @ %s\n", "definition", yybuf+yypos));
  771. return 1;
  772. l92:; yypos= yypos0; yythunkpos= yythunkpos0;
  773. yyprintf((stderr, " fail %s @ %s\n", "definition", yybuf+yypos));
  774. return 0;
  775. }
  776. YY_RULE(int) yy_declaration()
  777. { int yypos0= yypos, yythunkpos0= yythunkpos;
  778. yyprintf((stderr, "%s\n", "declaration")); if (!yymatchString("%{")) goto l95; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l95;
  779. l96:;
  780. { int yypos97= yypos, yythunkpos97= yythunkpos;
  781. { int yypos98= yypos, yythunkpos98= yythunkpos; if (!yymatchString("%}")) goto l98; goto l97;
  782. l98:; yypos= yypos98; yythunkpos= yythunkpos98;
  783. } if (!yymatchDot()) goto l97; goto l96;
  784. l97:; yypos= yypos97; yythunkpos= yythunkpos97;
  785. } yyText(yybegin, yyend); if (!(YY_END)) goto l95; if (!yy_RPERCENT()) goto l95; yyDo(yy_1_declaration, yybegin, yyend);
  786. yyprintf((stderr, " ok %s @ %s\n", "declaration", yybuf+yypos));
  787. return 1;
  788. l95:; yypos= yypos0; yythunkpos= yythunkpos0;
  789. yyprintf((stderr, " fail %s @ %s\n", "declaration", yybuf+yypos));
  790. return 0;
  791. }
  792. YY_RULE(int) yy__()
  793. {
  794. yyprintf((stderr, "%s\n", "_"));
  795. l100:;
  796. { int yypos101= yypos, yythunkpos101= yythunkpos;
  797. { int yypos102= yypos, yythunkpos102= yythunkpos; if (!yy_space()) goto l103; goto l102;
  798. l103:; yypos= yypos102; yythunkpos= yythunkpos102; if (!yy_comment()) goto l101;
  799. }
  800. l102:; goto l100;
  801. l101:; yypos= yypos101; yythunkpos= yythunkpos101;
  802. }
  803. yyprintf((stderr, " ok %s @ %s\n", "_", yybuf+yypos));
  804. return 1;
  805. }
  806. YY_RULE(int) yy_grammar()
  807. { int yypos0= yypos, yythunkpos0= yythunkpos;
  808. yyprintf((stderr, "%s\n", "grammar")); if (!yy__()) goto l104;
  809. { int yypos107= yypos, yythunkpos107= yythunkpos; if (!yy_declaration()) goto l108; goto l107;
  810. l108:; yypos= yypos107; yythunkpos= yythunkpos107; if (!yy_definition()) goto l104;
  811. }
  812. l107:;
  813. l105:;
  814. { int yypos106= yypos, yythunkpos106= yythunkpos;
  815. { int yypos109= yypos, yythunkpos109= yythunkpos; if (!yy_declaration()) goto l110; goto l109;
  816. l110:; yypos= yypos109; yythunkpos= yythunkpos109; if (!yy_definition()) goto l106;
  817. }
  818. l109:; goto l105;
  819. l106:; yypos= yypos106; yythunkpos= yythunkpos106;
  820. }
  821. { int yypos111= yypos, yythunkpos111= yythunkpos; if (!yy_trailer()) goto l111; goto l112;
  822. l111:; yypos= yypos111; yythunkpos= yythunkpos111;
  823. }
  824. l112:; if (!yy_end_of_file()) goto l104;
  825. yyprintf((stderr, " ok %s @ %s\n", "grammar", yybuf+yypos));
  826. return 1;
  827. l104:; yypos= yypos0; yythunkpos= yythunkpos0;
  828. yyprintf((stderr, " fail %s @ %s\n", "grammar", yybuf+yypos));
  829. return 0;
  830. }
  831. #ifndef YY_PART
  832. typedef int (*yyrule)();
  833. YY_PARSE(int) YYPARSEFROM(yyrule yystart)
  834. {
  835. int yyok;
  836. if (!yybuflen)
  837. {
  838. yybuflen= 1024;
  839. yybuf= malloc(yybuflen);
  840. yytextlen= 1024;
  841. yytext= malloc(yytextlen);
  842. yythunkslen= 32;
  843. yythunks= malloc(sizeof(yythunk) * yythunkslen);
  844. yyvalslen= 32;
  845. yyvals= malloc(sizeof(YYSTYPE) * yyvalslen);
  846. yybegin= yyend= yypos= yylimit= yythunkpos= 0;
  847. }
  848. yybegin= yyend= yypos;
  849. yythunkpos= 0;
  850. yyval= yyvals;
  851. yyok= yystart();
  852. if (yyok) yyDone();
  853. yyCommit();
  854. return yyok;
  855. (void)yyrefill;
  856. (void)yymatchDot;
  857. (void)yymatchChar;
  858. (void)yymatchString;
  859. (void)yymatchClass;
  860. (void)yyDo;
  861. (void)yyText;
  862. (void)yyDone;
  863. (void)yyCommit;
  864. (void)yyAccept;
  865. (void)yyPush;
  866. (void)yyPop;
  867. (void)yySet;
  868. (void)yytextmax;
  869. }
  870. YY_PARSE(int) YYPARSE(void)
  871. {
  872. return YYPARSEFROM(yy_grammar);
  873. }
  874. #endif
  875. void yyerror(char *message)
  876. {
  877. fprintf(stderr, "%s:%d: %s", fileName, lineNumber, message);
  878. if (yytext[0]) fprintf(stderr, " near token '%s'", yytext);
  879. if (yypos < yylimit || !feof(input))
  880. {
  881. yybuf[yylimit]= '\0';
  882. fprintf(stderr, " before text \"");
  883. while (yypos < yylimit)
  884. {
  885. if ('\n' == yybuf[yypos] || '\r' == yybuf[yypos]) break;
  886. fputc(yybuf[yypos++], stderr);
  887. }
  888. if (yypos == yylimit)
  889. {
  890. int c;
  891. while (EOF != (c= fgetc(input)) && '\n' != c && '\r' != c)
  892. fputc(c, stderr);
  893. }
  894. fputc('\"', stderr);
  895. }
  896. fprintf(stderr, "\n");
  897. exit(1);
  898. }
  899. void makeHeader(char *text)
  900. {
  901. Header *header= (Header *)malloc(sizeof(Header));
  902. header->text= strdup(text);
  903. header->next= headers;
  904. headers= header;
  905. }
  906. void makeTrailer(char *text)
  907. {
  908. trailer= strdup(text);
  909. }
  910. static void version(char *name)
  911. {
  912. printf("%s version %d.%d.%d\n", name, PEG_MAJOR, PEG_MINOR, PEG_LEVEL);
  913. }
  914. static void usage(char *name)
  915. {
  916. version(name);
  917. fprintf(stderr, "usage: %s [<option>...] [<file>...]\n", name);
  918. fprintf(stderr, "where <option> can be\n");
  919. fprintf(stderr, " -h print this help information\n");
  920. fprintf(stderr, " -o <ofile> write output to <ofile>\n");
  921. fprintf(stderr, " -v be verbose\n");
  922. fprintf(stderr, " -V print version number and exit\n");
  923. fprintf(stderr, "if no <file> is given, input is read from stdin\n");
  924. fprintf(stderr, "if no <ofile> is given, output is written to stdout\n");
  925. exit(1);
  926. }
  927. int main(int argc, char **argv)
  928. {
  929. Node *n;
  930. int c;
  931. output= stdout;
  932. input= stdin;
  933. lineNumber= 1;
  934. fileName= "<stdin>";
  935. while (-1 != (c= getopt(argc, argv, "Vho:v")))
  936. {
  937. switch (c)
  938. {
  939. case 'V':
  940. version(basename(argv[0]));
  941. exit(0);
  942. case 'h':
  943. usage(basename(argv[0]));
  944. break;
  945. case 'o':
  946. if (!(output= fopen(optarg, "w")))
  947. {
  948. perror(optarg);
  949. exit(1);
  950. }
  951. break;
  952. case 'v':
  953. verboseFlag= 1;
  954. break;
  955. default:
  956. fprintf(stderr, "for usage try: %s -h\n", argv[0]);
  957. exit(1);
  958. }
  959. }
  960. argc -= optind;
  961. argv += optind;
  962. if (argc)
  963. {
  964. for (; argc; --argc, ++argv)
  965. {
  966. if (!strcmp(*argv, "-"))
  967. {
  968. input= stdin;
  969. fileName= "<stdin>";
  970. }
  971. else
  972. {
  973. if (!(input= fopen(*argv, "r")))
  974. {
  975. perror(*argv);
  976. exit(1);
  977. }
  978. fileName= *argv;
  979. }
  980. lineNumber= 1;
  981. if (!yyparse())
  982. yyerror("syntax error");
  983. if (input != stdin)
  984. fclose(input);
  985. }
  986. }
  987. else
  988. if (!yyparse())
  989. yyerror("syntax error");
  990. if (verboseFlag)
  991. for (n= rules; n; n= n->any.next)
  992. Rule_print(n);
  993. Rule_compile_c_header();
  994. for (; headers; headers= headers->next)
  995. fprintf(output, "%s\n", headers->text);
  996. Rule_compile_c(rules);
  997. if (trailer)
  998. fprintf(output, "%s\n", trailer);
  999. return 0;
  1000. }