LLgen.c 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415
  1. /* LLgen generated code from source LLgen.g */
  2. #include "Lpars.h"
  3. #define LL_LEXI scanner
  4. #define LLNOFIRSTS
  5. #if __STDC__ || __cplusplus
  6. #define LL_ANSI_C 1
  7. #endif
  8. #define LL_LEXI scanner
  9. /* $Id$ */
  10. #ifdef LL_DEBUG
  11. #include <assert.h>
  12. #include <stdio.h>
  13. #define LL_assert(x) assert(x)
  14. #else
  15. #define LL_assert(x) /* nothing */
  16. #endif
  17. extern int LLsymb;
  18. #define LL_SAFE(x) /* Nothing */
  19. #define LL_SSCANDONE(x) if (LLsymb != x) LLsafeerror(x)
  20. #define LL_SCANDONE(x) if (LLsymb != x) LLerror(x)
  21. #define LL_NOSCANDONE(x) LLscan(x)
  22. #ifdef LL_FASTER
  23. #define LLscan(x) if ((LLsymb = LL_LEXI()) != x) LLerror(x)
  24. #endif
  25. extern unsigned int LLscnt[];
  26. extern unsigned int LLtcnt[];
  27. extern int LLcsymb;
  28. #if LL_NON_CORR
  29. extern int LLstartsymb;
  30. #endif
  31. #define LLsdecr(d) {LL_assert(LLscnt[d] > 0); LLscnt[d]--;}
  32. #define LLtdecr(d) {LL_assert(LLtcnt[d] > 0); LLtcnt[d]--;}
  33. #define LLsincr(d) LLscnt[d]++
  34. #define LLtincr(d) LLtcnt[d]++
  35. #if LL_ANSI_C
  36. extern int LL_LEXI(void);
  37. extern void LLread(void);
  38. extern int LLskip(void);
  39. extern int LLnext(int);
  40. extern void LLerror(int);
  41. extern void LLsafeerror(int);
  42. extern void LLnewlevel(unsigned int *);
  43. extern void LLoldlevel(unsigned int *);
  44. #ifndef LL_FASTER
  45. extern void LLscan(int);
  46. #endif
  47. #ifndef LLNOFIRSTS
  48. extern int LLfirst(int, int);
  49. #endif
  50. #if LL_NON_CORR
  51. extern void LLnc_recover(void);
  52. #endif
  53. #else /* not LL_ANSI_C */
  54. extern LLread();
  55. extern int LLskip();
  56. extern int LLnext();
  57. extern LLerror();
  58. extern LLsafeerror();
  59. extern LLnewlevel();
  60. extern LLoldlevel();
  61. #ifndef LL_FASTER
  62. extern LLscan();
  63. #endif
  64. #ifndef LLNOFIRSTS
  65. extern int LLfirst();
  66. #endif
  67. #if LL_NON_CORR
  68. extern LLnc_recover();
  69. #endif
  70. #endif /* not LL_ANSI_C */
  71. # line 20 "LLgen.g"
  72. # include <stdlib.h>
  73. # include <string.h>
  74. # include "types.h"
  75. # include "io.h"
  76. # include "extern.h"
  77. # include "assert.h"
  78. # include "cclass.h"
  79. # ifndef NORCSID
  80. static string rcsid = "$Id$";
  81. # endif
  82. p_mem alloc(), ralloc();
  83. string store();
  84. p_gram search();
  85. long ftell();
  86. static int acount; /* count #of global actions */
  87. static p_term t_list;
  88. static int t_cnt;
  89. static p_gram alt_table;
  90. static int n_alts;
  91. static int max_alts;
  92. #define ALTINCR 32
  93. static p_gram rule_table;
  94. static int n_rules;
  95. static int max_rules;
  96. #define RULEINCR 32
  97. /* Here are defined : */
  98. STATIC newnorder();
  99. STATIC newtorder();
  100. STATIC mkalt();
  101. STATIC mkterm();
  102. STATIC p_gram copyrule();
  103. /* and of course LLparse() */
  104. STATIC
  105. newnorder(index) {
  106. static int porder;
  107. if (norder != -1) {
  108. nonterms[porder].n_next = index;
  109. }
  110. else norder = index;
  111. porder = index;
  112. nonterms[porder].n_next = -1;
  113. }
  114. STATIC
  115. newtorder(index) {
  116. static int porder;
  117. if (torder != -1) {
  118. tokens[porder].t_next = index;
  119. }
  120. else torder = index;
  121. porder = index;
  122. tokens[porder].t_next = -1;
  123. }
  124. p_init()
  125. {
  126. alt_table = (p_gram )alloc(ALTINCR*sizeof(t_gram));
  127. n_alts = 0;
  128. max_alts = ALTINCR;
  129. rule_table = (p_gram )alloc(RULEINCR*sizeof(t_gram));
  130. n_rules = 0;
  131. max_rules = RULEINCR;
  132. }
  133. #if LL_ANSI_C
  134. static void LL1_def(void);
  135. static void LL2_rule(void);
  136. static void LL3_listel(void);
  137. static void LL4_firsts(void);
  138. static void LL5_productions(
  139. # line 246 "LLgen.g"
  140. p_gram *p) ;
  141. static void LL6_simpleproduction(
  142. # line 332 "LLgen.g"
  143. p_gram *p ,register int *conflres) ;
  144. static void LL7_elem(
  145. # line 480 "LLgen.g"
  146. register p_gram pres) ;
  147. static void LL8_repeats(
  148. # line 602 "LLgen.g"
  149. int *kind ,int *cnt) ;
  150. static void LL9_number(
  151. # line 619 "LLgen.g"
  152. int *t) ;
  153. #else
  154. static LL1_def();
  155. static LL2_rule();
  156. static LL3_listel();
  157. static LL4_firsts();
  158. static LL5_productions();
  159. static LL6_simpleproduction();
  160. static LL7_elem();
  161. static LL8_repeats();
  162. static LL9_number();
  163. #endif
  164. #if LL_ANSI_C
  165. void
  166. #endif
  167. LL0_spec(
  168. #if LL_ANSI_C
  169. void
  170. #endif
  171. ) {
  172. LLsincr(0);
  173. # line 96 "LLgen.g"
  174. { acount = 0; p_init(); }
  175. for (;;) {
  176. goto L_1;
  177. L_1 : {switch(LLcsymb) {
  178. case /* EOFILE */ 0 : ;
  179. break;
  180. default:{int LL_1=LLnext(0);
  181. ;if (!LL_1) {
  182. break;
  183. }
  184. else if (LL_1 & 1) goto L_1;}
  185. case /* C_IDENT */ 2 : ;
  186. case /* C_ACTION */ 7 : ;
  187. case /* C_TOKEN */ 8 : ;
  188. case /* C_START */ 9 : ;
  189. case /* C_FIRST */ 13 : ;
  190. case /* C_LEXICAL */ 14 : ;
  191. case /* C_PREFIX */ 15 : ;
  192. case /* C_ONERROR */ 16 : ;
  193. LL1_def();
  194. LLread();
  195. continue;
  196. }
  197. }
  198. LLsdecr(0);
  199. break;
  200. }
  201. # line 98 "LLgen.g"
  202. { /*
  203. * Put an endmarker in temporary file
  204. */
  205. putc('\0', fact);
  206. putc('\0', fact);
  207. free((p_mem) rule_table);
  208. free((p_mem) alt_table);
  209. }
  210. }
  211. static
  212. #if LL_ANSI_C
  213. void
  214. #endif
  215. LL1_def(
  216. #if LL_ANSI_C
  217. void
  218. #endif
  219. ) {
  220. # line 108 "LLgen.g"
  221. register string p;
  222. switch(LLcsymb) {
  223. case /* C_IDENT */ 2 : ;
  224. LL2_rule();
  225. break;
  226. case /* C_TOKEN */ 8 : ;
  227. LLtincr(23);
  228. LLtincr(24);
  229. LL_SAFE(C_TOKEN);
  230. LL3_listel();
  231. LLread();
  232. for (;;) {
  233. goto L_4;
  234. L_4 : {switch(LLcsymb) {
  235. case /* ';' */ 24 : ;
  236. break;
  237. default:{int LL_2=LLnext(44);
  238. ;if (!LL_2) {
  239. break;
  240. }
  241. else if (LL_2 & 1) goto L_4;}
  242. case /* ',' */ 23 : ;
  243. LL_SAFE(',');
  244. LL3_listel();
  245. LLread();
  246. continue;
  247. }
  248. }
  249. LLtdecr(23);
  250. break;
  251. }
  252. LLtdecr(24);
  253. LL_SSCANDONE(';');
  254. break;
  255. case /* C_START */ 9 : ;
  256. LLtincr(23);
  257. LLtincr(2);
  258. LLtincr(24);
  259. LL_SAFE(C_START);
  260. LL_NOSCANDONE(C_IDENT);
  261. # line 118 "LLgen.g"
  262. { p = store(lextoken.t_string); }
  263. LLtdecr(23);
  264. LL_NOSCANDONE(',');
  265. LLtdecr(2);
  266. LL_NOSCANDONE(C_IDENT);
  267. # line 123 "LLgen.g"
  268. { /*
  269. * Put the declaration in the list
  270. * of start symbols
  271. */
  272. register p_gram temp;
  273. register p_start ff;
  274. temp = search(NONTERM,lextoken.t_string,BOTH);
  275. ff = (p_start) alloc(sizeof(t_start));
  276. ff->ff_nont = g_getcont(temp);
  277. ff->ff_name = p;
  278. ff->ff_next = start;
  279. start = ff;
  280. while (ff = ff->ff_next) {
  281. if (! strcmp(p, ff->ff_name)) {
  282. error(linecount, "\"%s\" already used in a %%start", p);
  283. break;
  284. }
  285. }
  286. }
  287. LLtdecr(24);
  288. LL_NOSCANDONE(';');
  289. break;
  290. case /* C_LEXICAL */ 14 : ;
  291. LLtincr(24);
  292. LL_SAFE(C_LEXICAL);
  293. LL_NOSCANDONE(C_IDENT);
  294. # line 149 "LLgen.g"
  295. { if (!lexical) {
  296. lexical = store(lextoken.t_string);
  297. }
  298. else error(linecount,"Duplicate %%lexical");
  299. }
  300. LLtdecr(24);
  301. LL_NOSCANDONE(';');
  302. break;
  303. case /* C_PREFIX */ 15 : ;
  304. LLtincr(24);
  305. LL_SAFE(C_PREFIX);
  306. LL_NOSCANDONE(C_IDENT);
  307. # line 159 "LLgen.g"
  308. { if (!prefix) {
  309. prefix = store(lextoken.t_string);
  310. if (strlen(prefix) > 6) {
  311. error(linecount,
  312. "%%prefix too long");
  313. prefix[6] = 0;
  314. }
  315. }
  316. else error(linecount,"Duplicate %%prefix");
  317. }
  318. LLtdecr(24);
  319. LL_NOSCANDONE(';');
  320. break;
  321. case /* C_ONERROR */ 16 : ;
  322. LLtincr(24);
  323. LL_SAFE(C_ONERROR);
  324. LL_NOSCANDONE(C_IDENT);
  325. # line 171 "LLgen.g"
  326. {
  327. #ifdef NON_CORRECTING
  328. if (non_corr) {
  329. warning(linecount, "%%onerror conflicts with -n option");
  330. }
  331. else
  332. #endif
  333. if (! onerror) {
  334. onerror = store(lextoken.t_string);
  335. }
  336. else error(linecount,"Duplicate %%onerror");
  337. }
  338. LLtdecr(24);
  339. LL_NOSCANDONE(';');
  340. break;
  341. default:
  342. LL_SSCANDONE(C_ACTION);
  343. # line 184 "LLgen.g"
  344. { acount++; }
  345. break;
  346. case /* C_FIRST */ 13 : ;
  347. LL4_firsts();
  348. break;
  349. }
  350. }
  351. static
  352. #if LL_ANSI_C
  353. void
  354. #endif
  355. LL3_listel(
  356. #if LL_ANSI_C
  357. void
  358. #endif
  359. ) {
  360. LL_NOSCANDONE(C_IDENT);
  361. # line 194 "LLgen.g"
  362. { p_gram temp = search(TERMINAL,lextoken.t_string,ENTERING);
  363. newtorder(g_getcont(temp));
  364. tokens[g_getcont(temp)].t_lineno = linecount;
  365. }
  366. }
  367. static
  368. #if LL_ANSI_C
  369. void
  370. #endif
  371. LL2_rule(
  372. #if LL_ANSI_C
  373. void
  374. #endif
  375. ) {
  376. # line 200 "LLgen.g"
  377. register p_nont p;
  378. p_gram rr;
  379. register p_gram temp;
  380. LLtincr(6);
  381. LLtincr(7);
  382. LLtincr(25);
  383. LLsincr(1);
  384. LLtincr(24);
  385. LL_SAFE(C_IDENT);
  386. # line 207 "LLgen.g"
  387. { temp = search(NONTERM,lextoken.t_string,BOTH);
  388. p = &nonterms[g_getcont(temp)];
  389. if (p->n_rule) {
  390. error(linecount,
  391. "Nonterminal %s already defined", lextoken.t_string);
  392. }
  393. /*
  394. * Remember the order in which the nonterminals
  395. * were defined. Code must be generated in that
  396. * order to keep track with the actions on the
  397. * temporary file
  398. */
  399. newnorder(p - nonterms);
  400. p->n_count = acount;
  401. acount = 0;
  402. p->n_lineno = linecount;
  403. p->n_off = ftell(fact);
  404. }
  405. LLread();
  406. goto L_1;
  407. L_1 : {switch(LLcsymb) {
  408. case /* C_ACTION */ 7 : ;
  409. case /* ':' */ 25 : ;
  410. LLtdecr(6);
  411. break;
  412. default:{int LL_3=LLnext(262);
  413. ;if (!LL_3) {
  414. LLtdecr(6);
  415. break;
  416. }
  417. else if (LL_3 & 1) goto L_1;}
  418. case /* C_PARAMS */ 6 : ;
  419. LLtdecr(6);
  420. LL_SAFE(C_PARAMS);
  421. # line 225 "LLgen.g"
  422. { if (lextoken.t_num > 0) {
  423. p->n_flags |= PARAMS;
  424. if (lextoken.t_num > 15) {
  425. error(linecount,"Too many parameters");
  426. }
  427. else setntparams(p,lextoken.t_num);
  428. }
  429. }
  430. LLread();
  431. }
  432. }
  433. goto L_2;
  434. L_2 : {switch(LLcsymb) {
  435. case /* ':' */ 25 : ;
  436. LLtdecr(7);
  437. break;
  438. default:{int LL_4=LLnext(263);
  439. ;if (!LL_4) {
  440. LLtdecr(7);
  441. break;
  442. }
  443. else if (LL_4 & 1) goto L_2;}
  444. case /* C_ACTION */ 7 : ;
  445. LLtdecr(7);
  446. LL_SAFE(C_ACTION);
  447. # line 234 "LLgen.g"
  448. { p->n_flags |= LOCALS; }
  449. LLread();
  450. }
  451. }
  452. LLtdecr(25);
  453. LL_SCANDONE(':');
  454. # line 236 "LLgen.g"
  455. { in_production = 1; }
  456. LLread();
  457. LLsdecr(1);
  458. LL5_productions(
  459. # line 237 "LLgen.g"
  460. &rr);
  461. LLtdecr(24);
  462. LL_SCANDONE(';');
  463. # line 238 "LLgen.g"
  464. { in_production = 0; }
  465. # line 243 "LLgen.g"
  466. { nonterms[g_getcont(temp)].n_rule = rr;}
  467. }
  468. static
  469. #if LL_ANSI_C
  470. void
  471. #endif
  472. LL5_productions(
  473. #if LL_ANSI_C
  474. # line 246 "LLgen.g"
  475. p_gram *p)
  476. #else
  477. # line 246 "LLgen.g"
  478. p) p_gram *p;
  479. #endif
  480. {
  481. # line 250 "LLgen.g"
  482. p_gram prod;
  483. int conflres = 0;
  484. int t = 0;
  485. int haddefault = 0;
  486. int altcnt = 0;
  487. int o_lc, n_lc;
  488. LLtincr(26);
  489. # line 257 "LLgen.g"
  490. { o_lc = linecount; }
  491. LL6_simpleproduction(
  492. # line 258 "LLgen.g"
  493. p,&conflres);
  494. # line 259 "LLgen.g"
  495. { if (conflres & DEF) haddefault = 1; }
  496. goto L_2; /* so that the label is used for certain */
  497. L_2: ;
  498. switch(LLcsymb) {
  499. case /* '|' */ 26 : ;
  500. LLtdecr(26);
  501. LLsincr(1);
  502. LLsdecr(1);
  503. LLtincr(26);
  504. for (;;) {
  505. LL_SAFE('|');
  506. # line 261 "LLgen.g"
  507. { n_lc = linecount; }
  508. LLread();
  509. LL6_simpleproduction(
  510. # line 262 "LLgen.g"
  511. &prod,&t);
  512. # line 263 "LLgen.g"
  513. { if (n_alts >= max_alts-2) {
  514. alt_table = (p_gram ) ralloc(
  515. (p_mem) alt_table,
  516. (unsigned)(max_alts+=ALTINCR)*sizeof(t_gram));
  517. }
  518. if (t & DEF) {
  519. if (haddefault) {
  520. error(n_lc,
  521. "More than one %%default in alternation");
  522. }
  523. haddefault = 1;
  524. }
  525. mkalt(*p,conflres,o_lc,&alt_table[n_alts++]);
  526. altcnt++;
  527. o_lc = n_lc;
  528. conflres = t;
  529. t = 0;
  530. *p = prod;
  531. }
  532. goto L_4;
  533. L_4 : {switch(LLcsymb) {
  534. case /* ';' */ 24 : ;
  535. case /* ']' */ 28 : ;
  536. break;
  537. default:{int LL_5=LLnext(124);
  538. ;if (!LL_5) {
  539. break;
  540. }
  541. else if (LL_5 & 1) goto L_4;}
  542. case /* '|' */ 26 : ;
  543. continue;
  544. }
  545. }
  546. LLtdecr(26);
  547. break;
  548. }
  549. # line 282 "LLgen.g"
  550. { if (conflres & (COND|PREFERING|AVOIDING)) {
  551. error(n_lc,
  552. "Resolver on last alternative not allowed");
  553. }
  554. mkalt(*p,conflres,n_lc,&alt_table[n_alts++]);
  555. altcnt++;
  556. g_settype((&alt_table[n_alts]),EORULE);
  557. *p = copyrule(&alt_table[n_alts-altcnt],altcnt+1);
  558. }
  559. break;
  560. case /* ';' */ 24 : ;
  561. case /* ']' */ 28 : ;
  562. goto L_3;
  563. L_3: ;
  564. LLtdecr(26);
  565. # line 292 "LLgen.g"
  566. { if (conflres & (COND|PREFERING|AVOIDING)) {
  567. error(o_lc,
  568. "No alternation conflict resolver allowed here");
  569. }
  570. /*
  571. if (conflres & DEF) {
  572. error(o_lc,
  573. "No %%default allowed here");
  574. }
  575. */
  576. }
  577. break;
  578. default: if (LLskip()) goto L_2;
  579. goto L_3;
  580. }
  581. # line 304 "LLgen.g"
  582. { n_alts -= altcnt; }
  583. }
  584. # line 306 "LLgen.g"
  585. STATIC
  586. mkalt(prod,condition,lc,res) p_gram prod; register p_gram res; {
  587. /*
  588. * Create an alternation and initialise it.
  589. */
  590. register p_link l;
  591. static p_link list;
  592. static int cnt;
  593. if (! cnt) {
  594. cnt = 50;
  595. list = (p_link) alloc(50 * sizeof(t_link));
  596. }
  597. cnt--;
  598. l = list++;
  599. l->l_rule = prod;
  600. l->l_flag = condition;
  601. g_setlink(res,l);
  602. g_settype(res,ALTERNATION);
  603. res->g_lineno = lc;
  604. nalts++;
  605. }
  606. static
  607. #if LL_ANSI_C
  608. void
  609. #endif
  610. LL6_simpleproduction(
  611. #if LL_ANSI_C
  612. # line 332 "LLgen.g"
  613. p_gram *p ,register int *conflres)
  614. #else
  615. # line 332 "LLgen.g"
  616. p,conflres) p_gram *p; register int *conflres;
  617. #endif
  618. {
  619. # line 333 "LLgen.g"
  620. t_gram elem;
  621. int elmcnt = 0;
  622. int cnt, kind;
  623. int termdeleted = 0;
  624. LLtincr(19);
  625. LLsincr(2);
  626. LLtincr(22);
  627. LLsincr(3);
  628. goto L_1;
  629. L_1 : {switch(LLcsymb) {
  630. case /* C_IDENT */ 2 : ;
  631. case /* C_LITERAL */ 4 : ;
  632. case /* C_ACTION */ 7 : ;
  633. case /* C_IF */ 10 : ;
  634. case /* C_AVOID */ 17 : ;
  635. case /* C_PREFER */ 18 : ;
  636. case /* C_SUBSTART */ 20 : ;
  637. case /* C_ERRONEOUS */ 21 : ;
  638. case /* C_ILLEGAL */ 22 : ;
  639. case /* ';' */ 24 : ;
  640. case /* '|' */ 26 : ;
  641. case /* '[' */ 27 : ;
  642. case /* ']' */ 28 : ;
  643. LLtdecr(19);
  644. break;
  645. default:{int LL_6=LLnext(275);
  646. ;if (!LL_6) {
  647. LLtdecr(19);
  648. break;
  649. }
  650. else if (LL_6 & 1) goto L_1;}
  651. case /* C_DEFAULT */ 19 : ;
  652. LLtdecr(19);
  653. LL_SAFE(C_DEFAULT);
  654. # line 338 "LLgen.g"
  655. { *conflres |= DEF; }
  656. LLread();
  657. }
  658. }
  659. goto L_2;
  660. L_2 : {switch(LLcsymb) {
  661. case /* C_IDENT */ 2 : ;
  662. case /* C_LITERAL */ 4 : ;
  663. case /* C_ACTION */ 7 : ;
  664. case /* C_SUBSTART */ 20 : ;
  665. case /* C_ERRONEOUS */ 21 : ;
  666. case /* C_ILLEGAL */ 22 : ;
  667. case /* ';' */ 24 : ;
  668. case /* '|' */ 26 : ;
  669. case /* '[' */ 27 : ;
  670. case /* ']' */ 28 : ;
  671. LLsdecr(2);
  672. break;
  673. default:{int LL_7=LLnext(-8);
  674. ;if (!LL_7) {
  675. LLsdecr(2);
  676. break;
  677. }
  678. else if (LL_7 & 1) goto L_2;}
  679. case /* C_IF */ 10 : ;
  680. case /* C_AVOID */ 17 : ;
  681. case /* C_PREFER */ 18 : ;
  682. LLsdecr(2);
  683. switch(LLcsymb) {
  684. case /* C_IF */ 10 : ;
  685. LL_SAFE(C_IF);
  686. LL_NOSCANDONE(C_EXPR);
  687. # line 344 "LLgen.g"
  688. { *conflres |= COND; }
  689. break;
  690. default:
  691. LL_SAFE(C_PREFER);
  692. # line 345 "LLgen.g"
  693. { *conflres |= PREFERING; }
  694. break;
  695. case /* C_AVOID */ 17 : ;
  696. LL_SAFE(C_AVOID);
  697. # line 346 "LLgen.g"
  698. { *conflres |= AVOIDING; }
  699. break;
  700. }
  701. LLread();
  702. }
  703. }
  704. goto L_6;
  705. L_6 : {switch(LLcsymb) {
  706. case /* C_IDENT */ 2 : ;
  707. case /* C_LITERAL */ 4 : ;
  708. case /* C_ACTION */ 7 : ;
  709. case /* C_SUBSTART */ 20 : ;
  710. case /* C_ERRONEOUS */ 21 : ;
  711. case /* ';' */ 24 : ;
  712. case /* '|' */ 26 : ;
  713. case /* '[' */ 27 : ;
  714. case /* ']' */ 28 : ;
  715. LLtdecr(22);
  716. break;
  717. default:{int LL_8=LLnext(278);
  718. ;if (!LL_8) {
  719. LLtdecr(22);
  720. break;
  721. }
  722. else if (LL_8 & 1) goto L_6;}
  723. case /* C_ILLEGAL */ 22 : ;
  724. LLtdecr(22);
  725. LL_SAFE(C_ILLEGAL);
  726. # line 348 "LLgen.g"
  727. {
  728. #ifdef NON_CORRECTING
  729. if (n_rules >= max_rules-2) {
  730. rule_table = (p_gram) ralloc(
  731. (p_mem) rule_table,
  732. (unsigned)(max_rules+=RULEINCR)*sizeof(t_gram));
  733. }
  734. elmcnt++;
  735. rule_table[n_rules++] =
  736. *search(TERMINAL, "LLILLEGAL", BOTH);
  737. if (*conflres & DEF) {
  738. error(linecount, "%%illegal not allowed in %%default rule");
  739. }
  740. #endif
  741. }
  742. LLread();
  743. }
  744. }
  745. for (;;) {
  746. goto L_7;
  747. L_7 : {switch(LLcsymb) {
  748. case /* ';' */ 24 : ;
  749. case /* '|' */ 26 : ;
  750. case /* ']' */ 28 : ;
  751. break;
  752. default:{int LL_9=LLnext(-12);
  753. ;if (!LL_9) {
  754. break;
  755. }
  756. else if (LL_9 & 1) goto L_7;}
  757. case /* C_IDENT */ 2 : ;
  758. case /* C_NUMBER */ 3 : ;
  759. case /* C_LITERAL */ 4 : ;
  760. case /* C_ACTION */ 7 : ;
  761. case /* C_SUBSTART */ 20 : ;
  762. case /* C_ERRONEOUS */ 21 : ;
  763. case /* '[' */ 27 : ;
  764. case /* '?' */ 29 : ;
  765. case /* '*' */ 30 : ;
  766. case /* '+' */ 31 : ;
  767. LLsincr(4);
  768. LL7_elem(
  769. # line 364 "LLgen.g"
  770. &elem);
  771. # line 365 "LLgen.g"
  772. { if (n_rules >= max_rules-2) {
  773. rule_table = (p_gram) ralloc(
  774. (p_mem) rule_table,
  775. (unsigned)(max_rules+=RULEINCR)*sizeof(t_gram));
  776. }
  777. kind = FIXED;
  778. cnt = 0;
  779. }
  780. goto L_9; /* so that the label is used for certain */
  781. L_9: ;
  782. switch(LLcsymb) {
  783. case /* C_NUMBER */ 3 : ;
  784. case /* '?' */ 29 : ;
  785. case /* '*' */ 30 : ;
  786. case /* '+' */ 31 : ;
  787. LLsdecr(4);
  788. LL8_repeats(
  789. # line 373 "LLgen.g"
  790. &kind, &cnt);
  791. # line 374 "LLgen.g"
  792. { if (g_gettype(&elem) != TERM) {
  793. rule_table[n_rules] = elem;
  794. g_settype((&rule_table[n_rules+1]),EORULE);
  795. mkterm(copyrule(&rule_table[n_rules],2),
  796. 0,
  797. elem.g_lineno,
  798. &elem);
  799. }
  800. }
  801. break;
  802. case /* C_IDENT */ 2 : ;
  803. case /* C_LITERAL */ 4 : ;
  804. case /* C_ACTION */ 7 : ;
  805. case /* C_SUBSTART */ 20 : ;
  806. case /* C_ERRONEOUS */ 21 : ;
  807. case /* ';' */ 24 : ;
  808. case /* '|' */ 26 : ;
  809. case /* '[' */ 27 : ;
  810. case /* ']' */ 28 : ;
  811. goto L_10;
  812. L_10: ;
  813. LLsdecr(4);
  814. # line 384 "LLgen.g"
  815. { if (g_gettype(&elem) == TERM) {
  816. register p_term q = g_getterm(&elem);
  817. if (! (q->t_flags & RESOLVER) &&
  818. g_gettype(q->t_rule) != ALTERNATION &&
  819. g_gettype(q->t_rule) != EORULE) {
  820. while (g_gettype(q->t_rule) != EORULE) {
  821. rule_table[n_rules++] = *q->t_rule++;
  822. elmcnt++;
  823. if (n_rules >= max_rules-2) {
  824. rule_table = (p_gram) ralloc(
  825. (p_mem) rule_table,
  826. (unsigned)(max_rules+=RULEINCR)*sizeof(t_gram));
  827. }
  828. }
  829. elem = *--(q->t_rule);
  830. n_rules--;
  831. elmcnt--;
  832. if (q == t_list - 1) {
  833. t_list--;
  834. nterms--;
  835. t_cnt++;
  836. }
  837. termdeleted = 1;
  838. }
  839. }
  840. }
  841. break;
  842. default: if (LLskip()) goto L_9;
  843. goto L_10;
  844. }
  845. # line 411 "LLgen.g"
  846. { if (!termdeleted && g_gettype(&elem) == TERM) {
  847. register p_term q;
  848. q = g_getterm(&elem);
  849. r_setkind(q,kind);
  850. r_setnum(q,cnt);
  851. if ((q->t_flags & RESOLVER) &&
  852. (kind == PLUS || kind == FIXED)) {
  853. error(linecount,
  854. "%%while not allowed in this term");
  855. }
  856. /*
  857. * A persistent fixed term is the same
  858. * as a non-persistent fixed term.
  859. * Should we complain?
  860. if ((q->t_flags & PERSISTENT) &&
  861. kind == FIXED) {
  862. error(linecount,
  863. "Illegal %%persistent");
  864. }
  865. */
  866. }
  867. termdeleted = 0;
  868. elmcnt++;
  869. rule_table[n_rules++] = elem;
  870. }
  871. continue;
  872. }
  873. }
  874. LLsdecr(3);
  875. break;
  876. }
  877. # line 437 "LLgen.g"
  878. { register p_term q;
  879. g_settype((&rule_table[n_rules]),EORULE);
  880. *p = 0;
  881. n_rules -= elmcnt;
  882. if (g_gettype(&rule_table[n_rules]) == TERM &&
  883. elmcnt == 1) {
  884. q = g_getterm(&rule_table[n_rules]);
  885. if (r_getkind(q) == FIXED &&
  886. r_getnum(q) == 0) {
  887. *p = q->t_rule;
  888. }
  889. }
  890. if (!*p) *p = copyrule(&rule_table[n_rules],
  891. elmcnt+1);
  892. }
  893. }
  894. # line 454 "LLgen.g"
  895. STATIC
  896. mkterm(prod,flags,lc,result) p_gram prod; register p_gram result; {
  897. /*
  898. * Create a term, initialise it and return
  899. * a grammar element containing it
  900. */
  901. register p_term q;
  902. if (! t_cnt) {
  903. t_cnt = 50;
  904. t_list = (p_term) alloc(50 * sizeof(t_term));
  905. }
  906. t_cnt--;
  907. q = t_list++;
  908. q->t_rule = prod;
  909. q->t_contains = 0;
  910. q->t_flags = flags;
  911. g_settype(result,TERM);
  912. g_setterm(result,q);
  913. result->g_lineno = lc;
  914. nterms++;
  915. }
  916. static
  917. #if LL_ANSI_C
  918. void
  919. #endif
  920. LL7_elem(
  921. #if LL_ANSI_C
  922. # line 480 "LLgen.g"
  923. register p_gram pres)
  924. #else
  925. # line 480 "LLgen.g"
  926. pres) register p_gram pres;
  927. #endif
  928. {
  929. # line 481 "LLgen.g"
  930. register int t = 0;
  931. p_gram p1;
  932. int ln;
  933. p_gram pe;
  934. #ifdef NON_CORRECTING
  935. int erroneous = 0;
  936. #endif
  937. switch(LLcsymb) {
  938. case /* '[' */ 27 : ;
  939. LLtincr(11);
  940. LLtincr(12);
  941. LLsincr(1);
  942. LLtincr(28);
  943. LL_SAFE('[');
  944. # line 489 "LLgen.g"
  945. { ln = linecount; }
  946. LLread();
  947. goto L_4;
  948. L_4 : {switch(LLcsymb) {
  949. case /* C_IDENT */ 2 : ;
  950. case /* C_LITERAL */ 4 : ;
  951. case /* C_ACTION */ 7 : ;
  952. case /* C_IF */ 10 : ;
  953. case /* C_PERSISTENT */ 12 : ;
  954. case /* C_AVOID */ 17 : ;
  955. case /* C_PREFER */ 18 : ;
  956. case /* C_DEFAULT */ 19 : ;
  957. case /* C_SUBSTART */ 20 : ;
  958. case /* C_ERRONEOUS */ 21 : ;
  959. case /* C_ILLEGAL */ 22 : ;
  960. case /* '|' */ 26 : ;
  961. case /* '[' */ 27 : ;
  962. case /* ']' */ 28 : ;
  963. LLtdecr(11);
  964. break;
  965. default:{int LL_10=LLnext(267);
  966. ;if (!LL_10) {
  967. LLtdecr(11);
  968. break;
  969. }
  970. else if (LL_10 & 1) goto L_4;}
  971. case /* C_WHILE */ 11 : ;
  972. LLtdecr(11);
  973. LL_SAFE(C_WHILE);
  974. LL_NOSCANDONE(C_EXPR);
  975. # line 490 "LLgen.g"
  976. { t |= RESOLVER; }
  977. LLread();
  978. }
  979. }
  980. goto L_5;
  981. L_5 : {switch(LLcsymb) {
  982. case /* C_IDENT */ 2 : ;
  983. case /* C_LITERAL */ 4 : ;
  984. case /* C_ACTION */ 7 : ;
  985. case /* C_IF */ 10 : ;
  986. case /* C_AVOID */ 17 : ;
  987. case /* C_PREFER */ 18 : ;
  988. case /* C_DEFAULT */ 19 : ;
  989. case /* C_SUBSTART */ 20 : ;
  990. case /* C_ERRONEOUS */ 21 : ;
  991. case /* C_ILLEGAL */ 22 : ;
  992. case /* '|' */ 26 : ;
  993. case /* '[' */ 27 : ;
  994. case /* ']' */ 28 : ;
  995. LLtdecr(12);
  996. break;
  997. default:{int LL_11=LLnext(268);
  998. ;if (!LL_11) {
  999. LLtdecr(12);
  1000. break;
  1001. }
  1002. else if (LL_11 & 1) goto L_5;}
  1003. case /* C_PERSISTENT */ 12 : ;
  1004. LLtdecr(12);
  1005. LL_SAFE(C_PERSISTENT);
  1006. # line 492 "LLgen.g"
  1007. { t |= PERSISTENT; }
  1008. LLread();
  1009. }
  1010. }
  1011. LLsdecr(1);
  1012. LL5_productions(
  1013. # line 494 "LLgen.g"
  1014. &p1);
  1015. LLtdecr(28);
  1016. LL_SCANDONE(']');
  1017. # line 495 "LLgen.g"
  1018. {
  1019. mkterm(p1,t,ln,pres);
  1020. }
  1021. LLread();
  1022. break;
  1023. case /* C_IDENT */ 2 : ;
  1024. case /* C_LITERAL */ 4 : ;
  1025. case /* C_ERRONEOUS */ 21 : ;
  1026. LLsincr(5);
  1027. goto L_6;
  1028. L_6 : {switch(LLcsymb) {
  1029. default:
  1030. break;
  1031. case /* C_ERRONEOUS */ 21 : ;
  1032. LL_SAFE(C_ERRONEOUS);
  1033. # line 499 "LLgen.g"
  1034. {
  1035. #ifdef NON_CORRECTING
  1036. erroneous = 1;
  1037. #endif
  1038. }
  1039. LLread();
  1040. }
  1041. }
  1042. goto L_8; /* so that the label is used for certain */
  1043. L_8: ;
  1044. switch(LLcsymb) {
  1045. case /* C_IDENT */ 2 : ;
  1046. goto L_9;
  1047. L_9: ;
  1048. LLsdecr(5);
  1049. LLtincr(6);
  1050. LL_SSCANDONE(C_IDENT);
  1051. # line 507 "LLgen.g"
  1052. { pe = search(UNKNOWN,lextoken.t_string,BOTH);
  1053. *pres = *pe;
  1054. #ifdef NON_CORRECTING
  1055. if (erroneous) {
  1056. if (g_gettype(pres) != TERMINAL){
  1057. warning(linecount,
  1058. "Erroneous only allowed on terminal");
  1059. erroneous = 0;
  1060. }
  1061. else
  1062. pres->g_erroneous = 1;
  1063. }
  1064. #endif
  1065. }
  1066. LLread();
  1067. goto L_10;
  1068. L_10 : {switch(LLcsymb) {
  1069. case /* C_IDENT */ 2 : ;
  1070. case /* C_NUMBER */ 3 : ;
  1071. case /* C_LITERAL */ 4 : ;
  1072. case /* C_ACTION */ 7 : ;
  1073. case /* C_SUBSTART */ 20 : ;
  1074. case /* C_ERRONEOUS */ 21 : ;
  1075. case /* ';' */ 24 : ;
  1076. case /* '|' */ 26 : ;
  1077. case /* '[' */ 27 : ;
  1078. case /* ']' */ 28 : ;
  1079. case /* '?' */ 29 : ;
  1080. case /* '*' */ 30 : ;
  1081. case /* '+' */ 31 : ;
  1082. LLtdecr(6);
  1083. break;
  1084. default:{int LL_12=LLnext(262);
  1085. ;if (!LL_12) {
  1086. LLtdecr(6);
  1087. break;
  1088. }
  1089. else if (LL_12 & 1) goto L_10;}
  1090. case /* C_PARAMS */ 6 : ;
  1091. LLtdecr(6);
  1092. LL_SAFE(C_PARAMS);
  1093. # line 522 "LLgen.g"
  1094. { if (lextoken.t_num > 15) {
  1095. error(linecount,"Too many parameters");
  1096. } else g_setnpar(pres,lextoken.t_num);
  1097. if (g_gettype(pres) == TERMINAL) {
  1098. error(linecount,
  1099. "Terminal with parameters");
  1100. }
  1101. }
  1102. LLread();
  1103. }
  1104. }
  1105. break;
  1106. default: if (LLskip()) goto L_8;
  1107. goto L_9;
  1108. case /* C_LITERAL */ 4 : ;
  1109. LLsdecr(5);
  1110. LL_SAFE(C_LITERAL);
  1111. # line 531 "LLgen.g"
  1112. { pe = search(LITERAL,lextoken.t_string,BOTH);
  1113. *pres = *pe;
  1114. #ifdef NON_CORRECTING
  1115. if (erroneous)
  1116. pres->g_erroneous = 1;
  1117. #endif
  1118. }
  1119. LLread();
  1120. break;
  1121. }
  1122. break;
  1123. default:
  1124. LLtincr(7);
  1125. # line 539 "LLgen.g"
  1126. { g_settype(pres,ACTION);
  1127. pres->g_lineno = linecount;
  1128. #ifdef NON_CORRECTING
  1129. g_setsubparse(pres, (p_start) 0);
  1130. #endif
  1131. }
  1132. goto L_11;
  1133. L_11 : {switch(LLcsymb) {
  1134. default:
  1135. break;
  1136. case /* C_SUBSTART */ 20 : ;
  1137. LLtincr(23);
  1138. LLtincr(24);
  1139. LL_SAFE(C_SUBSTART);
  1140. # line 548 "LLgen.g"
  1141. {
  1142. #ifdef NON_CORRECTING
  1143. nsubstarts++;
  1144. #endif
  1145. }
  1146. LL_NOSCANDONE(C_IDENT);
  1147. # line 555 "LLgen.g"
  1148. {
  1149. #ifdef NON_CORRECTING
  1150. register p_gram temp;
  1151. register p_start subp;
  1152. temp = search(NONTERM,lextoken.t_string,BOTH);
  1153. subp = (p_start) alloc (sizeof(t_start));
  1154. subp->ff_nont = g_getcont(temp);
  1155. subp->ff_name = (string) 0;
  1156. subp->ff_next = (p_start) 0;
  1157. g_setsubparse(pres, subp);
  1158. #endif
  1159. }
  1160. LLread();
  1161. for (;;) {
  1162. goto L_12;
  1163. L_12 : {switch(LLcsymb) {
  1164. case /* ';' */ 24 : ;
  1165. break;
  1166. default:{int LL_13=LLnext(44);
  1167. ;if (!LL_13) {
  1168. break;
  1169. }
  1170. else if (LL_13 & 1) goto L_12;}
  1171. case /* ',' */ 23 : ;
  1172. LL_SAFE(',');
  1173. LL_NOSCANDONE(C_IDENT);
  1174. # line 571 "LLgen.g"
  1175. {
  1176. #ifdef NON_CORRECTING
  1177. register p_gram temp;
  1178. register p_start ff;
  1179. temp = search(NONTERM,lextoken.t_string,BOTH);
  1180. ff = g_getsubparse(pres);
  1181. while (ff) {
  1182. if (ff->ff_nont == g_getcont(temp)) {
  1183. warning(linecount, "\"%s\" used twice in %%substart", lextoken.t_string);
  1184. break;
  1185. }
  1186. ff = ff->ff_next;
  1187. }
  1188. ff = (p_start) alloc(sizeof(t_start));
  1189. ff->ff_nont = g_getcont(temp);
  1190. ff->ff_name = (string) 0;
  1191. ff->ff_next = g_getsubparse(pres);
  1192. g_setsubparse(pres, ff);
  1193. #endif
  1194. }
  1195. LLread();
  1196. continue;
  1197. }
  1198. }
  1199. LLtdecr(23);
  1200. break;
  1201. }
  1202. LLtdecr(24);
  1203. LL_SSCANDONE(';');
  1204. LLread();
  1205. }
  1206. }
  1207. LLtdecr(7);
  1208. LL_SCANDONE(C_ACTION);
  1209. LLread();
  1210. break;
  1211. }
  1212. }
  1213. static
  1214. #if LL_ANSI_C
  1215. void
  1216. #endif
  1217. LL8_repeats(
  1218. #if LL_ANSI_C
  1219. # line 602 "LLgen.g"
  1220. int *kind ,int *cnt)
  1221. #else
  1222. # line 602 "LLgen.g"
  1223. kind,cnt) int *kind; int *cnt;
  1224. #endif
  1225. {
  1226. # line 602 "LLgen.g"
  1227. int t1 = 0;
  1228. switch(LLcsymb) {
  1229. default:
  1230. LL_SAFE('?');
  1231. # line 604 "LLgen.g"
  1232. { *kind = OPT; }
  1233. LLread();
  1234. break;
  1235. case /* '*' */ 30 : ;
  1236. case /* '+' */ 31 : ;
  1237. LLtincr(3);
  1238. switch(LLcsymb) {
  1239. default:
  1240. LL_SAFE('*');
  1241. # line 605 "LLgen.g"
  1242. { *kind = STAR; }
  1243. break;
  1244. case /* '+' */ 31 : ;
  1245. LL_SAFE('+');
  1246. # line 606 "LLgen.g"
  1247. { *kind = PLUS; }
  1248. break;
  1249. }
  1250. LLread();
  1251. goto L_7;
  1252. L_7 : {switch(LLcsymb) {
  1253. case /* C_IDENT */ 2 : ;
  1254. case /* C_LITERAL */ 4 : ;
  1255. case /* C_ACTION */ 7 : ;
  1256. case /* C_SUBSTART */ 20 : ;
  1257. case /* C_ERRONEOUS */ 21 : ;
  1258. case /* ';' */ 24 : ;
  1259. case /* '|' */ 26 : ;
  1260. case /* '[' */ 27 : ;
  1261. case /* ']' */ 28 : ;
  1262. LLtdecr(3);
  1263. break;
  1264. default:{int LL_14=LLnext(259);
  1265. ;if (!LL_14) {
  1266. LLtdecr(3);
  1267. break;
  1268. }
  1269. else if (LL_14 & 1) goto L_7;}
  1270. case /* C_NUMBER */ 3 : ;
  1271. LLtdecr(3);
  1272. LL9_number(
  1273. # line 608 "LLgen.g"
  1274. &t1);
  1275. LLread();
  1276. }
  1277. }
  1278. # line 609 "LLgen.g"
  1279. { if (t1 == 1) {
  1280. t1 = 0;
  1281. if (*kind == STAR) *kind = OPT;
  1282. if (*kind == PLUS) *kind = FIXED;
  1283. }
  1284. }
  1285. break;
  1286. case /* C_NUMBER */ 3 : ;
  1287. LL9_number(
  1288. # line 615 "LLgen.g"
  1289. &t1);
  1290. LLread();
  1291. break;
  1292. }
  1293. # line 616 "LLgen.g"
  1294. { *cnt = t1; }
  1295. }
  1296. static
  1297. #if LL_ANSI_C
  1298. void
  1299. #endif
  1300. LL9_number(
  1301. #if LL_ANSI_C
  1302. # line 619 "LLgen.g"
  1303. int *t)
  1304. #else
  1305. # line 619 "LLgen.g"
  1306. t) int *t;
  1307. #endif
  1308. {
  1309. LL_SAFE(C_NUMBER);
  1310. # line 621 "LLgen.g"
  1311. { *t = lextoken.t_num;
  1312. if (*t <= 0 || *t >= 8192) {
  1313. error(linecount,"Illegal number");
  1314. }
  1315. }
  1316. }
  1317. static
  1318. #if LL_ANSI_C
  1319. void
  1320. #endif
  1321. LL4_firsts(
  1322. #if LL_ANSI_C
  1323. void
  1324. #endif
  1325. ) {
  1326. # line 628 "LLgen.g"
  1327. register string p;
  1328. LLtincr(23);
  1329. LLtincr(2);
  1330. LLtincr(24);
  1331. LL_SAFE(C_FIRST);
  1332. LL_NOSCANDONE(C_IDENT);
  1333. # line 630 "LLgen.g"
  1334. { p = store(lextoken.t_string); }
  1335. LLtdecr(23);
  1336. LL_NOSCANDONE(',');
  1337. LLtdecr(2);
  1338. LL_NOSCANDONE(C_IDENT);
  1339. LLtdecr(24);
  1340. LL_NOSCANDONE(';');
  1341. # line 632 "LLgen.g"
  1342. { /*
  1343. * Store this %first in the list belonging
  1344. * to this input file
  1345. */
  1346. p_gram temp;
  1347. register p_first ff;
  1348. temp = search(NONTERM,lextoken.t_string,BOTH);
  1349. ff = (p_first) alloc(sizeof(t_first));
  1350. ff->ff_nont = g_getcont(temp);
  1351. ff->ff_name = p;
  1352. ff->ff_next = pfile->f_firsts;
  1353. pfile->f_firsts = ff;
  1354. }
  1355. }
  1356. # line 647 "LLgen.g"
  1357. STATIC p_gram
  1358. copyrule(p,length) register p_gram p; {
  1359. /*
  1360. * Returns a pointer to a grammar rule that was created in
  1361. * p. The space pointed to by p can now be reused
  1362. */
  1363. register p_gram t;
  1364. p_gram rule;
  1365. t = (p_gram) alloc((unsigned) length * sizeof(t_gram));
  1366. rule = t;
  1367. while (length--) {
  1368. *t++ = *p++;
  1369. }
  1370. return rule;
  1371. }