home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume20 / fpc / part06 < prev    next >
Encoding:
Internet Message Format  |  1989-10-23  |  37.2 KB

  1. Subject:  v20i055:  Portable compiler of the FP language, Part06/06
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Edoardo Biagioni <biagioni@cs.unc.edu>
  7. Posting-number: Volume 20, Issue 55
  8. Archive-name: fpc/part06
  9.  
  10. #    This is a shell archive.
  11. #    Remove everything above and including the cut line.
  12. #    Then run the rest of the file through sh.
  13. -----cut here-----cut here-----cut here-----cut here-----
  14. #!/bin/sh
  15. # shar:    Shell Archiver
  16. #    Run the following text with /bin/sh to create:
  17. #    parse.c
  18. #    parse.h
  19. #    prims.fp
  20. #    y.tab.c
  21. # This archive created: Thu May 26 17:08:30 1988
  22. echo shar: extracting parse.c '(11733 characters)'
  23. sed 's/^XX//' << \SHAR_EOF > parse.c
  24. XX/* parse.c: builds the parse tree for each function, then calls code (tree)
  25. XX *        to produce the code for it.
  26. XX */
  27. XX
  28. XX#include <stdio.h>
  29. XX#include <strings.h>
  30. XX#include "fpc.h"
  31. XX#include "parse.h"
  32. XX
  33. XXextern char * malloc ();
  34. XXextern char * sprintf ();
  35. XX
  36. XXvoid code ();
  37. XXvoid startcomp ();
  38. XXvoid endcomp ();
  39. XX
  40. XXchar funname [MAXIDLEN] = "no function declaration seen yet";
  41. XXint inerror = 0;
  42. XXstatic struct fpexprd basefun = { INVALID };
  43. XXstatic fpexpr stack [STACKDEPTH] = { & basefun };
  44. XXstatic int stackptr = 0;
  45. XX
  46. XX/* the context holds, for level cntptr, whether a compose was
  47. XX * encountered on that level or not. */
  48. XXstatic int context [STACKDEPTH];
  49. XXstatic int cntptr = 0;
  50. XX
  51. XXstatic fpexpr newexpr (type)
  52. XXint type;
  53. XX{
  54. XX  register fpexpr new;
  55. XX
  56. XX  new = (fpexpr) malloc (sizeof (struct fpexprd));
  57. XX  new->exprtype = type;
  58. XX  return (new);
  59. XX}
  60. XX
  61. XXvoid parsefnstart (fname)
  62. XXchar * fname;
  63. XX{
  64. XX  extern int verbose;    /* set in fpc.c */
  65. XX
  66. XX#ifdef TRACE
  67. XX  (void) printf ("function name is %s\n", fname);
  68. XX#endif
  69. XX  (void) strcpy (funname, fname);
  70. XX  inerror = 0;
  71. XX  stackptr = 0;
  72. XX  cntptr = 0;    /* root context */
  73. XX  if (verbose)
  74. XX    (void) printf ("%s\n", funname);
  75. XX  startcomp ();
  76. XX}
  77. XX
  78. XXvoid parsefnend ()
  79. XX{
  80. XX#ifdef TRACE
  81. XX  (void) printf ("function body is finished\n");
  82. XX#endif
  83. XX  endcomp ();
  84. XX  if (inerror)
  85. XX    inerror = 0;
  86. XX  else
  87. XX  {
  88. XX    if (stackptr != 1)
  89. XX      (void) fprintf (stderr, "stackptr is %d at end\n", stackptr);
  90. XX    if (cntptr != 0)
  91. XX      (void) fprintf (stderr, "context pointer is %d at end\n", cntptr);
  92. XX    if (stackptr != 1)
  93. XX      puterror ("compiler error 1", "");
  94. XX    if (cntptr != 0)
  95. XX      puterror ("compiler error 5", "");
  96. XX    code (funname, stack [0]);
  97. XX  }
  98. XX}
  99. XX
  100. XXvoid parsethen ()
  101. XX{ /* pop the composition being parsed off the stack and make it
  102. XX   * the first (if) part of the conditional */
  103. XX  fpexpr ifpart, current;
  104. XX
  105. XX#ifdef TRACE
  106. XX  (void) printf (" -> ");
  107. XX#endif
  108. XX  endcomp ();
  109. XX  ifpart = stack [--stackptr];
  110. XX  stack [stackptr++] = current = newexpr (COND);
  111. XX  current->fpexprv.conditional [0] = ifpart;
  112. XX  startcomp ();
  113. XX}
  114. XX
  115. XXvoid parseelse ()
  116. XX{
  117. XX/* top of stack is the then part, put it into the structure */
  118. XX  fpexpr current;
  119. XX
  120. XX#ifdef TRACE
  121. XX  (void) printf (" ; ");
  122. XX#endif
  123. XX  endcomp ();
  124. XX  current = stack [stackptr - 2];
  125. XX  if (current->exprtype != COND)
  126. XX    yyerror ("compiler error 2");
  127. XX  current->fpexprv.conditional [1] = stack [--stackptr];
  128. XX  startcomp ();
  129. XX}
  130. XX
  131. XXvoid parseendif ()
  132. XX{
  133. XX/* top of stack is the else part, put it into the structure */
  134. XX  fpexpr current;
  135. XX
  136. XX#ifdef TRACE
  137. XX  (void) printf (" endif\n");
  138. XX#endif
  139. XX  endcomp ();
  140. XX  if (stackptr < 2)
  141. XX    yyerror ("compiler error 4");
  142. XX  else
  143. XX  {
  144. XX    current = stack [stackptr - 2];
  145. XX    if (current->exprtype != COND)
  146. XX      yyerror ("compiler error 3");
  147. XX    current->fpexprv.conditional [2] = stack [--stackptr];
  148. XX  }
  149. XX  startcomp ();        /* empty, only to keep the stack balanced */
  150. XX}
  151. XX
  152. XXvoid parsebustart (right)
  153. XXint right;
  154. XX{
  155. XX#ifdef TRACE
  156. XX  (void) printf ("starting bu%s\n", (right) ? "r" : "");
  157. XX#endif
  158. XX  stack [stackptr++] = newexpr (right ? BUR : BU);
  159. XX  startcomp ();
  160. XX}
  161. XX
  162. XXvoid parsebufun ()
  163. XX{
  164. XX  fpexpr fun;
  165. XX
  166. XX#ifdef TRACE
  167. XX  (void) printf ("done with the bu or bur expression\n");
  168. XX#endif
  169. XX  endcomp ();
  170. XX  fun = stack [--stackptr];
  171. XX  stack [stackptr - 1]->fpexprv.bulr.bufun = fun;
  172. XX}
  173. XX
  174. XXvoid parsebuobj ()
  175. XX{
  176. XX  fpexpr obj;
  177. XX
  178. XX#ifdef TRACE
  179. XX  (void) printf ("done with the bu or bur object\n");
  180. XX#endif
  181. XX  obj = stack [--stackptr];
  182. XX  stack [stackptr - 1]->fpexprv.bulr.buobj = obj;
  183. XX}
  184. XX
  185. XXvoid whilestart ()
  186. XX{
  187. XX#ifdef TRACE
  188. XX  (void) printf ("starting the while\n");
  189. XX#endif
  190. XX  stack [stackptr++] = newexpr (WHILE);
  191. XX  startcomp ();
  192. XX}
  193. XX
  194. XXvoid whilepred ()
  195. XX{
  196. XX  fpexpr pred;
  197. XX
  198. XX#ifdef TRACE
  199. XX  (void) printf ("while predicate done\n");
  200. XX#endif
  201. XX  endcomp ();
  202. XX  pred = stack [--stackptr];
  203. XX  stack [stackptr - 1]->fpexprv.whilestat [0] = pred;
  204. XX  startcomp ();
  205. XX}
  206. XX
  207. XXvoid whilefun ()
  208. XX{
  209. XX  fpexpr loop;
  210. XX
  211. XX#ifdef TRACE
  212. XX  (void) printf ("while function done\n");
  213. XX#endif
  214. XX  endcomp ();
  215. XX  loop = stack [--stackptr];
  216. XX  stack [stackptr - 1]->fpexprv.whilestat [1] = loop;
  217. XX}
  218. XX
  219. XXvoid parsecomp ()
  220. XX{
  221. XX  fpexpr fun, next;
  222. XX
  223. XX#ifdef TRACE
  224. XX  (void) printf ("composing with next function\n");
  225. XX#endif
  226. XX  fun = stack [--stackptr];
  227. XX  next = newexpr (COMP);
  228. XX  next->fpexprv.compconstr.compexpr = fun;
  229. XX  if (context [cntptr - 1])    /* node already allocated on this level */
  230. XX  {    /* join the new one in front of the old list, which is now present */
  231. XX#ifdef TRACE
  232. XX    (void) printf ("adding to old compose list, stackptr is %d\n", stackptr);
  233. XX#endif
  234. XX    if (stackptr < 1)
  235. XX      yyerror ("compiler error 9");
  236. XX    else
  237. XX    {
  238. XX      next->fpexprv.compconstr.compnext = stack [stackptr - 1];
  239. XX      stack [stackptr - 1] = next;
  240. XX    }
  241. XX  }
  242. XX  else                /* create new list */
  243. XX  {
  244. XX#ifdef TRACE
  245. XX    (void) printf ("creating new compose list, stackptr is %d\n", stackptr);
  246. XX#endif
  247. XX    next->fpexprv.compconstr.compnext = 0;
  248. XX    stack [stackptr++] = next;
  249. XX  }
  250. XX  context [cntptr - 1] = 1;    /* yes, we have a compose on this level */
  251. XX}
  252. XX
  253. XXvoid startcomp ()
  254. XX{
  255. XX#ifdef TRACE
  256. XX  (void) printf ("setting up possible composition\n");
  257. XX#endif
  258. XX  context [cntptr++] = 0;
  259. XX}
  260. XX
  261. XXvoid endcomp ()
  262. XX{
  263. XX#ifdef TRACE
  264. XX  (void) printf ("closing up %s composition\n",
  265. XX         context [cntptr - 1] ? "the" : "no");
  266. XX#endif
  267. XX  if (cntptr <= 0)        /* endcomp does not match comp */
  268. XX    yyerror ("compiler error 6");
  269. XX  else if ((context [cntptr - 1]) == 0) /* composition not done */
  270. XX    cntptr--;
  271. XX  else if (stackptr <= 1)    /* composition done, but no composition? */
  272. XX    yyerror ("compiler error 7");
  273. XX  else if (stack [stackptr - 2]->exprtype != COMP)    /* same problem */
  274. XX    yyerror ("compiler error 8");
  275. XX  else
  276. XX  {  /* we put the stack top as the last expression to be composed with */
  277. XX    parsecomp ();
  278. XX    cntptr--;
  279. XX  }
  280. XX}
  281. XX
  282. XXvoid parseaa ()
  283. XX{
  284. XX  fpexpr exp, aa;
  285. XX
  286. XX#ifdef TRACE
  287. XX  (void) printf ("apply-to-all encountered\n");
  288. XX#endif
  289. XX  exp = stack [--stackptr];
  290. XX  stack [stackptr++] = aa = newexpr (AA);
  291. XX  aa->fpexprv.aains = exp;
  292. XX}
  293. XX
  294. XXvoid parseconstr ()
  295. XX{
  296. XX#ifdef TRACE
  297. XX  (void) printf ("constructor encountered\n");
  298. XX#endif
  299. XX  stack [stackptr] = newexpr (CONSTR);
  300. XX  stack [stackptr++]->fpexprv.compconstr.compnext = 0;
  301. XX  startcomp ();
  302. XX}
  303. XX
  304. XXvoid constrnext ()
  305. XX{    /* append new item to the end of the list */
  306. XX  fpexpr fun, oldc;
  307. XX
  308. XX#ifdef TRACE
  309. XX  (void) printf ("finished item of constructor\n");
  310. XX#endif
  311. XX  endcomp ();
  312. XX  fun = stack [--stackptr];
  313. XX  oldc = stack [stackptr - 1];
  314. XX  while (oldc->fpexprv.compconstr.compnext != 0)
  315. XX    oldc = oldc->fpexprv.compconstr.compnext;
  316. XX  oldc->fpexprv.compconstr.compexpr = fun;
  317. XX  oldc->fpexprv.compconstr.compnext = newexpr (CONSTR);
  318. XX  oldc->fpexprv.compconstr.compnext->fpexprv.compconstr.compnext = 0;
  319. XX  startcomp ();
  320. XX}
  321. XX
  322. XXvoid endconstr ()
  323. XX{    /* we delete the last storage box of the list, since it's unused */
  324. XX  fpexpr oldc, last;
  325. XX
  326. XX#ifdef TRACE
  327. XX  (void) printf ("constructor finished\n");
  328. XX#endif
  329. XX  endcomp ();/* usually this one just pops the context, should always be 0 */
  330. XX  oldc = stack [stackptr - 1];
  331. XX  while (oldc->fpexprv.compconstr.compnext != 0)
  332. XX  {
  333. XX    last = oldc;
  334. XX    oldc = oldc->fpexprv.compconstr.compnext;
  335. XX  }
  336. XX  last->fpexprv.compconstr.compnext = 0;
  337. XX}
  338. XX
  339. XXvoid parseinsert (type)
  340. XXint type;
  341. XX/* type is 0 for insert, 1 for right insert, 2 for tree insert */
  342. XX{
  343. XX  fpexpr ins;
  344. XX
  345. XX#ifdef TRACE
  346. XX  switch (type)
  347. XX  {
  348. XX    case 0: (void) printf ("insert encountered\n");
  349. XX        break;
  350. XX    case 1: (void) printf ("right insert encountered\n");
  351. XX        break;
  352. XX    case 2: (void) printf ("tree insert encountered\n");
  353. XX        break;
  354. XX    default: (void) printf ("unknown insert found\n");
  355. XX        exit (1);
  356. XX  }
  357. XX#endif
  358. XX  switch (type)
  359. XX  {
  360. XX    case 0: ins = newexpr (INSERT);
  361. XX        break;
  362. XX    case 1: ins = newexpr (RINSERT);
  363. XX        break;
  364. XX    default: ins = newexpr (TREE);
  365. XX  }
  366. XX  stack [stackptr++] = ins;
  367. XX}
  368. XX
  369. XXvoid endinsert ()
  370. XX{
  371. XX#ifdef TRACE
  372. XX  (void) printf ("insert done\n");
  373. XX#endif
  374. XX  stackptr--;
  375. XX  stack [stackptr - 1]->fpexprv.aains = stack [stackptr];
  376. XX}
  377. XX
  378. XXvoid parsesel (sel, right)
  379. XXchar * sel;
  380. XXint right;
  381. XX{
  382. XX  fpexpr selfn;
  383. XX  char errbuf [256];
  384. XX
  385. XX#ifdef TRACE
  386. XX  (void) printf ("%s selector is %s\n", (right ? "right" : "left"), sel);
  387. XX#endif
  388. XX  stack [stackptr++] = selfn = newexpr (right ? RSEL : SEL);
  389. XX  (void) sscanf (sel, "%d", &selfn->fpexprv.lrsel);
  390. XX  if (selfn->fpexprv.lrsel <= 0)
  391. XX  {
  392. XX    (void) sprintf (errbuf, "error: selector %d < 1", selfn->fpexprv.lrsel);
  393. XX    yyerror (errbuf);
  394. XX  }
  395. XX}
  396. XX
  397. XXvoid parsefncall (fun)
  398. XXchar * fun;
  399. XX{
  400. XX  fpexpr funblk;
  401. XX  unsigned int len;
  402. XX
  403. XX#ifdef TRACE
  404. XX  (void) printf ("calling function %s\n", fun);
  405. XX#endif
  406. XX  stack [stackptr++] = funblk = newexpr (FNCALL);
  407. XX  len = strlen (fun) + 1;
  408. XX  funblk->fpexprv.funcall = malloc (len);
  409. XX  (void) strcpy (funblk->fpexprv.funcall, fun);
  410. XX}
  411. XX
  412. XXvoid consttrue ()
  413. XX{
  414. XX#ifdef TRACE
  415. XX  (void) printf ("constant true\n");
  416. XX#endif
  417. XX  stack [stackptr++] = newexpr (TRUE);
  418. XX}
  419. XX
  420. XXvoid constfalse ()
  421. XX{
  422. XX#ifdef TRACE
  423. XX  (void) printf ("constant false\n");
  424. XX#endif
  425. XX  stack [stackptr++] = newexpr (FALSE);
  426. XX}
  427. XX
  428. XXvoid constnum (num)
  429. XXchar * num;
  430. XX{
  431. XX  fpexpr objblock;
  432. XX
  433. XX#ifdef TRACE
  434. XX  (void) printf ("constant number %s\n", num);
  435. XX#endif
  436. XX  stack [stackptr++] = objblock = newexpr (INT);
  437. XX  (void) sscanf (num, "%d", &objblock->fpexprv.intobj);
  438. XX}
  439. XX
  440. XXvoid constsym (name)
  441. XXchar * name;
  442. XX{
  443. XX  fpexpr objblock;
  444. XX
  445. XX#ifdef TRACE
  446. XX  (void) printf ("constant symbol %s\n", name);
  447. XX#endif
  448. XX  stack [stackptr++] = objblock = newexpr (SYM);
  449. XX  objblock->fpexprv.symbol = malloc ((unsigned) (strlen (name) + 1));
  450. XX  (void) strcpy (objblock->fpexprv.symbol, name);
  451. XX}
  452. XX
  453. XXvoid conststr (str)
  454. XXchar * str;
  455. XX{
  456. XX  fpexpr obj, new, ch;
  457. XX  char * strp = str;
  458. XX
  459. XX#ifdef TRACE
  460. XX  (void) printf ("constant string %s\n", str);
  461. XX#endif
  462. XX  while (*(++strp) != '\0')
  463. XX    ;
  464. XX  strp--;    /* strp now points to the char before the null */
  465. XX  strp--;    /* strp now points to the char before the " */
  466. XX  if (strp == str)    /* empty string, same as NIL */
  467. XX    stack [stackptr++] = newexpr (NIL);
  468. XX  else
  469. XX  {
  470. XX    for (obj = 0; strp != str; strp--)
  471. XX/* by checking strp != str, we skip the initial " */
  472. XX    {
  473. XX      new = newexpr (LIST);
  474. XX      new->fpexprv.listobj.listnext = obj;
  475. XX      ch = newexpr (CHAR);
  476. XX      ch->fpexprv.character = *strp;
  477. XX      new->fpexprv.listobj.listel = ch;
  478. XX      obj = new;
  479. XX    }
  480. XX    stack [stackptr++] = obj;
  481. XX  }
  482. XX}
  483. XX
  484. XXvoid constchr (ch)
  485. XXchar * ch;
  486. XX{
  487. XX  fpexpr objblock;
  488. XX
  489. XX#ifdef TRACE
  490. XX  (void) printf ("constant character %s\n", ch);
  491. XX#endif
  492. XX  stack [stackptr++] = objblock = newexpr (CHAR);
  493. XX  if (*(++ch) == '\\')
  494. XX    ch++;
  495. XX  objblock->fpexprv.character = *ch;
  496. XX}
  497. XX
  498. XXvoid constreal (num)
  499. XXchar * num;
  500. XX{
  501. XX  fpexpr objblock;
  502. XX
  503. XX#ifdef TRACE
  504. XX  (void) printf ("constant floating-point number %s\n", num);
  505. XX#endif
  506. XX  stack [stackptr++] = objblock = newexpr (FLOAT);
  507. XX  (void) sscanf (num, "%lf", &objblock->fpexprv.floatobj);
  508. XX}
  509. XX
  510. XXvoid parsenil ()
  511. XX{
  512. XX#ifdef TRACE
  513. XX  (void) printf ("constant nil\n");
  514. XX#endif
  515. XX  stack [stackptr++] = newexpr (NIL);
  516. XX}
  517. XX
  518. XXvoid liststart ()
  519. XX{
  520. XX  fpexpr objblock;
  521. XX
  522. XX#ifdef TRACE
  523. XX  (void) printf ("beginning of constant list\n");
  524. XX#endif
  525. XX  stack [stackptr++] = objblock = newexpr (LIST);
  526. XX  objblock->fpexprv.listobj.listnext = 0;
  527. XX}
  528. XX
  529. XXvoid listnext ()
  530. XX{
  531. XX  fpexpr obj, oldobj, el;
  532. XX
  533. XX#ifdef TRACE
  534. XX  (void) printf ("end of element of constant list\n");
  535. XX#endif
  536. XX  obj = newexpr (LIST);
  537. XX  el = stack [--stackptr];
  538. XX  obj->fpexprv.listobj.listnext = 0;
  539. XX  oldobj = stack [stackptr - 1];
  540. XX  while (oldobj->fpexprv.listobj.listnext != 0)
  541. XX    oldobj = oldobj->fpexprv.listobj.listnext;
  542. XX  oldobj->fpexprv.listobj.listel = el;
  543. XX  oldobj->fpexprv.listobj.listnext = obj;
  544. XX}
  545. XX
  546. XXvoid listend ()
  547. XX{    /* invariant: thanks to YACC, there must have been at
  548. XX     * least one call to listnext since the call to liststart */
  549. XX    /* essentially, we take the last element off the list, since
  550. XX     * that is the one and only unused one */
  551. XX  fpexpr obj;
  552. XX
  553. XX#ifdef TRACE
  554. XX  (void) printf ("end of constant list\n");
  555. XX#endif
  556. XX  obj = stack [stackptr - 1];
  557. XX  while (obj->fpexprv.listobj.listnext->fpexprv.listobj.listnext != 0)
  558. XX    obj = obj->fpexprv.listobj.listnext;
  559. XX  obj->fpexprv.listobj.listnext = 0;
  560. XX}
  561. SHAR_EOF
  562. if test 11733 -ne "`wc -c parse.c`"
  563. then
  564. echo shar: error transmitting parse.c '(should have been 11733 characters)'
  565. fi
  566. echo shar: extracting parse.h '(1448 characters)'
  567. sed 's/^XX//' << \SHAR_EOF > parse.h
  568. XX/* parse.h: defines the possible structures of the parse tree
  569. XX *        used to represent FP functions.
  570. XX */
  571. XX
  572. XX#define COND    0
  573. XX#define BU    1
  574. XX#define BUR    2
  575. XX#define WHILE    3
  576. XX#define COMP    4
  577. XX#define AA    5
  578. XX#define CONSTR    6
  579. XX#define INSERT    7
  580. XX#define RINSERT    8
  581. XX#define TREE    9
  582. XX/* unnecessary, since the individual constant types take care of this
  583. XX #define CONST    10 */
  584. XX#define SEL    11
  585. XX#define RSEL    12
  586. XX#define MULTI    13
  587. XX/* not a real functional form, used for in-lining /{+, *, and, or} */
  588. XX#define FNCALL    14
  589. XX#define INVALID    15
  590. XX
  591. XX#define NIL    20
  592. XX#define TRUE    21
  593. XX#define FALSE    22
  594. XX#define LIST    23
  595. XX#define INT    24
  596. XX#define FLOAT    25
  597. XX#define SYM    26
  598. XX#define CHAR    27
  599. XX
  600. XXtypedef struct fpexprd * fpexpr;
  601. XX
  602. XXunion fpexprc
  603. XX{
  604. XX  fpexpr conditional [3];    /* if, then, else */
  605. XX  struct {
  606. XX       fpexpr bufun;
  607. XX       fpexpr buobj;
  608. XX     } bulr;        /* bu, bur */
  609. XX  fpexpr whilestat [2];        /* predicate, body */
  610. XX  struct {
  611. XX       fpexpr compexpr;
  612. XX           fpexpr compnext;
  613. XX         } compconstr;
  614. XX/* compose, construct both have lists of expressions */
  615. XX  fpexpr aains;            /* aa, all inserts, multi */
  616. XX  int lrsel;            /* left, right selects */
  617. XX  char * funcall;        /* function call */
  618. XX  struct {
  619. XX       fpexpr listel;
  620. XX           fpexpr listnext;
  621. XX         } listobj;
  622. XX  long intobj;
  623. XX  double floatobj;
  624. XX  char * symbol;
  625. XX  char * string;
  626. XX  char character;
  627. XX};
  628. XX
  629. XXstruct fpexprd
  630. XX{
  631. XX  int exprtype;
  632. XX  union fpexprc fpexprv;
  633. XX  char constvar [6];        /* only used for constants */
  634. XX};
  635. XX
  636. XX#ifndef STACKDEPTH
  637. XX#define STACKDEPTH 100
  638. XX#endif
  639. XX
  640. SHAR_EOF
  641. if test 1448 -ne "`wc -c parse.h`"
  642. then
  643. echo shar: error transmitting parse.h '(should have been 1448 characters)'
  644. fi
  645. echo shar: extracting prims.fp '(8494 characters)'
  646. sed 's/^XX//' << \SHAR_EOF > prims.fp
  647. XX# prims.fp: test suite for any implementation of FP or FP/FFP
  648. XXDef prims [id, \/and] o
  649. XX      [testtl, testtlr,
  650. XX       testrotl, testrotr,
  651. XX       testid, testatom,
  652. XX       testdistl, testdistr,
  653. XX       testapndl, testapndr,
  654. XX       testeq, testnoteq,
  655. XX       testleq, testgeq,
  656. XX       testless, testgreater,
  657. XX       testplus, testminus,
  658. XX       testtimes, testdiv,
  659. XX       testneg, testmod,
  660. XX       testnull, testlength,
  661. XX       testtrans, testreverse,
  662. XX       testand, testor,
  663. XX       testnot, testiota]
  664. XX
  665. XXDef testand \/and o aa = o
  666. XX       (bu trans <F, F, F, T>) o aa and o _<<F, F>, <F, T>, <T, F>, <T, T>>
  667. XX
  668. XXDef testapndl \/and o aa = o
  669. XX       (bu trans <<a>, <a, b>, <a, b, c>, <<>>, <<a>>, <<a>, <b>>>) o
  670. XX       aa apndl o
  671. XX         _<<a, <>>, <a, <b>>, <a, <b, c>>, <<>, <>>, <<a>, <>>,
  672. XX           <<a>, <<b>>>>
  673. XX
  674. XXDef testapndr \/and o aa = o
  675. XX       (bu trans <<a>, <a, b>, <a, b, c>, <<>>, <<a>>, <<a>, <b>>>) o
  676. XX       aa apndr o
  677. XX         _<<<>, a>, <<a>, b>, <<a, b>, c>, <<>, <>>, <<>, <a>>,
  678. XX           <<<a>>, <b>>>
  679. XX
  680. XXDef testatom \/and o aa = o
  681. XX       (bu trans <T, T, T, T, T, T, T, F, F, F, F>) o
  682. XX       aa atom o
  683. XX        _<T, F, <>, 1, 1.0, a, 'a, "string", <vector>,
  684. XX          <"vector">, <v, e, c, t, o, r>>
  685. XX
  686. XXDef testdistl \/and o aa = o
  687. XX       (bu trans <<>, <<a, 1>>, <<b, 1>, <b, 2>>, <<<>, 1>,
  688. XX              <<>, 2>, <<>, 3>>>) o
  689. XX       aa distl o _<<x, <>>, <a, <1>>, <b, <1, 2>>, <<>, <1, 2, 3>>>
  690. XX
  691. XXDef testdistr \/and o aa = o
  692. XX       (bu trans <<>, <<a, 1>>, <<a, 2>, <b, 2>>,
  693. XX              <<a, <>>, <b, <>>, <c, <>>>>) o
  694. XX       aa distr o _<<<>, x>, <<a>, 1>, <<a, b>, 2>, <<a, b, c>, <>>>
  695. XX
  696. XXDef testdiv \/and o aa = o
  697. XX       (bu trans
  698. XX        <1,   1,   0,   2,   -12,   -3,    6,
  699. XX          1.0, 1.0, 0.5, 2.0, -8.75, -17.5, 6.25>) o
  700. XX       aa div o
  701. XX       _<<1, 1>, <10, 10>, <1, 2>, <2, 1>, <35, -3>, <-35, 17>, <-27, -4>,
  702. XX         <1, 1.0>, <10.0, 10>, <1.0, 2.0>, <2.0, 1>, <35, -4.0>,
  703. XX         <-35.0, 2.0>, <-25.0, -4.0>>
  704. XX
  705. XXDef testeq \/and o aa = o
  706. XX       (bu trans
  707. XX        <T, F, F, F, T, F, F, F, F, F,
  708. XX         T, F, F, F, F, F, F, F, F,
  709. XX         T, F, F, F, F, F, F, F, F,
  710. XX         T, F, T, F, F, F, F, F, F, F,
  711. XX         T, F, F, F, F, F, F,
  712. XX         T, F, F, F, F, F, F,
  713. XX         T, F, F, F, F, F, F,
  714. XX         T, F, F, F, F, F, F, F, F,
  715. XX         T, F>) o aa = o
  716. XX       _<<1, 1>, <1, 0>, <1, a>, <1, 'a>, <1, 1.0>, <1, 0.99>,
  717. XX        <1, <>>, <1, T>, <1, F>, <1, <1>>,
  718. XX         <a, a>, <a, b>, <a, 1>, <a, 'a>, <a, 1.0>, <a, <>>,
  719. XX        <a, T>, <a, F>, <a, <a>>,
  720. XX         <'a, 'a>, <'a, 'b>, <'a, 1>, <'a, a>, <'a, 1.0>,
  721. XX        <'a, <>>, <'a, T>, <'a, F>, <'a, <'a>>,
  722. XX         <1.0, 1.0>, <1.0, 2.0>, <1.0, 1>, <1.1, 1>, <1.0, 'a>,
  723. XX        <1.0, a>, <1.0, <>>, <1.0, T>, <1.0, F>, <1.0, <1.0>>,
  724. XX         <T, T>, <T, 1>, <T, 'T>, <T, 1.0>, <T, <>>, <T, F>, <T, <T>>,
  725. XX         <F, F>, <F, 1>, <F, 'F>, <F, 1.0>, <F, <>>, <F, T>, <F, <F>>,
  726. XX         <<>, <>>, <<>, 1>, <<>, 'F>, <<>, 1.0>, <<>, T>, <<>, F>,
  727. XX        <<>, <<>>>,
  728. XX         <<a>, <a>>, <<a>, <b>>, <<a>, 1>, <<a>, 'a>, <<a>, 1.0>,
  729. XX        <<a>, <>>, <<a>, T>, <<a>, F>, <<a>, <<a>>>,
  730. XX         <<a, <b>, <c, <d>>, e>, <a, <b>, <c, <d>>, e>>,
  731. XX         <<a, <b>, <c, <d>>, e>, <a, <b>, <c, <f>>, e>>>
  732. XX
  733. XX# only test geq on atoms, chars and numbers. Particular implementations
  734. XX# may have it defined for other values as well, but that is not portable
  735. XXDef testgeq \/and o aa = o
  736. XX       (bu trans <T, T, F, T, T, F, T, T, F, T, T, F, T, T, F, T, T, F>) o
  737. XX       aa >= o
  738. XX       _<<1, 0>, <1, 1>, <1, 2>,
  739. XX         <1.0, 0.99>, <1.0, 1.0>, <1.0, 1.01>,
  740. XX         <1, 0.99>, <1, 1.0>, <1, 1.01>,
  741. XX         <1.01, 1>, <1.0, 1>, <0.99, 1>,
  742. XX         <m, a>, <m, m>, <m, z>,
  743. XX         <'m, 'a>, <'m, 'm>, <'m, 'z>>
  744. XX
  745. XXDef testgreater \/and o aa = o
  746. XX       (bu trans <T, F, F, T, F, F, T, F, F, T, F, F, T, F, F, T, F, F>) o
  747. XX       aa > o
  748. XX       _<<1, 0>, <1, 1>, <1, 2>,
  749. XX         <1.0, 0.99>, <1.0, 1.0>, <1.0, 1.01>,
  750. XX         <1, 0.99>, <1, 1.0>, <1, 1.01>,
  751. XX         <1.01, 1>, <1.0, 1>, <0.99, 1>,
  752. XX         <m, a>, <m, m>, <m, z>,
  753. XX         <'m, 'a>, <'m, 'm>, <'m, 'z>>
  754. XX
  755. XXDef testid \/and o aa = o
  756. XX       (bu trans <1, a, 'a, 1.0, T, F, <>, "id", <id, 1, x>>) o
  757. XX       aa id o  _<1, a, 'a, 1.0, T, F, <>, "id", <id, 1, x>>
  758. XX
  759. XXDef testiota \/and o aa = o
  760. XX       (bu trans <<>, <1>, <1, 2>, <1, 2, 3, 4, 5, 6, 7, 8, 9, 10>>) o
  761. XX       aa iota o _<0, 1, 2, 10>
  762. XX
  763. XXDef testlength \/and o aa = o
  764. XX       (bu trans <0, 1, 1, 2, 3, 4, 10>) o
  765. XX       aa length o
  766. XX       _<<>, <1>, <<<>>>, <<a, b, c>, <d, e>>, "xyz", "four", "lenght ten">
  767. XX
  768. XXDef testleq \/and o aa = o
  769. XX       (bu trans <F, T, T, F, T, T, F, T, T, F, T, T, F, T, T, F, T, T>) o
  770. XX       aa <= o
  771. XX       _<<1, 0>, <1, 1>, <1, 2>,
  772. XX         <1.0, 0.99>, <1.0, 1.0>, <1.0, 1.01>,
  773. XX         <1, 0.99>, <1, 1.0>, <1, 1.01>,
  774. XX         <1.01, 1>, <1.0, 1>, <0.99, 1>,
  775. XX         <m, a>, <m, m>, <m, z>,
  776. XX         <'m, 'a>, <'m, 'm>, <'m, 'z>>
  777. XX
  778. XXDef testless \/and o aa = o
  779. XX       (bu trans <F, F, T, F, F, T, F, F, T, F, F, T, F, F, T, F, F, T>) o
  780. XX       aa < o
  781. XX       _<<1, 0>, <1, 1>, <1, 2>,
  782. XX         <1.0, 0.99>, <1.0, 1.0>, <1.0, 1.01>,
  783. XX         <1, 0.99>, <1, 1.0>, <1, 1.01>,
  784. XX         <1.01, 1>, <1.0, 1>, <0.99, 1>,
  785. XX         <m, a>, <m, m>, <m, z>,
  786. XX         <'m, 'a>, <'m, 'm>, <'m, 'z>>
  787. XX
  788. XXDef testminus \/and o aa = o
  789. XX       (bu trans <1, -1, 0, 11, -5, 3, -5>) o
  790. XX       aa - o
  791. XX       _<<1, 0>, <0, 1>, <1, 1>, <7, -4>, <-3, 2>, <-5, -8>, <-8, -3>>
  792. XX
  793. XXDef testmod \/and o aa = o
  794. XX       (bu trans <0, 0, 1, 0, 1, 16, 3>) o
  795. XX       aa mod o
  796. XX       _<<1, 1>, <10, 10>, <1, 2>, <2, 1>, <35, -3>, <-35, 17>, <-27, -4>>
  797. XX
  798. XXDef testneg \/and o aa = o (bu trans <0, 0, 1, -1.0, 15.2, -17>) o
  799. XX       aa neg o _<0, -0, -1, 1.0, -15.2, 17>
  800. XX
  801. XXDef testnot \/and o aa = o (bu trans <T, F>) o aa not o _<F, T>
  802. XX
  803. XXDef testnoteq \/and o aa = o
  804. XX       (bu trans
  805. XX        <F, T, T, T, F, T, T, T, T, T,
  806. XX         F, T, T, T, T, T, T, T, T,
  807. XX         F, T, T, T, T, T, T, T, T,
  808. XX         F, T, F, T, T, T, T, T, T, T,
  809. XX         F, T, T, T, T, T, T,
  810. XX         F, T, T, T, T, T, T,
  811. XX         F, T, T, T, T, T, T,
  812. XX         F, T, T, T, T, T, T, T, T,
  813. XX         F, T>) o aa != o
  814. XX       _<<1, 1>, <1, 0>, <1, a>, <1, 'a>, <1, 1.0>, <1, 0.99>,
  815. XX        <1, <>>, <1, T>, <1, F>, <1, <1>>,
  816. XX         <a, a>, <a, b>, <a, 1>, <a, 'a>, <a, 1.0>, <a, <>>,
  817. XX        <a, T>, <a, F>, <a, <a>>,
  818. XX         <'a, 'a>, <'a, 'b>, <'a, 1>, <'a, a>, <'a, 1.0>, <'a, <>>,
  819. XX        <'a, T>, <'a, F>, <'a, <'a>>,
  820. XX         <1.0, 1.0>, <1.0, 2.0>, <1.0, 1>, <1.1, 1>, <1.0, 'a>, <1.0, a>,
  821. XX        <1.0, <>>, <1.0, T>, <1.0, F>, <1.0, <1.0>>,
  822. XX         <T, T>, <T, 1>, <T, 'T>, <T, 1.0>, <T, <>>, <T, F>, <T, <T>>,
  823. XX         <F, F>, <F, 1>, <F, 'F>, <F, 1.0>, <F, <>>, <F, T>, <F, <F>>,
  824. XX         <<>, <>>, <<>, 1>, <<>, 'F>, <<>, 1.0>, <<>, T>, <<>, F>,
  825. XX        <<>, <<>>>,
  826. XX         <<a>, <a>>, <<a>, <b>>, <<a>, 1>, <<a>, 'a>, <<a>, 1.0>,
  827. XX        <<a>, <>>, <<a>, T>, <<a>, F>, <<a>, <<a>>>,
  828. XX         <<a, <b>, <c, <d>>, e>, <a, <b>, <c, <d>>, e>>,
  829. XX         <<a, <b>, <c, <d>>, e>, <a, <b>, <c, <f>>, e>>>
  830. XX
  831. XXDef testnull \/and o aa = o
  832. XX       (bu trans <T, F, F, F, F, F, F, T, F, F, F>) o
  833. XX       aa null o _<<>, 0, 1, a, '0, T, F, "", "nil", <nil>,
  834. XX               <m, <o, n>, <<s>, t, e>, r>>
  835. XX
  836. XXDef testor \/and o aa = o
  837. XX       (bu trans <F, T, T, T>) o aa or o _<<F, F>, <F, T>, <T, F>, <T, T>>
  838. XX
  839. XXDef testplus \/and o aa = o
  840. XX       (bu trans <0, 2, 1, 1, -2, 3, -9>) o
  841. XX       aa + o _<<0, 0>, <1, 1>, <1, 0>, <0, 1>, <1, -3>, <-5, 8>, <-4, -5>>
  842. XX
  843. XXDef testreverse \/and o aa = o
  844. XX       (bu trans
  845. XX           <<>, <a>, <b, a>, <4, 3, 2, 1>, <<e, f>, <c, d>, <a, b>>>) o
  846. XX       aa reverse o
  847. XX       _<<>, <a>, <a, b>, <1, 2, 3, 4>, <<a, b>, <c, d>, <e, f>>>
  848. XX
  849. XXDef testrotl \/and o aa = o
  850. XX       (bu trans
  851. XX           <<>, <a>, <b, a>, <2, 3, 4, 5, 1>, <<r, s>, <t, u>, <p, q>>>) o
  852. XX       aa rotl o
  853. XX       _<<>, <a>, <a, b>, <1, 2, 3, 4, 5>, <<p, q>, <r, s>, <t, u>>>
  854. XX
  855. XXDef testrotr \/and o aa = o
  856. XX       (bu trans
  857. XX           <<>, <a>, <b, a>, <5, 1, 2, 3, 4>, <<t, u>, <p, q>, <r, s>>>) o
  858. XX       aa rotr o
  859. XX       _<<>, <a>, <a, b>, <1, 2, 3, 4, 5>, <<p, q>, <r, s>, <t, u>>>
  860. XX
  861. XXDef testtimes \/and o aa = o
  862. XX       (bu trans <0, 0, 0, 9, -2, -4, 6, 6, 28, -18, -10>) o
  863. XX       aa * o
  864. XX       _<<0, 0>, <0, 5>, <1, 0>, <1, 9>, <1, -2>, <-1, 4>, <-1, -6>,
  865. XX         <-2, -3>, <4, 7>, <-6, 3>, <5, -2>>
  866. XX
  867. XXDef testtl \/and o aa = o
  868. XX       (bu trans <<>, <a>, <a, b, c>, <<>>, <<a>>, <<a>, <b>>>) o
  869. XX       aa tl o
  870. XX       _<<a>, <1, a>, <z, a, b, c>, <a, <>>, <x, <a>>, <<x>, <a>, <b>>>
  871. XX
  872. XXDef testtlr \/and o aa = o
  873. XX       (bu trans <<>, <a>, <a, b, c>, <<>>, <<a>>, <<a>, <b>>>) o
  874. XX       aa tlr o
  875. XX       _<<a>, <a, b>, <a, b, c, d>, <<>, a>, <<a>, x>, <<a>, <b>, <c>>>
  876. XX
  877. XXDef testtrans \/and o aa = o
  878. XX       (bu trans
  879. XX        <<>, <>, <>,
  880. XX         <<a>, <b>, <c>, <d>, <e>, <f>>, <<1, 2, 3, 4, 5>>,
  881. XX         <<a, c>, <b, d>>, <<a, 1, x>, <b, 2, y>, <c, 3, z>>,
  882. XX         <<a, 1, l>, <b, 2, m>, <c, 3, n>, <d, 4, o>, <e, 5, p>>>) o
  883. XX       aa trans o
  884. XX       _<<<>>, <<>, <>>, <<>, <>, <>, <>, <>>,
  885. XX         <<a, b, c, d, e, f>>, <<1>, <2>, <3>, <4>, <5>>,
  886. XX         <<a, b>, <c, d>>, <<a, b, c>, <1, 2, 3>, <x, y, z>>,
  887. XX         <<a, b, c, d, e>, <1, 2, 3, 4, 5>, <l, m, n, o, p>>>
  888. SHAR_EOF
  889. if test 8494 -ne "`wc -c prims.fp`"
  890. then
  891. echo shar: error transmitting prims.fp '(should have been 8494 characters)'
  892. fi
  893. echo shar: extracting y.tab.c '(12220 characters)'
  894. sed 's/^XX//' << \SHAR_EOF > y.tab.c
  895. XX# define Def 257
  896. XX# define Symbol 258
  897. XX# define Sel 259
  898. XX# define Rsel 260
  899. XX# define Then 261
  900. XX# define Else 262
  901. XX# define Compose 263
  902. XX# define Alpha 264
  903. XX# define Insert 265
  904. XX# define Rinsert 266
  905. XX# define Tree 267
  906. XX# define Bu 268
  907. XX# define Bur 269
  908. XX# define While 270
  909. XX# define  _ 95
  910. XX# define Div 271
  911. XX# define Geq 272
  912. XX# define Leq 273
  913. XX# define Noteq 274
  914. XX# define TrueConst 275
  915. XX# define FalseConst 276
  916. XX# define String 277
  917. XX# define CharConst 278
  918. XX# define Float 279
  919. XX#define yyclearin yychar = -1
  920. XX#define yyerrok yyerrflag = 0
  921. XXextern int yychar;
  922. XXextern short yyerrflag;
  923. XX#ifndef YYMAXDEPTH
  924. XX#define YYMAXDEPTH 150
  925. XX#endif
  926. XX#ifndef YYSTYPE
  927. XX#define YYSTYPE int
  928. XX#endif
  929. XXYYSTYPE yylval, yyval;
  930. XX# define YYERRCODE 256
  931. XX
  932. XX# line 157 "fpg.y"
  933. XX
  934. XX
  935. XX#include "lex.yy.c"
  936. XX
  937. XX#undef YYMAXDEPTH
  938. XX#define YYMAXDEPTH 2048
  939. XX
  940. XXvoid parsefnstart ();
  941. XXvoid parsefnend ();
  942. XXvoid parsethen ();
  943. XXvoid parseelse ();
  944. XXvoid parseendif ();
  945. XXvoid parsebustart ();
  946. XXvoid parsebufun ();
  947. XXvoid parsebuobj ();
  948. XXvoid whilestart ();
  949. XXvoid whilepred ();
  950. XXvoid whilefun ();
  951. XXvoid parsecomp ();
  952. XXvoid startcomp ();
  953. XXvoid endcomp ();
  954. XXvoid parseaa ();
  955. XXvoid parseconstr ();
  956. XXvoid constrnext ();
  957. XXvoid endconstr ();
  958. XXvoid parseinsert ();
  959. XXvoid endinsert ();
  960. XXvoid parsesel ();
  961. XXvoid parsefncall ();
  962. XXvoid parsenil ();
  963. XXvoid consttrue ();
  964. XXvoid constfalse ();
  965. XXvoid constnum ();
  966. XXvoid constsym ();
  967. XXvoid conststr ();
  968. XXvoid constchr ();
  969. XXvoid constreal ();
  970. XXvoid liststart ();
  971. XXvoid listnext ();
  972. XXvoid listend ();
  973. XX
  974. XXshort yyexca[] ={
  975. XX-1, 1,
  976. XX    0, -1,
  977. XX    -2, 0,
  978. XX    };
  979. XX# define YYNPROD 70
  980. XX# define YYLAST 275
  981. XXshort yyact[]={
  982. XX
  983. XX  13,  37,  25,  23,  84,  24,  33,   5,   3,  81,
  984. XX  45,   7,  40,   8,  91,  72,  88,   2,  82,   4,
  985. XX  28,  27,  29,  73,  12,  89,  44,  43,  42,  67,
  986. XX  41,  79,  90,  38,  65,  77,  36,  76,  53,  39,
  987. XX  13,  35,  25,  23,  75,  24,  62,  63,  64,  34,
  988. XX  66,  15,  92,  68,  61,  19,   6,   1,  80,   0,
  989. XX  28,  27,  29,   0,   0,   0,   0,  69,  70,  71,
  990. XX   0,   0,   0,  74,   0,   0,   0,   0,   0,  78,
  991. XX   0,   0,   0,   0,  83,   0,  85,  86,   0,  87,
  992. XX   0,  15,   0,   0,   0,  19,   0,   0,   0,   0,
  993. XX   0,  93,  94,   0,  95,   0,   0,   0,   0,   0,
  994. XX   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  995. XX   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  996. XX   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  997. XX   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  998. XX   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  999. XX   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  1000. XX   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  1001. XX   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  1002. XX   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  1003. XX   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  1004. XX   0,   0,   0,   0,   0,   0,   0,   0,  22,  20,
  1005. XX  21,   0,   0,   0,  14,  16,  17,  18,   9,  10,
  1006. XX  11,  26,  30,  31,  32,  54,  49,  48,   0,   0,
  1007. XX   0,  56,  55,   0,   0,   0,  58,  59,  60,  57,
  1008. XX   0,   0,   0,  46,  47,  50,  51,  52,  22,  20,
  1009. XX  21,   0,   0,   0,  14,  16,  17,  18,   0,   0,
  1010. XX   0,  26,  30,  31,  32 };
  1011. XXshort yypact[]={
  1012. XX
  1013. XX-249,-249,-1000,-251,-1000,-1000, -40,-1000,-255,-1000,
  1014. XX-1000,-1000,-262,-1000,   0, -81,-1000,-1000,-1000, -22,
  1015. XX-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
  1016. XX-1000,-1000,-1000,-1000, -40, -40, -40,-1000, -40,-1000,
  1017. XX-1000, -40,   0,   0,   0,-1000,-1000,-1000,-1000,-1000,
  1018. XX-1000,-1000,-1000, -47,-1000,-1000,-1000,-1000,-1000,-1000,
  1019. XX-1000, -40,-1000,-1000,-1000,   0,-1000, -35,-1000,-1000,
  1020. XX-1000,-1000,-1000, -22,-258, -22, -22, -40,-1000, -25,
  1021. XX-1000,-1000, -30,-1000,-1000,-1000,-1000,-1000,-1000, -40,
  1022. XX-1000, -22, -40,-1000,-1000,-1000 };
  1023. XXshort yypgo[]={
  1024. XX
  1025. XX   0,  57,  17,  56,  11,  13,  54,  52,  49,  44,
  1026. XX  10,  41,  37,  36,  35,  24,  34,  33,  31,  30,
  1027. XX  29,  28,  27,  26,  25,  23,  18 };
  1028. XXshort yyr1[]={
  1029. XX
  1030. XX   0,   1,   1,   3,   2,   6,   7,   4,   8,   9,
  1031. XX   4,  11,  12,   4,  13,  14,   4,   4,   5,  16,
  1032. XX   5,  17,  18,  15,  15,  15,  19,  15,  21,  15,
  1033. XX  22,  15,  23,  15,  15,  15,  15,  15,  15,  15,
  1034. XX  15,  15,  15,  15,  15,  15,  15,  15,  20,  24,
  1035. XX  20,  10,  10,  10,  10,  10,  10,  10,  10,  25,
  1036. XX  10,  10,  10,  10,  10,  10,  10,  10,  26,  26 };
  1037. XXshort yyr2[]={
  1038. XX
  1039. XX   0,   1,   2,   0,   4,   0,   0,   7,   0,   0,
  1040. XX   5,   0,   0,   5,   0,   0,   5,   1,   1,   0,
  1041. XX   4,   0,   0,   5,   2,   2,   0,   4,   0,   3,
  1042. XX   0,   3,   0,   3,   2,   1,   1,   1,   1,   1,
  1043. XX   1,   1,   1,   1,   1,   1,   1,   1,   1,   0,
  1044. XX   4,   1,   1,   1,   1,   1,   1,   1,   2,   0,
  1045. XX   4,   1,   1,   1,   1,   1,   1,   1,   1,   3 };
  1046. XXshort yychk[]={
  1047. XX
  1048. XX-1000,  -1,  -2, 257,  -2, 258,  -3,  -4,  -5, 268,
  1049. XX 269, 270, -15,  40, 264,  91, 265, 266, 267,  95,
  1050. XX 259, 260, 258,  43,  45,  42, 271,  61,  60,  62,
  1051. XX 272, 273, 274, 261,  -8, -11, -13, 263, -17, -15,
  1052. XX  93, -19, -21, -22, -23, -10, 275, 276, 259, 258,
  1053. XX 277, 278, 279,  60, 257, 264, 263, 271, 268, 269,
  1054. XX 270,  -6,  -4,  -4,  -4, -16,  -4, -20,  -4, -15,
  1055. XX -15, -15,  62, -25,  -4,  -9, -12, -14,  -5, -18,
  1056. XX  93,  44, -26, -10, 262, -10, -10,  -4,  41, -24,
  1057. XX  62,  44,  -7,  -4, -10,  -4 };
  1058. XXshort yydef[]={
  1059. XX
  1060. XX   0,  -2,   1,   0,   2,   3,   0,   4,  17,   8,
  1061. XX  11,  14,  18,  21,   0,  26,  28,  30,  32,   0,
  1062. XX  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
  1063. XX  45,  46,  47,   5,   0,   0,   0,  19,   0,  24,
  1064. XX  25,   0,   0,   0,   0,  34,  51,  52,  53,  54,
  1065. XX  55,  56,  57,  59,  61,  62,  63,  64,  65,  66,
  1066. XX  67,   0,   9,  12,  15,   0,  22,   0,  48,  29,
  1067. XX  31,  33,  58,   0,   0,   0,   0,   0,  20,   0,
  1068. XX  27,  49,   0,  68,   6,  10,  13,  16,  23,   0,
  1069. XX  60,   0,   0,  50,  69,   7 };
  1070. XX#ifndef lint
  1071. XXstatic char yaccpar_sccsid[] = "@(#)yaccpar    4.1    (Berkeley)    2/11/83";
  1072. XX#endif not lint
  1073. XX
  1074. XX#
  1075. XX# define YYFLAG -1000
  1076. XX# define YYERROR goto yyerrlab
  1077. XX# define YYACCEPT return(0)
  1078. XX# define YYABORT return(1)
  1079. XX
  1080. XX/*    parser for yacc output    */
  1081. XX
  1082. XX#ifdef YYDEBUG
  1083. XXint yydebug = 0; /* 1 for debugging */
  1084. XX#endif
  1085. XXYYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
  1086. XXint yychar = -1; /* current input token number */
  1087. XXint yynerrs = 0;  /* number of errors */
  1088. XXshort yyerrflag = 0;  /* error recovery flag */
  1089. XX
  1090. XXyyparse() {
  1091. XX
  1092. XX    short yys[YYMAXDEPTH];
  1093. XX    short yyj, yym;
  1094. XX    register YYSTYPE *yypvt;
  1095. XX    register short yystate, *yyps, yyn;
  1096. XX    register YYSTYPE *yypv;
  1097. XX    register short *yyxi;
  1098. XX
  1099. XX    yystate = 0;
  1100. XX    yychar = -1;
  1101. XX    yynerrs = 0;
  1102. XX    yyerrflag = 0;
  1103. XX    yyps= &yys[-1];
  1104. XX    yypv= &yyv[-1];
  1105. XX
  1106. XX yystack:    /* put a state and value onto the stack */
  1107. XX
  1108. XX#ifdef YYDEBUG
  1109. XX    if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
  1110. XX#endif
  1111. XX        if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
  1112. XX        *yyps = yystate;
  1113. XX        ++yypv;
  1114. XX        *yypv = yyval;
  1115. XX
  1116. XX yynewstate:
  1117. XX
  1118. XX    yyn = yypact[yystate];
  1119. XX
  1120. XX    if( yyn<= YYFLAG ) goto yydefault; /* simple state */
  1121. XX
  1122. XX    if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
  1123. XX    if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
  1124. XX
  1125. XX    if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
  1126. XX        yychar = -1;
  1127. XX        yyval = yylval;
  1128. XX        yystate = yyn;
  1129. XX        if( yyerrflag > 0 ) --yyerrflag;
  1130. XX        goto yystack;
  1131. XX        }
  1132. XX
  1133. XX yydefault:
  1134. XX    /* default state action */
  1135. XX
  1136. XX    if( (yyn=yydef[yystate]) == -2 ) {
  1137. XX        if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
  1138. XX        /* look through exception table */
  1139. XX
  1140. XX        for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
  1141. XX
  1142. XX        while( *(yyxi+=2) >= 0 ){
  1143. XX            if( *yyxi == yychar ) break;
  1144. XX            }
  1145. XX        if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
  1146. XX        }
  1147. XX
  1148. XX    if( yyn == 0 ){ /* error */
  1149. XX        /* error ... attempt to resume parsing */
  1150. XX
  1151. XX        switch( yyerrflag ){
  1152. XX
  1153. XX        case 0:   /* brand new error */
  1154. XX
  1155. XX            yyerror( "syntax error" );
  1156. XX        yyerrlab:
  1157. XX            ++yynerrs;
  1158. XX
  1159. XX        case 1:
  1160. XX        case 2: /* incompletely recovered error ... try again */
  1161. XX
  1162. XX            yyerrflag = 3;
  1163. XX
  1164. XX            /* find a state where "error" is a legal shift action */
  1165. XX
  1166. XX            while ( yyps >= yys ) {
  1167. XX               yyn = yypact[*yyps] + YYERRCODE;
  1168. XX               if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
  1169. XX                  yystate = yyact[yyn];  /* simulate a shift of "error" */
  1170. XX                  goto yystack;
  1171. XX                  }
  1172. XX               yyn = yypact[*yyps];
  1173. XX
  1174. XX               /* the current yyps has no shift onn "error", pop stack */
  1175. XX
  1176. XX#ifdef YYDEBUG
  1177. XX               if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
  1178. XX#endif
  1179. XX               --yyps;
  1180. XX               --yypv;
  1181. XX               }
  1182. XX
  1183. XX            /* there is no state on the stack with an error shift ... abort */
  1184. XX
  1185. XX    yyabort:
  1186. XX            return(1);
  1187. XX
  1188. XX
  1189. XX        case 3:  /* no shift yet; clobber input char */
  1190. XX
  1191. XX#ifdef YYDEBUG
  1192. XX            if( yydebug ) printf( "error recovery discards char %d\n", yychar );
  1193. XX#endif
  1194. XX
  1195. XX            if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
  1196. XX            yychar = -1;
  1197. XX            goto yynewstate;   /* try again in the same state */
  1198. XX
  1199. XX            }
  1200. XX
  1201. XX        }
  1202. XX
  1203. XX    /* reduction by production yyn */
  1204. XX
  1205. XX#ifdef YYDEBUG
  1206. XX        if( yydebug ) printf("reduce %d\n",yyn);
  1207. XX#endif
  1208. XX        yyps -= yyr2[yyn];
  1209. XX        yypvt = yypv;
  1210. XX        yypv -= yyr2[yyn];
  1211. XX        yyval = yypv[1];
  1212. XX        yym=yyn;
  1213. XX            /* consult goto table to find next state */
  1214. XX        yyn = yyr1[yyn];
  1215. XX        yyj = yypgo[yyn] + *yyps + 1;
  1216. XX        if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
  1217. XX        switch(yym){
  1218. XX            
  1219. XXcase 3:
  1220. XX# line 13 "fpg.y"
  1221. XX{ parsefnstart (yytext); } break;
  1222. XXcase 4:
  1223. XX# line 14 "fpg.y"
  1224. XX{ parsefnend (); } break;
  1225. XXcase 5:
  1226. XX# line 19 "fpg.y"
  1227. XX{ parsethen (); } break;
  1228. XXcase 6:
  1229. XX# line 22 "fpg.y"
  1230. XX{ parseelse (); } break;
  1231. XXcase 7:
  1232. XX# line 24 "fpg.y"
  1233. XX{ parseendif (); } break;
  1234. XXcase 8:
  1235. XX# line 26 "fpg.y"
  1236. XX{ parsebustart (0); } break;
  1237. XXcase 9:
  1238. XX# line 28 "fpg.y"
  1239. XX{ parsebufun (); } break;
  1240. XXcase 10:
  1241. XX# line 30 "fpg.y"
  1242. XX{ parsebuobj (); } break;
  1243. XXcase 11:
  1244. XX# line 32 "fpg.y"
  1245. XX{ parsebustart (1); } break;
  1246. XXcase 12:
  1247. XX# line 34 "fpg.y"
  1248. XX{ parsebufun (); } break;
  1249. XXcase 13:
  1250. XX# line 36 "fpg.y"
  1251. XX{ parsebuobj (); } break;
  1252. XXcase 14:
  1253. XX# line 38 "fpg.y"
  1254. XX{ whilestart (); } break;
  1255. XXcase 15:
  1256. XX# line 40 "fpg.y"
  1257. XX{ whilepred (); } break;
  1258. XXcase 16:
  1259. XX# line 42 "fpg.y"
  1260. XX{ whilefun (); } break;
  1261. XXcase 19:
  1262. XX# line 49 "fpg.y"
  1263. XX{ parsecomp (); } break;
  1264. XXcase 21:
  1265. XX# line 54 "fpg.y"
  1266. XX{ startcomp (); } break;
  1267. XXcase 22:
  1268. XX# line 56 "fpg.y"
  1269. XX{ endcomp (); } break;
  1270. XXcase 24:
  1271. XX# line 60 "fpg.y"
  1272. XX{ parseaa (); } break;
  1273. XXcase 25:
  1274. XX# line 62 "fpg.y"
  1275. XX{ parsenil (); } break;
  1276. XXcase 26:
  1277. XX# line 64 "fpg.y"
  1278. XX{ parseconstr (); } break;
  1279. XXcase 27:
  1280. XX# line 67 "fpg.y"
  1281. XX{ constrnext (); endconstr (); } break;
  1282. XXcase 28:
  1283. XX# line 69 "fpg.y"
  1284. XX{ parseinsert (0); } break;
  1285. XXcase 29:
  1286. XX# line 71 "fpg.y"
  1287. XX{ endinsert (); } break;
  1288. XXcase 30:
  1289. XX# line 73 "fpg.y"
  1290. XX{ parseinsert (1); } break;
  1291. XXcase 31:
  1292. XX# line 75 "fpg.y"
  1293. XX{ endinsert (); } break;
  1294. XXcase 32:
  1295. XX# line 77 "fpg.y"
  1296. XX{ parseinsert (2); } break;
  1297. XXcase 33:
  1298. XX# line 79 "fpg.y"
  1299. XX{ endinsert (); } break;
  1300. XXcase 35:
  1301. XX# line 82 "fpg.y"
  1302. XX{ parsesel (yytext, 0); } break;
  1303. XXcase 36:
  1304. XX# line 84 "fpg.y"
  1305. XX{ parsesel (yytext, 1); } break;
  1306. XXcase 37:
  1307. XX# line 86 "fpg.y"
  1308. XX{ parsefncall (yytext); } break;
  1309. XXcase 38:
  1310. XX# line 88 "fpg.y"
  1311. XX{ parsefncall ("plus"); } break;
  1312. XXcase 39:
  1313. XX# line 90 "fpg.y"
  1314. XX{ parsefncall ("minus"); } break;
  1315. XXcase 40:
  1316. XX# line 92 "fpg.y"
  1317. XX{ parsefncall ("times"); } break;
  1318. XXcase 41:
  1319. XX# line 94 "fpg.y"
  1320. XX{ parsefncall ("div"); } break;
  1321. XXcase 42:
  1322. XX# line 96 "fpg.y"
  1323. XX{ parsefncall ("eq"); } break;
  1324. XXcase 43:
  1325. XX# line 98 "fpg.y"
  1326. XX{ parsefncall ("less"); } break;
  1327. XXcase 44:
  1328. XX# line 100 "fpg.y"
  1329. XX{ parsefncall ("greater"); } break;
  1330. XXcase 45:
  1331. XX# line 102 "fpg.y"
  1332. XX{ parsefncall ("gequal"); } break;
  1333. XXcase 46:
  1334. XX# line 104 "fpg.y"
  1335. XX{ parsefncall ("lequal"); } break;
  1336. XXcase 47:
  1337. XX# line 106 "fpg.y"
  1338. XX{ parsefncall ("notequal"); } break;
  1339. XXcase 49:
  1340. XX# line 111 "fpg.y"
  1341. XX{ constrnext (); } break;
  1342. XXcase 51:
  1343. XX# line 115 "fpg.y"
  1344. XX{ consttrue (); } break;
  1345. XXcase 52:
  1346. XX# line 117 "fpg.y"
  1347. XX{ constfalse (); } break;
  1348. XXcase 53:
  1349. XX# line 119 "fpg.y"
  1350. XX{ constnum (yytext); } break;
  1351. XXcase 54:
  1352. XX# line 121 "fpg.y"
  1353. XX{ constsym (yytext); } break;
  1354. XXcase 55:
  1355. XX# line 123 "fpg.y"
  1356. XX{ conststr (yytext); } break;
  1357. XXcase 56:
  1358. XX# line 125 "fpg.y"
  1359. XX{ constchr (yytext); } break;
  1360. XXcase 57:
  1361. XX# line 127 "fpg.y"
  1362. XX{ constreal (yytext); } break;
  1363. XXcase 58:
  1364. XX# line 129 "fpg.y"
  1365. XX{ parsenil (); } break;
  1366. XXcase 59:
  1367. XX# line 131 "fpg.y"
  1368. XX{ liststart (); } break;
  1369. XXcase 60:
  1370. XX# line 134 "fpg.y"
  1371. XX{ listend (); } break;
  1372. XXcase 61:
  1373. XX# line 136 "fpg.y"
  1374. XX{ constsym ("Def"); } break;
  1375. XXcase 62:
  1376. XX# line 138 "fpg.y"
  1377. XX{ constsym ("aa"); } break;
  1378. XXcase 63:
  1379. XX# line 140 "fpg.y"
  1380. XX{ constsym ("o"); } break;
  1381. XXcase 64:
  1382. XX# line 142 "fpg.y"
  1383. XX{ constsym ("div"); } break;
  1384. XXcase 65:
  1385. XX# line 144 "fpg.y"
  1386. XX{ constsym ("bu"); } break;
  1387. XXcase 66:
  1388. XX# line 146 "fpg.y"
  1389. XX{ constsym ("bur"); } break;
  1390. XXcase 67:
  1391. XX# line 148 "fpg.y"
  1392. XX{ constsym ("while"); } break;
  1393. XXcase 68:
  1394. XX# line 152 "fpg.y"
  1395. XX{ listnext (); } break;
  1396. XXcase 69:
  1397. XX# line 155 "fpg.y"
  1398. XX{ listnext (); } break; 
  1399. XX        }
  1400. XX        goto yystack;  /* stack new state and value */
  1401. XX
  1402. XX    }
  1403. SHAR_EOF
  1404. if test 12220 -ne "`wc -c y.tab.c`"
  1405. then
  1406. echo shar: error transmitting y.tab.c '(should have been 12220 characters)'
  1407. fi
  1408. #    End of shell archive
  1409. exit 0
  1410.  
  1411.