Lpars.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  1. /* LLgen generated code from source . */
  2. #include "Lpars.h"
  3. #define LLNOFIRSTS
  4. #if __STDC__ || __cplusplus
  5. #define LL_ANSI_C 1
  6. #endif
  7. #define LL_LEXI scanner
  8. /* $Id$ */
  9. #ifdef LL_DEBUG
  10. #include <assert.h>
  11. #include <stdio.h>
  12. #define LL_assert(x) assert(x)
  13. #else
  14. #define LL_assert(x) /* nothing */
  15. #endif
  16. extern int LLsymb;
  17. #define LL_SAFE(x) /* Nothing */
  18. #define LL_SSCANDONE(x) if (LLsymb != x) LLsafeerror(x)
  19. #define LL_SCANDONE(x) if (LLsymb != x) LLerror(x)
  20. #define LL_NOSCANDONE(x) LLscan(x)
  21. #ifdef LL_FASTER
  22. #define LLscan(x) if ((LLsymb = LL_LEXI()) != x) LLerror(x)
  23. #endif
  24. extern unsigned int LLscnt[];
  25. extern unsigned int LLtcnt[];
  26. extern int LLcsymb;
  27. #if LL_NON_CORR
  28. extern int LLstartsymb;
  29. #endif
  30. #define LLsdecr(d) {LL_assert(LLscnt[d] > 0); LLscnt[d]--;}
  31. #define LLtdecr(d) {LL_assert(LLtcnt[d] > 0); LLtcnt[d]--;}
  32. #define LLsincr(d) LLscnt[d]++
  33. #define LLtincr(d) LLtcnt[d]++
  34. #if LL_ANSI_C
  35. extern int LL_LEXI(void);
  36. extern void LLread(void);
  37. extern int LLskip(void);
  38. extern int LLnext(int);
  39. extern void LLerror(int);
  40. extern void LLsafeerror(int);
  41. extern void LLnewlevel(unsigned int *);
  42. extern void LLoldlevel(unsigned int *);
  43. #ifndef LL_FASTER
  44. extern void LLscan(int);
  45. #endif
  46. #ifndef LLNOFIRSTS
  47. extern int LLfirst(int, int);
  48. #endif
  49. #if LL_NON_CORR
  50. extern void LLnc_recover(void);
  51. #endif
  52. #else /* not LL_ANSI_C */
  53. extern LLread();
  54. extern int LLskip();
  55. extern int LLnext();
  56. extern LLerror();
  57. extern LLsafeerror();
  58. extern LLnewlevel();
  59. extern LLoldlevel();
  60. #ifndef LL_FASTER
  61. extern LLscan();
  62. #endif
  63. #ifndef LLNOFIRSTS
  64. extern int LLfirst();
  65. #endif
  66. #if LL_NON_CORR
  67. extern LLnc_recover();
  68. #endif
  69. #endif /* not LL_ANSI_C */
  70. #define LL_SSIZE 4
  71. #define LL_NSETS 6
  72. #define LL_NTERMINALS 32
  73. #if LL_ANSI_C
  74. void LL0_spec(void);
  75. #endif
  76. #if LL_ANSI_C
  77. void LLparse(void)
  78. #else
  79. LLparse()
  80. #endif
  81. {
  82. unsigned int s[LL_NTERMINALS+LL_NSETS+2];
  83. LLnewlevel(s);
  84. LLread();
  85. LL0_spec();
  86. LL_SCANDONE(EOFILE);
  87. LLoldlevel(s);
  88. }
  89. static char LLsets[] = {
  90. '\204','\343','\1','\0',
  91. '\234','\4','\176','\354',
  92. '\0','\4','\6','\0',
  93. '\234','\0','\60','\350',
  94. '\10','\0','\0','\340',
  95. '\124','\0','\0','\0',
  96. 0 };
  97. #define LLindex (LL_index+1)
  98. static short LL_index[] = {0,0,
  99. -1,
  100. -1,
  101. -1,
  102. -1,
  103. -1,
  104. -1,
  105. -1,
  106. -1,
  107. -1,
  108. -1,
  109. -1,
  110. -1,
  111. -1,
  112. -1,
  113. -1,
  114. -1,
  115. -1,
  116. -1,
  117. -1,
  118. -1,
  119. -1,
  120. -1,
  121. -1,
  122. -1,
  123. -1,
  124. -1,
  125. -1,
  126. -1,
  127. -1,
  128. -1,
  129. -1,
  130. -1,
  131. -1,
  132. -1,
  133. -1,
  134. -1,
  135. -1,
  136. -1,
  137. -1,
  138. -1,
  139. -1,
  140. 30,
  141. 31,
  142. 23,
  143. -1,
  144. -1,
  145. -1,
  146. -1,
  147. -1,
  148. -1,
  149. -1,
  150. -1,
  151. -1,
  152. -1,
  153. -1,
  154. -1,
  155. -1,
  156. 25,
  157. 24,
  158. -1,
  159. -1,
  160. -1,
  161. 29,
  162. -1,
  163. -1,
  164. -1,
  165. -1,
  166. -1,
  167. -1,
  168. -1,
  169. -1,
  170. -1,
  171. -1,
  172. -1,
  173. -1,
  174. -1,
  175. -1,
  176. -1,
  177. -1,
  178. -1,
  179. -1,
  180. -1,
  181. -1,
  182. -1,
  183. -1,
  184. -1,
  185. -1,
  186. -1,
  187. -1,
  188. -1,
  189. 27,
  190. -1,
  191. 28,
  192. -1,
  193. -1,
  194. -1,
  195. -1,
  196. -1,
  197. -1,
  198. -1,
  199. -1,
  200. -1,
  201. -1,
  202. -1,
  203. -1,
  204. -1,
  205. -1,
  206. -1,
  207. -1,
  208. -1,
  209. -1,
  210. -1,
  211. -1,
  212. -1,
  213. -1,
  214. -1,
  215. -1,
  216. -1,
  217. -1,
  218. -1,
  219. -1,
  220. -1,
  221. -1,
  222. 26,
  223. -1,
  224. -1,
  225. -1,
  226. -1,
  227. -1,
  228. -1,
  229. -1,
  230. -1,
  231. -1,
  232. -1,
  233. -1,
  234. -1,
  235. -1,
  236. -1,
  237. -1,
  238. -1,
  239. -1,
  240. -1,
  241. -1,
  242. -1,
  243. -1,
  244. -1,
  245. -1,
  246. -1,
  247. -1,
  248. -1,
  249. -1,
  250. -1,
  251. -1,
  252. -1,
  253. -1,
  254. -1,
  255. -1,
  256. -1,
  257. -1,
  258. -1,
  259. -1,
  260. -1,
  261. -1,
  262. -1,
  263. -1,
  264. -1,
  265. -1,
  266. -1,
  267. -1,
  268. -1,
  269. -1,
  270. -1,
  271. -1,
  272. -1,
  273. -1,
  274. -1,
  275. -1,
  276. -1,
  277. -1,
  278. -1,
  279. -1,
  280. -1,
  281. -1,
  282. -1,
  283. -1,
  284. -1,
  285. -1,
  286. -1,
  287. -1,
  288. -1,
  289. -1,
  290. -1,
  291. -1,
  292. -1,
  293. -1,
  294. -1,
  295. -1,
  296. -1,
  297. -1,
  298. -1,
  299. -1,
  300. -1,
  301. -1,
  302. -1,
  303. -1,
  304. -1,
  305. -1,
  306. -1,
  307. -1,
  308. -1,
  309. -1,
  310. -1,
  311. -1,
  312. -1,
  313. -1,
  314. -1,
  315. -1,
  316. -1,
  317. -1,
  318. -1,
  319. -1,
  320. -1,
  321. -1,
  322. -1,
  323. -1,
  324. -1,
  325. -1,
  326. -1,
  327. -1,
  328. -1,
  329. -1,
  330. -1,
  331. -1,
  332. -1,
  333. -1,
  334. -1,
  335. -1,
  336. -1,
  337. -1,
  338. -1,
  339. -1,
  340. -1,
  341. -1,
  342. -1,
  343. -1,
  344. -1,
  345. -1,
  346. -1,
  347. -1,
  348. -1,
  349. -1,
  350. -1,
  351. -1,
  352. -1,
  353. -1,
  354. 0,
  355. 1,
  356. 2,
  357. 3,
  358. 4,
  359. 5,
  360. 6,
  361. 7,
  362. 8,
  363. 9,
  364. 10,
  365. 11,
  366. 12,
  367. 13,
  368. 14,
  369. 15,
  370. 16,
  371. 17,
  372. 18,
  373. 19,
  374. 20,
  375. 21,
  376. 22,
  377. 0 };
  378. #define LL_NEWMESS
  379. /*
  380. * Some grammar independent code.
  381. * This file is copied into Lpars.c.
  382. */
  383. #ifndef lint
  384. static char *rcsid = "$Id$";
  385. #endif
  386. unsigned int LLtcnt[LL_NTERMINALS];
  387. unsigned int LLscnt[LL_NSETS];
  388. int LLcsymb, LLsymb;
  389. static int LLlevel;
  390. #if LL_NON_CORR
  391. int LLstartsymb;
  392. static int fake_eof = 0;
  393. #endif
  394. #if LL_ANSI_C
  395. #define LL_VOIDCST (void)
  396. void LLmessage(int);
  397. #else
  398. #define LL_VOIDCST
  399. #endif
  400. #ifdef LL_USERHOOK
  401. #if LL_ANSI_C
  402. static int LLdoskip(int);
  403. static int LLuserhook(int, int*);
  404. #else
  405. static int LLdoskip();
  406. static int LLuserhook();
  407. #endif
  408. #endif
  409. #ifndef LL_FASTER
  410. #if LL_ANSI_C
  411. void LLscan(int t)
  412. #else
  413. LLscan(t)
  414. int t;
  415. #endif
  416. {
  417. /*
  418. * Check if the next symbol is equal to the parameter
  419. */
  420. #if LL_NON_CORR
  421. /* See if the error recovery has eaten an eof */
  422. if (fake_eof) {
  423. LLsymb = EOFILE;
  424. fake_eof = 0;
  425. }
  426. else {
  427. LLsymb = LL_LEXI();
  428. }
  429. if (LLsymb == t) {
  430. #else
  431. if ((LLsymb = LL_LEXI()) == t) {
  432. #endif
  433. #if LL_NON_CORR
  434. /* Check if a previous parser has 'crashed', in that
  435. * case continue with non-correcting parser
  436. */
  437. if (err_seen && !nc_done) {
  438. LLnc_recover();
  439. nc_done = 1;
  440. /* Remember that the error recovery has eaten an eof */
  441. fake_eof = 1;
  442. if (t != LLsymb) {
  443. LLerror(t);
  444. }
  445. else
  446. return;
  447. }
  448. #endif
  449. return;
  450. }
  451. /*
  452. * If we come here, an error has been detected
  453. */
  454. LLerror(t);
  455. }
  456. #endif
  457. #if LL_ANSI_C
  458. void LLread(void) {
  459. #else
  460. LLread() {
  461. #endif
  462. #if LL_NON_CORR
  463. /* Again, check if another parser has crashed,
  464. * in that case intercept and go to the
  465. * non-correcting parser
  466. */
  467. if (err_seen && !nc_done) {
  468. LLnc_recover();
  469. nc_done = 1;
  470. /* Pretend we read end of file */
  471. LLsymb = EOFILE;
  472. LLcsymb = LLindex[EOFILE];
  473. fake_eof = 0;
  474. return;
  475. }
  476. if (fake_eof) {
  477. LLsymb = EOFILE;
  478. LLcsymb = LLindex[EOFILE];
  479. fake_eof = 0;
  480. return;
  481. }
  482. #endif
  483. for (;;) {
  484. if ((LLcsymb = LLindex[(LLsymb = LL_LEXI())]) >= 0) return;
  485. LLmessage(0);
  486. }
  487. /* NOTREACHED */
  488. }
  489. #if LL_ANSI_C
  490. void LLerror(int t)
  491. #else
  492. LLerror(t)
  493. int t;
  494. #endif
  495. {
  496. register int i;
  497. if (t == EOFILE && LLsymb <= 0) return;
  498. #ifdef LL_NEWMESS
  499. if (t == EOFILE) {
  500. #ifdef LL_USERHOOK
  501. static int lst[] = { EOFILE, 0 };
  502. LL_VOIDCST LLuserhook(EOFILE, lst);
  503. #endif /* LL_USERHOOK */
  504. if (LLsymb != EOFILE && LLsymb > 0) {
  505. LLmessage(-1);
  506. while ((LLsymb = LL_LEXI()) > 0 && LLsymb != EOFILE)
  507. /* nothing */ ;
  508. }
  509. return;
  510. }
  511. #endif
  512. #if LL_NON_CORR
  513. if ((!nc_done) && (LLsymb > 0) && (LLsymb != EOFILE)) {
  514. LLmessage(0);
  515. LLnc_recover();
  516. nc_done = 1;
  517. LLsymb = EOFILE;
  518. }
  519. #endif
  520. if ((LLcsymb = LLindex[LLsymb]) < 0) {
  521. LLmessage(0);
  522. LLread();
  523. }
  524. i = LLindex[t];
  525. LLtcnt[i]++;
  526. #ifdef LL_USERHOOK
  527. LL_VOIDCST LLdoskip(t);
  528. #else
  529. LL_VOIDCST LLskip();
  530. #endif
  531. LLtcnt[i]--;
  532. if (LLsymb != t) {
  533. #if LL_NON_CORR
  534. /* A little kludge here; when using non-correcting recovery
  535. * it can happen that a program is correct but incomplete.
  536. * Here, we test this, and make sure the appropriate
  537. * message is generated
  538. */
  539. if (! nc_done) {
  540. int oldLLsymb;
  541. oldLLsymb = LLsymb;
  542. LLsymb = EOFILE;
  543. LLmessage(0);
  544. nc_done = 1;
  545. /* Not really, but to prevent more than 1 error message */
  546. LLsymb = oldLLsymb;
  547. }
  548. #endif
  549. LLmessage(t);
  550. }
  551. }
  552. #if LL_ANSI_C
  553. void LLsafeerror(int t)
  554. #else
  555. LLsafeerror(t)
  556. int t;
  557. #endif
  558. {
  559. if (t == EOFILE && LLsymb <= 0) return;
  560. #ifdef LL_NEWMESS
  561. if (t == EOFILE) {
  562. #ifdef LL_USERHOOK
  563. static int lst[] = { EOFILE, 0 };
  564. LL_VOIDCST LLuserhook(EOFILE, lst);
  565. #endif /* LL_USERHOOK */
  566. if (LLsymb != EOFILE && LLsymb > 0) {
  567. LLmessage(-1);
  568. while ((LLsymb = LL_LEXI()) > 0 && LLsymb != EOFILE)
  569. /* nothing */ ;
  570. }
  571. return;
  572. }
  573. #endif
  574. #if LL_NON_CORR
  575. if ((!nc_done) && (LLsymb > 0) && (LLsymb != EOFILE)) {
  576. LLmessage(0);
  577. LLnc_recover();
  578. nc_done = 1;
  579. LLsymb = EOFILE;
  580. }
  581. /* A little kludge here; when using non-correcting recovery
  582. * it can happen that a program is correct but incomplete.
  583. * Here, we test this, and make sure the appropriate
  584. * message is generated
  585. */
  586. if (! nc_done) {
  587. int oldLLsymb;
  588. oldLLsymb = LLsymb;
  589. LLsymb = EOFILE;
  590. LLmessage(0);
  591. nc_done = 1;
  592. /* Not really, but to prevent more than 1 error message */
  593. LLsymb = oldLLsymb;
  594. }
  595. #endif
  596. LLmessage(t);
  597. }
  598. #ifndef LLNOFIRSTS
  599. #if LL_ANSI_C
  600. int LLfirst(int x, int d) {
  601. #else
  602. int LLfirst(x, d) {
  603. #endif
  604. register int i;
  605. return (i = LLindex[x]) >= 0 &&
  606. (LLsets[d + (i >> 3)] & (1 << (i & 07)));
  607. }
  608. #endif
  609. #if LL_ANSI_C
  610. int LLnext(int n)
  611. #else
  612. int LLnext(n)
  613. int n;
  614. #endif
  615. {
  616. /* returns: 0 if the current symbol is'nt skipped, and it
  617. is'nt a member of "n",
  618. 1 if we have a new symbol, but it is'nt a member,
  619. 2 if the current symbol is a member,
  620. and 3 if we have a new symbol and it is a member.
  621. So, the low order bit indicates wether we have a new symbol,
  622. and the next bit indicates wether it is a member of "n".
  623. */
  624. int retval = 0;
  625. if (LLskip()) retval = 1;
  626. if (n <= 0 && LLsets[(LLcsymb >> 3) - n] & (1 << (LLcsymb & 07))) {
  627. retval |= 2;
  628. }
  629. else if (n > 0 && LLcsymb == LLindex[n]) retval |= 2;
  630. return retval;
  631. }
  632. #if LL_ANSI_C
  633. int LLskip(void) {
  634. #else
  635. int LLskip() {
  636. #endif
  637. /* returns 0 if the current symbol is'nt skipped, and
  638. 1 if it is, t.i., we have a new symbol
  639. */
  640. #ifdef LL_USERHOOK
  641. return LLdoskip(0);
  642. }
  643. #if LL_ANSI_C
  644. extern void LL_USERHOOK(int, int *);
  645. static int LLuserhook(int e, int *list)
  646. #else
  647. static int LLuserhook(e, list)
  648. int e;
  649. int *list;
  650. #endif
  651. {
  652. int old = LLsymb;
  653. LL_USERHOOK(e, list);
  654. LLread();
  655. return LLsymb != old;
  656. }
  657. #if LL_ANSI_C
  658. static void LLmklist(register int *list)
  659. #else
  660. static LLmklist(list)
  661. register int *list;
  662. #endif
  663. {
  664. char Xset[LL_SSIZE];
  665. register char *p;
  666. register int i;
  667. for (p = &Xset[0]; p < &Xset[LL_SSIZE]; ) *p++ = 0;
  668. for (i = 0; i < LL_NTERMINALS; i++) {
  669. if (LLtcnt[i] != 0) Xset[i >> 3] |= (1 << (i & 07));
  670. }
  671. for (i = LL_NSETS - 1; i >= 0; i--) if (LLscnt[i] != 0) {
  672. register char *q = &LLsets[LL_SSIZE * i];
  673. p = &Xset[0];
  674. while (p < &Xset[LL_SSIZE]) *p++ |= *q++;
  675. }
  676. for (i = 0; i < LL_NTERMINALS; i++) {
  677. if (Xset[i >> 3] & (1 << (i & 07))) {
  678. *list++ = LLtok[i];
  679. }
  680. }
  681. *list = 0;
  682. }
  683. #if LL_ANSI_C
  684. static int LLdoskip(int e)
  685. #else
  686. static int LLdoskip(e)
  687. int e;
  688. #endif
  689. {
  690. int LLx;
  691. int list[LL_NTERMINALS+1];
  692. #endif /* LL_USERHOOK */
  693. register int i;
  694. int retval;
  695. int LLi, LLb;
  696. retval = 0;
  697. #ifdef LL_USERHOOK
  698. LLmklist(list);
  699. LLx = LLuserhook(e, list);
  700. if (LLx) retval = 1;
  701. #endif /* LL_USERHOOK */
  702. for (;;) {
  703. if (LLtcnt[LLcsymb] != 0) {
  704. #ifdef LL_USERHOOK
  705. if (!e || !LLx || LLcsymb == LLindex[e])
  706. #endif
  707. return retval;
  708. }
  709. LLi = LLcsymb >> 3;
  710. LLb = 1 << (LLcsymb & 07);
  711. for (i = LL_NSETS - 1; i >= 0; i--) {
  712. if (LLscnt[i] != 0) {
  713. if (LLsets[LL_SSIZE*i+LLi] & LLb) {
  714. #ifdef LL_USERHOOK
  715. if (!e || !LLx || LLcsymb == LLindex[e])
  716. #endif
  717. return retval;
  718. }
  719. }
  720. }
  721. #ifdef LL_USERHOOK
  722. if (LLx) {
  723. LLx = LLuserhook(e, list);
  724. continue;
  725. }
  726. #endif /* LL_USERHOOK */
  727. #if LL_NON_CORR
  728. if ((!nc_done) && (LLsymb > 0)) {
  729. LLmessage(0);
  730. LLnc_recover();
  731. nc_done = 1;
  732. fake_eof = 1;
  733. }
  734. else {
  735. LLmessage(0);
  736. }
  737. #else
  738. LLmessage(0);
  739. #endif
  740. retval = 1;
  741. LLread();
  742. }
  743. /* NOTREACHED */
  744. }
  745. #if LL_ANSI_C
  746. void LLnewlevel(unsigned int *LLsinfo) {
  747. #else
  748. LLnewlevel(LLsinfo) unsigned int *LLsinfo; {
  749. #endif
  750. register int i;
  751. if (LLlevel++) {
  752. LLsinfo[LL_NSETS+LL_NTERMINALS] = (unsigned) LLsymb;
  753. LLsinfo[LL_NSETS+LL_NTERMINALS+1] = (unsigned) LLcsymb;
  754. for (i = LL_NTERMINALS - 1; i >= 0; i--) {
  755. LLsinfo[i] = LLtcnt[i];
  756. LLtcnt[i] = 0;
  757. }
  758. for (i = LL_NSETS - 1; i >= 0; i--) {
  759. LLsinfo[LL_NTERMINALS+i] = LLscnt[i];
  760. LLscnt[i] = 0;
  761. }
  762. }
  763. LLtincr(0);
  764. }
  765. #if LL_ANSI_C
  766. void LLoldlevel(unsigned int *LLsinfo) {
  767. #else
  768. LLoldlevel(LLsinfo) unsigned int *LLsinfo; {
  769. #endif
  770. register int i;
  771. LLtdecr(0);
  772. #ifdef LL_DEBUG
  773. for (i = 0; i < LL_NTERMINALS; i++) LL_assert(LLtcnt[i] == 0);
  774. for (i = 0; i < LL_NSETS; i++) LL_assert(LLscnt[i] == 0);
  775. #endif
  776. if (--LLlevel) {
  777. for (i = LL_NSETS - 1; i >= 0; i--) {
  778. LLscnt[i] = LLsinfo[LL_NTERMINALS+i];
  779. }
  780. for (i = LL_NTERMINALS - 1; i >= 0; i--) {
  781. LLtcnt[i] = LLsinfo[i];
  782. }
  783. LLsymb = (int) LLsinfo[LL_NSETS+LL_NTERMINALS];
  784. LLcsymb = (int) LLsinfo[LL_NSETS+LL_NTERMINALS+1];
  785. }
  786. }