skeleton.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861
  1. /*
  2. ** This file generated automatically from
  3. */
  4. #include "defs.h"
  5. /* The banner used here should be replaced with an #ident directive */
  6. /* if the target C compiler supports #ident directives. */
  7. /* */
  8. /* If the skeleton is changed, the banner should be changed so that */
  9. /* the altered version can easily be distinguished from the original. */
  10. char *banner[] =
  11. {
  12. "#line 8 \"btyaccpa.ske\"",
  13. "",
  14. "//",
  15. "// @(#)btyaccpar, based on byacc 1.8 (Berkeley)",
  16. "//",
  17. "#define YYBTYACC 1",
  18. "",
  19. "#include <stdio.h>",
  20. "#include <stdlib.h>",
  21. "#include <string.h>",
  22. "",
  23. "typedef int Yshort;",
  24. "",
  25. 0
  26. };
  27. char *tables[] =
  28. {
  29. "#line 21 \"btyaccpa.ske\"",
  30. "",
  31. "#define _C_ \"C\"",
  32. "",
  33. "extern _C_ Yshort yylhs[];",
  34. "extern _C_ Yshort yylen[];",
  35. "extern _C_ Yshort yydefred[];",
  36. "extern _C_ Yshort yydgoto[];",
  37. "extern _C_ Yshort yysindex[];",
  38. "extern _C_ Yshort yyrindex[];",
  39. "extern _C_ Yshort yycindex[];",
  40. "extern _C_ Yshort yygindex[];",
  41. "extern _C_ Yshort yytable[];",
  42. "extern _C_ Yshort yycheck[];",
  43. "extern _C_ Yshort yyctable[];",
  44. "",
  45. "#if YYDEBUG",
  46. "extern _C_ char *yyname[];",
  47. "extern _C_ char *yyrule[];",
  48. "#endif",
  49. "",
  50. 0
  51. };
  52. char *header[] =
  53. {
  54. "#line 42 \"btyaccpa.ske\"",
  55. "",
  56. "//",
  57. "// YYPOSN is user-defined text position type.",
  58. "//",
  59. "#ifndef YYPOSN",
  60. "#define YYPOSN int",
  61. "#endif",
  62. "",
  63. "#ifdef YYREDUCEPOSNFUNC",
  64. "#define YYCALLREDUCEPOSN(e) \\",
  65. "\tif(reduce_posn) { \\",
  66. "\t YYREDUCEPOSNFUNC(yyps->pos, &(yyps->psp)[1-yym], &(yyps->vsp)[1-yym], \\",
  67. "\t\t\t yym, yyps->psp - yyps->ps, yychar, yyposn, e); \\",
  68. "\t reduce_posn = 0; \\",
  69. "\t}",
  70. "",
  71. "#ifndef YYCALLREDUCEPOSNARG",
  72. "#define YYCALLREDUCEPOSNARG yyps->val",
  73. "#endif",
  74. "",
  75. "",
  76. "#define YYPOSNARG(n) ((yyps->psp)[1-yym+(n)-1])",
  77. "#define YYPOSNOUT (yyps->pos)",
  78. "#endif",
  79. "",
  80. "// If delete function is not defined by the user, do not deletions.",
  81. "#ifndef YYDELETEVAL",
  82. "#define YYDELETEVAL(v) ",
  83. "#endif",
  84. "",
  85. "// If delete function is not defined by the user, do not deletions.",
  86. "#ifndef YYDELETEPOSN",
  87. "#define YYDELETEPOSN(v) ",
  88. "#endif",
  89. "",
  90. "#define yyclearin (yychar=(-1))",
  91. "",
  92. "#define yyerrok (yyps->errflag=0)",
  93. "",
  94. "#ifndef YYSTACKGROWTH",
  95. "#define YYSTACKGROWTH 16",
  96. "#endif",
  97. "",
  98. "#ifndef YYDEFSTACKSIZE",
  99. "#define YYDEFSTACKSIZE 12",
  100. "#endif",
  101. "",
  102. "#ifdef YYDEBUG",
  103. "int yydebug;",
  104. "#endif",
  105. "",
  106. "int yynerrs;",
  107. "",
  108. "/* These value/posn are taken from the lexer */",
  109. "YYSTYPE yylval;",
  110. "YYPOSN yyposn;",
  111. "",
  112. "/* These value/posn of the root non-terminal are returned to the caller */",
  113. "YYSTYPE yyretlval;",
  114. "YYPOSN yyretposn;",
  115. "",
  116. "#define YYABORT goto yyabort",
  117. "#define YYACCEPT goto yyaccept",
  118. "#define YYERROR goto yyerrlab",
  119. "#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)",
  120. "#define YYVALID_NESTED do { if (yyps->save && \\",
  121. " yyps->save->save==0) goto yyvalid; } while(0)",
  122. "",
  123. "struct yyparsestate {",
  124. " yyparsestate *save; // Previously saved parser state",
  125. " int state;",
  126. " int errflag;",
  127. " Yshort *ssp; // state stack pointer",
  128. " YYSTYPE *vsp; // value stack pointer",
  129. " YYPOSN *psp; // position stack pointer",
  130. " YYSTYPE val; // value as returned by actions",
  131. " YYPOSN pos; // position as returned by universal action",
  132. " Yshort *ss; // state stack base",
  133. " YYSTYPE *vs; // values stack base",
  134. " YYPOSN *ps; // position stack base",
  135. " int lexeme; // index of the conflict lexeme in the lexical queue",
  136. " unsigned int stacksize; // current maximum stack size",
  137. " Yshort ctry; // index in yyctable[] for this conflict",
  138. "};",
  139. "",
  140. "// Current parser state",
  141. "static yyparsestate *yyps=0;",
  142. "",
  143. "// yypath!=NULL: do the full parse, starting at *yypath parser state.",
  144. "static yyparsestate *yypath=0;",
  145. "",
  146. "// Base of the lexical value queue",
  147. "static YYSTYPE *yylvals=0;",
  148. "",
  149. "// Current posistion at lexical value queue",
  150. "static YYSTYPE *yylvp=0;",
  151. "",
  152. "// End position of lexical value queue",
  153. "static YYSTYPE *yylve=0;",
  154. "",
  155. "// The last allocated position at the lexical value queue",
  156. "static YYSTYPE *yylvlim=0;",
  157. "",
  158. "// Base of the lexical position queue",
  159. "static YYPOSN *yylpsns=0;",
  160. "",
  161. "// Current posistion at lexical position queue",
  162. "static YYPOSN *yylpp=0;",
  163. "",
  164. "// End position of lexical position queue",
  165. "static YYPOSN *yylpe=0;",
  166. "",
  167. "// The last allocated position at the lexical position queue",
  168. "static YYPOSN *yylplim=0;",
  169. "",
  170. "// Current position at lexical token queue",
  171. "static Yshort *yylexp=0;",
  172. "",
  173. "static Yshort *yylexemes=0;",
  174. "",
  175. "//",
  176. "// For use in generated program",
  177. "//",
  178. "#define yytrial (yyps->save)",
  179. "#define yyvsp (yyps->vsp)",
  180. "#define yyval (yyps->val)",
  181. "#define yydepth (yyps->ssp - yyps->ss)",
  182. "",
  183. "",
  184. "//",
  185. "// Local prototypes.",
  186. "//",
  187. "int yyparse(void);",
  188. "",
  189. "int YYLex1();",
  190. "int yyexpand();",
  191. "void YYSCopy(YYSTYPE *to, YYSTYPE *from, int size);",
  192. "void YYPCopy(YYPOSN *to, YYPOSN *from, int size);",
  193. "void YYMoreStack(yyparsestate *yyps);",
  194. "yyparsestate *YYNewState(int size);",
  195. "void YYFreeState(yyparsestate *p);",
  196. "",
  197. "",
  198. 0
  199. };
  200. char *body[] =
  201. {
  202. "#line 186 \"btyaccpa.ske\"",
  203. "",
  204. "",
  205. "//",
  206. "// Parser function",
  207. "//",
  208. "int yyparse() {",
  209. " int yym, yyn, yystate, yychar, yynewerrflag;",
  210. " yyparsestate *yyerrctx = NULL;",
  211. " int reduce_posn;",
  212. "",
  213. "#if YYDEBUG",
  214. " char *yys;",
  215. " ",
  216. " if ((yys = getenv(\"YYDEBUG\"))) {",
  217. " yyn = *yys;",
  218. " if (yyn >= '0' && yyn <= '9')",
  219. " yydebug = yyn - '0'; ",
  220. " }",
  221. "#endif",
  222. " ",
  223. " yyps = YYNewState(YYDEFSTACKSIZE);",
  224. " yyps->save = 0;",
  225. " yynerrs = 0;",
  226. " yyps->errflag = 0;",
  227. " yychar = (-1);",
  228. " ",
  229. " yyps->ssp = yyps->ss;",
  230. " yyps->vsp = yyps->vs;",
  231. " yyps->psp = yyps->ps;",
  232. " *(yyps->ssp) = yystate = 0;",
  233. " ",
  234. "",
  235. " //",
  236. " // Main parsing loop",
  237. " //",
  238. " yyloop:",
  239. " if ((yyn = yydefred[yystate])) {",
  240. " goto yyreduce;",
  241. " }",
  242. "",
  243. " //",
  244. " // Read one token",
  245. " //",
  246. " if (yychar < 0) {",
  247. " if ((yychar = YYLex1()) < 0) yychar = 0;",
  248. "#if YYDEBUG",
  249. " if (yydebug) {",
  250. " yys = 0;",
  251. " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];",
  252. " if (!yys) yys = \"illegal-symbol\";",
  253. " printf(\"yydebug[%d,%d]: state %d, reading %d (%s)\", ",
  254. "\t yydepth, (int)yytrial, yystate, yychar, yys);",
  255. "#ifdef YYDBPR",
  256. " printf(\"<\");",
  257. " YYDBPR(yylval);",
  258. " printf(\">\");",
  259. "#endif",
  260. " printf(\"\\n\"); ",
  261. " }",
  262. "#endif",
  263. " }",
  264. "",
  265. " //",
  266. " // Do we have a conflict?",
  267. " //",
  268. " if ((yyn = yycindex[yystate]) &&",
  269. " (yyn += yychar) >= 0 &&",
  270. " yyn <= YYTABLESIZE &&",
  271. " yycheck[yyn] == yychar) {",
  272. " int ctry;",
  273. "",
  274. " if (yypath) {",
  275. "#if YYDEBUG",
  276. " if (yydebug) {",
  277. " printf(\"yydebug[%d,%d]: CONFLICT in state %d: following successful trial parse\\n\", ",
  278. "\t yydepth, (int)yytrial, yystate);",
  279. " }",
  280. "#endif",
  281. " // Switch to the next conflict context",
  282. " yyparsestate *save = yypath;",
  283. " yypath = save->save;",
  284. " ctry = save->ctry;",
  285. " if (save->state != yystate) ",
  286. " goto yyabort;",
  287. " YYFreeState(save); ",
  288. "",
  289. " } else {",
  290. "",
  291. "#if YYDEBUG",
  292. " if (yydebug) {",
  293. " printf(\"yydebug[%d,%d]: CONFLICT in state %d. \", ",
  294. "\t yydepth, (int)yytrial, yystate);",
  295. " if(yyps->save) {",
  296. " printf(\"ALREADY in conflict. Continue trial parse.\");",
  297. " } else {",
  298. " printf(\"Start trial parse.\");",
  299. " }",
  300. " printf(\"\\n\");",
  301. " }",
  302. "#endif",
  303. " yyparsestate *save = YYNewState(yyps->ssp - yyps->ss);",
  304. " save->save = yyps->save;",
  305. " save->state = yystate;",
  306. " save->errflag = yyps->errflag;",
  307. " save->ssp = save->ss + (yyps->ssp - yyps->ss);",
  308. " save->vsp = save->vs + (yyps->vsp - yyps->vs);",
  309. " save->psp = save->ps + (yyps->psp - yyps->ps);",
  310. " memcpy (save->ss, yyps->ss, (yyps->ssp - yyps->ss + 1)*sizeof(Yshort));",
  311. " YYSCopy(save->vs, yyps->vs, (yyps->ssp - yyps->ss + 1));",
  312. " YYPCopy(save->ps, yyps->ps, (yyps->ssp - yyps->ss + 1));",
  313. " ctry = yytable[yyn];",
  314. " if (yyctable[ctry] == -1) {",
  315. "#if YYDEBUG",
  316. " if (yydebug && yychar >= 0)",
  317. " printf(\"yydebug[%d]: backtracking 1 token\\n\", ",
  318. "\t\t (int)yytrial);",
  319. "#endif",
  320. " ctry++; ",
  321. " }",
  322. " save->ctry = ctry;",
  323. " if (!yyps->save) {",
  324. " // If this is a first conflict in the stack, start saving lexemes",
  325. " if (!yylexemes) {",
  326. " yylexemes = new Yshort[YYSTACKGROWTH];",
  327. " yylvals = new YYSTYPE[YYSTACKGROWTH];",
  328. " yylvlim = yylvals + YYSTACKGROWTH; ",
  329. " yylpsns = new YYPOSN[YYSTACKGROWTH];",
  330. " yylplim = yylpsns + YYSTACKGROWTH; ",
  331. " }",
  332. " if (yylvp == yylve) {",
  333. " yylvp = yylve = yylvals;",
  334. "\t yylpp = yylpe = yylpsns;",
  335. " yylexp = yylexemes;",
  336. " if (yychar >= 0) {",
  337. " *yylve++ = yylval;",
  338. " *yylpe++ = yyposn;",
  339. " *yylexp = yychar;",
  340. " yychar = -1; ",
  341. " } ",
  342. " } ",
  343. " }",
  344. " if (yychar >= 0) {",
  345. " yylvp--, yylpp--, yylexp--;",
  346. " yychar = -1; ",
  347. " }",
  348. " save->lexeme = yylvp - yylvals;",
  349. " yyps->save = save; ",
  350. " }",
  351. " if (yytable[yyn] == ctry) {",
  352. "#if YYDEBUG",
  353. " if (yydebug)",
  354. " printf(\"yydebug[%d,%d]: state %d, shifting to state %d\\n\",",
  355. " yydepth, (int)yytrial, yystate, yyctable[ctry]);",
  356. "#endif",
  357. " if (yychar < 0)",
  358. " yylvp++, yylpp++, yylexp++;",
  359. " yychar = -1;",
  360. " if (yyps->errflag > 0) --yyps->errflag;",
  361. " yystate = yyctable[ctry];",
  362. " goto yyshift; ",
  363. " } else {",
  364. " yyn = yyctable[ctry];",
  365. " goto yyreduce; ",
  366. " } ",
  367. " }",
  368. "",
  369. " //",
  370. " // Is action a shift?",
  371. " //",
  372. " if ((yyn = yysindex[yystate]) &&",
  373. " (yyn += yychar) >= 0 &&",
  374. " yyn <= YYTABLESIZE &&",
  375. " yycheck[yyn] == yychar) {",
  376. "#if YYDEBUG",
  377. " if (yydebug)",
  378. " printf(\"yydebug[%d,%d]: state %d, shifting to state %d\\n\",",
  379. " yydepth, (int)yytrial, yystate, yytable[yyn]);",
  380. "#endif",
  381. " yychar = (-1);",
  382. " if (yyps->errflag > 0) --yyps->errflag;",
  383. " yystate = yytable[yyn];",
  384. " yyshift:",
  385. " if (yyps->ssp >= yyps->ss + yyps->stacksize - 1) {",
  386. " YYMoreStack(yyps);",
  387. " }",
  388. " *++(yyps->ssp) = yystate;",
  389. " *++(yyps->vsp) = yylval;",
  390. " *++(yyps->psp) = yyposn;",
  391. " goto yyloop;",
  392. " }",
  393. " if ((yyn = yyrindex[yystate]) &&",
  394. " (yyn += yychar) >= 0 &&",
  395. " yyn <= YYTABLESIZE &&",
  396. " yycheck[yyn] == yychar) {",
  397. " yyn = yytable[yyn];",
  398. " goto yyreduce;",
  399. " }",
  400. "",
  401. " //",
  402. " // Action: error",
  403. " //",
  404. " if (yyps->errflag) goto yyinrecovery;",
  405. " yynewerrflag = 1;",
  406. " goto yyerrhandler;",
  407. "yyerrlab:",
  408. " yynewerrflag = 0;",
  409. "yyerrhandler:",
  410. " while (yyps->save) { ",
  411. " int ctry; ",
  412. " yyparsestate *save = yyps->save;",
  413. "#if YYDEBUG",
  414. " if (yydebug)",
  415. " printf(\"yydebug[%d,%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\\n\",",
  416. " yydepth, (int)yytrial, yystate, yyps->save->state, yylvp - yylvals - yyps->save->lexeme);",
  417. "#endif",
  418. " // Memorize most forward-looking error state in case",
  419. " // it's really an error.",
  420. " if(yyerrctx==NULL || yyerrctx->lexeme<yylvp-yylvals) {",
  421. " // Free old saved error context state",
  422. " if(yyerrctx) YYFreeState(yyerrctx);",
  423. " // Create and fill out new saved error context state",
  424. " yyerrctx = YYNewState(yyps->ssp - yyps->ss);",
  425. " yyerrctx->save = yyps->save;",
  426. " yyerrctx->state = yystate;",
  427. " yyerrctx->errflag = yyps->errflag;",
  428. " yyerrctx->ssp = yyerrctx->ss + (yyps->ssp - yyps->ss);",
  429. " yyerrctx->vsp = yyerrctx->vs + (yyps->vsp - yyps->vs);",
  430. " yyerrctx->psp = yyerrctx->ps + (yyps->psp - yyps->ps);",
  431. " memcpy (yyerrctx->ss, yyps->ss, (yyps->ssp - yyps->ss + 1)*sizeof(Yshort));",
  432. " YYSCopy(yyerrctx->vs, yyps->vs, (yyps->ssp - yyps->ss + 1));",
  433. " YYPCopy(yyerrctx->ps, yyps->ps, (yyps->ssp - yyps->ss + 1));",
  434. " yyerrctx->lexeme = yylvp - yylvals;",
  435. " }",
  436. " yylvp = yylvals + save->lexeme;",
  437. " yylpp = yylpsns + save->lexeme;",
  438. " yylexp = yylexemes + save->lexeme;",
  439. " yychar = -1;",
  440. " yyps->ssp = yyps->ss + (save->ssp - save->ss);",
  441. " yyps->vsp = yyps->vs + (save->vsp - save->vs);",
  442. " yyps->psp = yyps->ps + (save->psp - save->ps);",
  443. " memcpy (yyps->ss, save->ss, (yyps->ssp - yyps->ss + 1) * sizeof(Yshort));",
  444. " YYSCopy(yyps->vs, save->vs, yyps->vsp - yyps->vs + 1);",
  445. " YYPCopy(yyps->ps, save->ps, yyps->psp - yyps->ps + 1);",
  446. " ctry = ++save->ctry;",
  447. " yystate = save->state;",
  448. " // We tried shift, try reduce now",
  449. " if ((yyn = yyctable[ctry]) >= 0) {",
  450. " goto yyreduce;",
  451. " }",
  452. " yyps->save = save->save;",
  453. " YYFreeState(save);",
  454. " //",
  455. " // Nothing left on the stack -- error",
  456. " //",
  457. " if (!yyps->save) {",
  458. "#if YYDEBUG",
  459. " if (yydebug) {",
  460. " printf(\"yydebug[%d]: trial parse FAILED, entering ERROR mode\\n\", ",
  461. "\t (int)yytrial);",
  462. " }",
  463. "#endif",
  464. " // Restore state as it was in the most forward-advanced error",
  465. " yylvp = yylvals + yyerrctx->lexeme;",
  466. " yylpp = yylpsns + yyerrctx->lexeme;",
  467. " yylexp = yylexemes + yyerrctx->lexeme;",
  468. " yychar = yylexp[-1];",
  469. " yylval = yylvp[-1];",
  470. " yyposn = yylpp[-1];",
  471. " yyps->ssp = yyps->ss + (yyerrctx->ssp - yyerrctx->ss);",
  472. " yyps->vsp = yyps->vs + (yyerrctx->vsp - yyerrctx->vs);",
  473. " yyps->psp = yyps->ps + (yyerrctx->psp - yyerrctx->ps);",
  474. " memcpy (yyps->ss, yyerrctx->ss, (yyps->ssp - yyps->ss + 1) * sizeof(Yshort));",
  475. " YYSCopy(yyps->vs, yyerrctx->vs, yyps->vsp - yyps->vs + 1);",
  476. " YYPCopy(yyps->ps, yyerrctx->ps, yyps->psp - yyps->ps + 1);",
  477. " yystate = yyerrctx->state;",
  478. " YYFreeState(yyerrctx);",
  479. " yyerrctx = NULL;",
  480. " }",
  481. " yynewerrflag = 1; ",
  482. " }",
  483. " if (yynewerrflag) {",
  484. "#ifdef YYERROR_DETAILED",
  485. " yyerror_detailed(\"syntax error\", yychar, yylval, yyposn);",
  486. "#else",
  487. " yyerror(\"syntax error\");",
  488. "#endif",
  489. " }",
  490. " ++yynerrs;",
  491. " yyinrecovery:",
  492. " if (yyps->errflag < 3) {",
  493. " yyps->errflag = 3;",
  494. " for (;;) {",
  495. " if ((yyn = yysindex[*(yyps->ssp)]) && ",
  496. "\t (yyn += YYERRCODE) >= 0 &&",
  497. " yyn <= YYTABLESIZE && ",
  498. "\t yycheck[yyn] == YYERRCODE) {",
  499. "#if YYDEBUG",
  500. " if (yydebug)",
  501. " printf(\"yydebug[%d,%d]: state %d, ERROR recovery shifts to state %d\\n\",",
  502. " yydepth, (int)yytrial, *(yyps->ssp), yytable[yyn]);",
  503. "#endif",
  504. " /* Use label yyerrlab, so that compiler does not warn */",
  505. " if(yyps->errflag != yyps->errflag) goto yyerrlab;",
  506. " yystate = yytable[yyn];",
  507. " goto yyshift; ",
  508. " } else {",
  509. "#if YYDEBUG",
  510. " if (yydebug)",
  511. " printf(\"yydebug[%d,%d]: ERROR recovery discards state %d\\n\",",
  512. " yydepth, (int)yytrial, *(yyps->ssp));",
  513. "#endif",
  514. " if (yyps->ssp <= yyps->ss) {",
  515. "\t goto yyabort;",
  516. "\t}",
  517. "\tif(!yytrial) {",
  518. "\t YYDELETEVAL(yyps->vsp[0],1);",
  519. "\t YYDELETEPOSN(yyps->psp[0],1);",
  520. "\t}",
  521. " --(yyps->ssp);",
  522. " --(yyps->vsp);",
  523. " --(yyps->psp);",
  524. " }",
  525. " }",
  526. " } else {",
  527. " if (yychar == 0) goto yyabort;",
  528. "#if YYDEBUG",
  529. " if (yydebug) {",
  530. " yys = 0;",
  531. " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];",
  532. " if (!yys) yys = \"illegal-symbol\";",
  533. " printf(\"yydebug[%d,%d]: state %d, ERROR recovery discards token %d (%s)\\n\",",
  534. " yydepth, (int)yytrial, yystate, yychar, yys); ",
  535. " }",
  536. "#endif",
  537. " if(!yytrial) {",
  538. " YYDELETEVAL(yylval,0);",
  539. " YYDELETEPOSN(yyposn,0);",
  540. " }",
  541. " yychar = (-1);",
  542. " goto yyloop;",
  543. " }",
  544. "",
  545. " //",
  546. " // Reduce the rule",
  547. " //",
  548. "yyreduce:",
  549. " yym = yylen[yyn];",
  550. "#if YYDEBUG",
  551. " if (yydebug) {",
  552. " printf(\"yydebug[%d,%d]: state %d, reducing by rule %d (%s)\",",
  553. " yydepth, (int)yytrial, yystate, yyn, yyrule[yyn]);",
  554. "#ifdef YYDBPR",
  555. " if (yym) {",
  556. " int i;",
  557. " printf(\"<\");",
  558. " for (i=yym; i>0; i--) {",
  559. " if (i!=yym) printf(\", \");",
  560. " YYDBPR((yyps->vsp)[1-i]);",
  561. " }",
  562. " printf(\">\");",
  563. " }",
  564. "#endif",
  565. " printf(\"\\n\");",
  566. " }",
  567. "#endif",
  568. " if (yyps->ssp + 1 - yym >= yyps->ss + yyps->stacksize) {",
  569. " YYMoreStack(yyps);",
  570. " }",
  571. "",
  572. " /* \"$$ = NULL\" default action */",
  573. " memset(&yyps->val, 0, sizeof(yyps->val));",
  574. "",
  575. " /* default reduced position is NULL -- no position at all.",
  576. " no position will be assigned at trial time and if no position handling is present */",
  577. " memset(&yyps->pos, 0, sizeof(yyps->pos));",
  578. "",
  579. " reduce_posn = TRUE;",
  580. "",
  581. " switch (yyn) {",
  582. "",
  583. 0
  584. };
  585. char *trailer[] =
  586. {
  587. "#line 567 \"btyaccpa.ske\"",
  588. "",
  589. " default:",
  590. " break;",
  591. " }",
  592. "",
  593. "#if YYDEBUG && defined(YYDBPR)",
  594. " if (yydebug) {",
  595. " printf(\"yydebug[%d]: after reduction, result is \", yytrial);",
  596. " YYDBPR(yyps->val);",
  597. " printf(\"\\n\");",
  598. " }",
  599. "#endif",
  600. "",
  601. " // Perform user-defined position reduction",
  602. "#ifdef YYREDUCEPOSNFUNC",
  603. " if(!yytrial) {",
  604. " YYCALLREDUCEPOSN(YYREDUCEPOSNFUNCARG);",
  605. " }",
  606. "#endif",
  607. "",
  608. " yyps->ssp -= yym;",
  609. " yystate = *(yyps->ssp);",
  610. " yyps->vsp -= yym;",
  611. " yyps->psp -= yym;",
  612. "",
  613. " yym = yylhs[yyn];",
  614. " if (yystate == 0 && yym == 0) {",
  615. "#if YYDEBUG",
  616. " if (yydebug) {",
  617. " printf(\"yydebug[%d,%d]: after reduction, shifting from state 0 to state %d\\n\", ",
  618. "\t yydepth, (int)yytrial, YYFINAL);",
  619. " }",
  620. "#endif",
  621. " yystate = YYFINAL;",
  622. " *++(yyps->ssp) = YYFINAL;",
  623. " *++(yyps->vsp) = yyps->val;",
  624. " yyretlval = yyps->val;\t// return value of root non-terminal to yylval",
  625. " *++(yyps->psp) = yyps->pos;",
  626. " yyretposn = yyps->pos;\t// return value of root position to yyposn",
  627. " if (yychar < 0) {",
  628. " if ((yychar = YYLex1()) < 0) {",
  629. " yychar = 0;",
  630. " }",
  631. "#if YYDEBUG",
  632. " if (yydebug) {",
  633. " yys = 0;",
  634. " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];",
  635. " if (!yys) yys = \"illegal-symbol\";",
  636. " printf(\"yydebug[%d,%d]: state %d, reading %d (%s)\\n\", ",
  637. "\t yydepth, (int)yytrial, YYFINAL, yychar, yys); ",
  638. " }",
  639. "#endif",
  640. " }",
  641. " if (yychar == 0) goto yyaccept;",
  642. " goto yyloop;",
  643. " }",
  644. "",
  645. " if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&",
  646. " yyn <= YYTABLESIZE && yycheck[yyn] == yystate) {",
  647. " yystate = yytable[yyn];",
  648. " } else {",
  649. " yystate = yydgoto[yym];",
  650. " }",
  651. "#if YYDEBUG",
  652. " if (yydebug)",
  653. " printf(\"yydebug[%d,%d]: after reduction, shifting from state %d to state %d\\n\",",
  654. " yydepth, (int)yytrial, *(yyps->ssp), yystate);",
  655. "#endif",
  656. " if (yyps->ssp >= yyps->ss + yyps->stacksize - 1) {",
  657. " YYMoreStack(yyps);",
  658. " }",
  659. " *++(yyps->ssp) = yystate;",
  660. " *++(yyps->vsp) = yyps->val;",
  661. " *++(yyps->psp) = yyps->pos;",
  662. " goto yyloop;",
  663. "",
  664. "",
  665. " //",
  666. " // Reduction declares that this path is valid.",
  667. " // Set yypath and do a full parse",
  668. " //",
  669. "yyvalid:",
  670. " if (yypath) {",
  671. " goto yyabort;",
  672. " }",
  673. " while (yyps->save) {",
  674. " yyparsestate *save = yyps->save;",
  675. " yyps->save = save->save;",
  676. " save->save = yypath;",
  677. " yypath = save;",
  678. " }",
  679. "#if YYDEBUG",
  680. " if (yydebug)",
  681. " printf(\"yydebug[%d,%d]: CONFLICT trial successful, backtracking to state %d, %d tokens\\n\",",
  682. " yydepth, (int)yytrial, yypath->state, yylvp - yylvals - yypath->lexeme);",
  683. "#endif",
  684. " if(yyerrctx) {",
  685. " YYFreeState(yyerrctx); yyerrctx = NULL;",
  686. " }",
  687. " yychar = -1;",
  688. " yyps->ssp = yyps->ss + (yypath->ssp - yypath->ss);",
  689. " yyps->vsp = yyps->vs + (yypath->vsp - yypath->vs);",
  690. " yyps->psp = yyps->ps + (yypath->psp - yypath->ps);",
  691. " memcpy (yyps->ss, yypath->ss, (yyps->ssp - yyps->ss + 1) * sizeof(Yshort));",
  692. " YYSCopy(yyps->vs, yypath->vs, yyps->vsp - yyps->vs + 1);",
  693. " YYPCopy(yyps->ps, yypath->ps, yyps->psp - yyps->ps + 1);",
  694. " yylvp = yylvals + yypath->lexeme;",
  695. " yylpp = yylpsns + yypath->lexeme;",
  696. " yylexp = yylexemes + yypath->lexeme;",
  697. " yystate = yypath->state;",
  698. " goto yyloop;",
  699. "",
  700. "",
  701. "yyabort:",
  702. " if(yyerrctx) {",
  703. " YYFreeState(yyerrctx); yyerrctx = NULL;",
  704. " }",
  705. "",
  706. " YYSTYPE *pv;",
  707. " for(pv=yyps->vs; pv<yyps->vsp; pv++) {",
  708. " YYDELETEVAL(*pv,2);",
  709. " }",
  710. "",
  711. " YYPOSN *pp;",
  712. " for(pp=yyps->ps; pp<yyps->psp; pp++) {",
  713. " YYDELETEPOSN(*pp,2);",
  714. " }",
  715. "",
  716. " while (yyps) {",
  717. " yyparsestate *save = yyps;",
  718. " yyps = save->save;",
  719. " YYFreeState(save);",
  720. " }",
  721. " while (yypath) {",
  722. " yyparsestate *save = yypath;",
  723. " yypath = save->save;",
  724. " YYFreeState(save); ",
  725. " }",
  726. " return (1);",
  727. "",
  728. "",
  729. "yyaccept:",
  730. " if (yyps->save) goto yyvalid;",
  731. " if(yyerrctx) {",
  732. " YYFreeState(yyerrctx); yyerrctx = NULL;",
  733. " }",
  734. " while (yyps) {",
  735. " yyparsestate *save = yyps;",
  736. " yyps = save->save;",
  737. " YYFreeState(save);",
  738. " }",
  739. " while (yypath) {",
  740. " yyparsestate *save = yypath;",
  741. " yypath = save->save;",
  742. " YYFreeState(save); ",
  743. " }",
  744. " return (0);",
  745. "}",
  746. "",
  747. "",
  748. "int YYLex1() {",
  749. " if(yylvp<yylve) {",
  750. " yylval = *yylvp++;",
  751. " yyposn = *yylpp++;",
  752. " return *yylexp++;",
  753. " } else {",
  754. " if(yyps->save) {",
  755. " if(yylvp==yylvlim) {",
  756. "\tyyexpand();",
  757. " }",
  758. " *yylexp = yylex();",
  759. " *yylvp++ = yylval;",
  760. " yylve++;",
  761. " *yylpp++ = yyposn;",
  762. " yylpe++;",
  763. " return *yylexp++;",
  764. " } else {",
  765. " return yylex();",
  766. " }",
  767. " }",
  768. "}",
  769. "",
  770. "int yyexpand() {",
  771. " int p = yylvp-yylvals;",
  772. " int s = yylvlim-yylvals;",
  773. " s += YYSTACKGROWTH;",
  774. " { Yshort *tl = yylexemes; ",
  775. " YYSTYPE *tv = yylvals;",
  776. " YYPOSN *tp = yylpsns;",
  777. " yylvals = new YYSTYPE[s];",
  778. " yylpsns = new YYPOSN[s];",
  779. " yylexemes = new Yshort[s];",
  780. " memcpy(yylexemes, tl, (s-YYSTACKGROWTH)*sizeof(Yshort));",
  781. " YYSCopy(yylvals, tv, s-YYSTACKGROWTH);",
  782. " YYPCopy(yylpsns, tp, s-YYSTACKGROWTH);",
  783. " delete[] tl;",
  784. " delete[] tv;",
  785. " delete[] tp;",
  786. " }",
  787. " yylvp = yylve = yylvals + p;",
  788. " yylvlim = yylvals + s;",
  789. " yylpp = yylpe = yylpsns + p;",
  790. " yylplim = yylpsns + s;",
  791. " yylexp = yylexemes + p;",
  792. " return 0;",
  793. "}",
  794. "",
  795. "void YYSCopy(YYSTYPE *to, YYSTYPE *from, int size) {",
  796. " int i; ",
  797. " for (i = size-1; i >= 0; i--) {",
  798. " to[i] = from[i];",
  799. " }",
  800. "}",
  801. "",
  802. "void YYPCopy(YYPOSN *to, YYPOSN *from, int size) {",
  803. " int i; ",
  804. " for (i = size-1; i >= 0; i--) {",
  805. " to[i] = from[i];",
  806. " }",
  807. "}",
  808. "",
  809. "void YYMoreStack(yyparsestate *yyps) {",
  810. " int p = yyps->ssp - yyps->ss; ",
  811. " Yshort *tss = yyps->ss;",
  812. " YYSTYPE *tvs = yyps->vs;",
  813. " YYPOSN *tps = yyps->ps;",
  814. " yyps->ss = new Yshort [yyps->stacksize + YYSTACKGROWTH]; ",
  815. " yyps->vs = new YYSTYPE[yyps->stacksize + YYSTACKGROWTH]; ",
  816. " yyps->ps = new YYPOSN [yyps->stacksize + YYSTACKGROWTH]; ",
  817. " memcpy(yyps->ss, tss, yyps->stacksize * sizeof(Yshort)); ",
  818. " YYSCopy(yyps->vs, tvs, yyps->stacksize); ",
  819. " YYPCopy(yyps->ps, tps, yyps->stacksize); ",
  820. " yyps->stacksize += YYSTACKGROWTH; ",
  821. " delete[] tss;",
  822. " delete[] tvs;",
  823. " delete[] tps;",
  824. " yyps->ssp = yyps->ss + p; ",
  825. " yyps->vsp = yyps->vs + p; ",
  826. " yyps->psp = yyps->ps + p; ",
  827. "}",
  828. "",
  829. "yyparsestate *YYNewState(int size) {",
  830. " yyparsestate *p = new yyparsestate;",
  831. " p->stacksize = size+4;",
  832. " p->ss = new Yshort [size + 4];",
  833. " p->vs = new YYSTYPE[size + 4];",
  834. " p->ps = new YYPOSN [size + 4];",
  835. " memset(&p->vs[0], 0, (size+4)*sizeof(YYSTYPE));",
  836. " memset(&p->ps[0], 0, (size+4)*sizeof(YYPOSN));",
  837. " return p;",
  838. "}",
  839. "",
  840. "void YYFreeState(yyparsestate *p) {",
  841. " delete[] p->ss;",
  842. " delete[] p->vs;",
  843. " delete[] p->ps;",
  844. " delete p;",
  845. "}",
  846. 0
  847. };
  848. struct section section_list[] = {
  849. { "banner", &banner[0] },
  850. { "tables", &tables[0] },
  851. { "header", &header[0] },
  852. { "body", &body[0] },
  853. { "trailer", &trailer[0] },
  854. { 0, 0 } };