home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / hugs101.zip / hugs101sc.zip / hugsdist / src / parser.c < prev    next >
C/C++ Source or Header  |  1995-03-02  |  46KB  |  1,599 lines

  1. /* A YACC parser generated from "parser.y" */
  2.  
  3. # line 19
  4. #ifndef lint
  5. #define lint
  6. #endif
  7. #define defTycon(n,l,lhs,rhs,w)     tyconDefn(intOf(l),lhs,rhs,w); sp-=n
  8. #define sigdecl(l,vs,t)         ap(SIGDECL,triple(l,vs,t))
  9. #define grded(gs)         ap(GUARDED,gs)
  10. #define letrec(bs,e)         (nonNull(bs) ? ap(LETREC,pair(bs,e)) : e)
  11. #define yyerror(s)         /* errors handled elsewhere */
  12. #define YYSTYPE             Cell
  13.  
  14. static Cell   local gcShadow     Args((Int,Cell));
  15. static Void   local syntaxError  Args((String));
  16. static String local unexpected   Args((Void));
  17. static Cell   local checkPrec    Args((Cell));
  18. static Void   local fixDefn      Args((Syntax,Cell,Cell,List));
  19. static Void   local setSyntax    Args((Int,Syntax,Cell));
  20. static Cell   local buildTuple   Args((List));
  21. static Cell   local checkClass   Args((Cell));
  22. static Cell   local checkInst     Args((Cell));
  23. static List   local tupToList    Args((Cell));
  24. static List   local checkContext Args((List));
  25. static Cell   local checkTyLhs     Args((Cell));
  26. static Cell   local tidyInfix    Args((Cell));
  27.  
  28. /* For the purposes of reasonably portable garbage collection, it is
  29.  * necessary to simulate the YACC stack on the Hugs stack to keep
  30.  * track of all intermediate constructs.  The lexical analyser
  31.  * pushes a token onto the stack for each token that is found, with
  32.  * these elements being removed as reduce actions are performed,
  33.  * taking account of look-ahead tokens as described by gcShadow()
  34.  * below.
  35.  *
  36.  * Of the non-terminals used below, only start, topDecl & begin do not leave
  37.  * any values on the Hugs stack.  The same is true for the terminals
  38.  * EVALEX and SCRIPT.  At the end of a successful parse, there should only
  39.  * be one element left on the stack, containing the result of the parse.
  40.  */
  41.  
  42. #define gc0(e)             gcShadow(0,e)
  43. #define gc1(e)             gcShadow(1,e)
  44. #define gc2(e)             gcShadow(2,e)
  45. #define gc3(e)             gcShadow(3,e)
  46. #define gc4(e)             gcShadow(4,e)
  47. #define gc5(e)             gcShadow(5,e)
  48. #define gc6(e)             gcShadow(6,e)
  49. #define gc7(e)             gcShadow(7,e)
  50.  
  51. #define EVALEX 257
  52. #define SCRIPT 258
  53. #define COCO 259
  54. #define INFIXL 260
  55. #define INFIXR 261
  56. #define INFIX 262
  57. #define FUNARROW 263
  58. #define UPTO 264
  59. #define CASEXP 265
  60. #define OF 266
  61. #define IF 267
  62. #define THEN 268
  63. #define ELSE 269
  64. #define WHERE 270
  65. #define TYPE 271
  66. #define DATA 272
  67. #define FROM 273
  68. #define LET 274
  69. #define IN 275
  70. #define VAROP 276
  71. #define VARID 277
  72. #define NUMLIT 278
  73. #define CHARLIT 279
  74. #define STRINGLIT 280
  75. #define REPEAT 281
  76. #define CONOP 282
  77. #define CONID 283
  78. #define TCLASS 284
  79. #define IMPLIES 285
  80. #define TINSTANCE 286
  81. #define DERIVING 287
  82. #define TRUNST 288
  83. #define PRIMITIVE 289
  84. #define DEFAULT 290
  85. #define HIDING 291
  86. #define IMPORT 292
  87. #define INTERFACE 293
  88. #define MODULE 294
  89. #define RENAMING 295
  90. #define TO 296
  91. #define yyclearin yychar = -1
  92. #define yyerrok yyerrflag = 0
  93. extern int yychar;
  94. extern short yyerrflag;
  95. #ifndef YYMAXDEPTH
  96. #define YYMAXDEPTH 150
  97. #endif
  98. #ifndef YYSTYPE
  99. #define YYSTYPE int
  100. #endif
  101. YYSTYPE yylval, yyval;
  102. # define YYERRCODE 256
  103.  
  104. #line 460
  105.  
  106.  
  107. static Cell local gcShadow(n,e)        /* keep parsed fragments on stack  */
  108. Int  n;
  109. Cell e; {
  110.     /* If a look ahead token is held then the required stack transformation
  111.      * is:
  112.      *   pushed: n               1     0          1     0
  113.      *           x1  |  ...  |  xn  |  la   ===>  e  |  la
  114.      *                                top()            top()
  115.      *
  116.      * Othwerwise, the transformation is:
  117.      *   pushed: n-1             0        0
  118.      *           x1  |  ...  |  xn  ===>  e
  119.      *                         top()     top()
  120.      */
  121.     if (yychar>=0) {
  122.     pushed(n-1) = top();
  123.         pushed(n)   = e;
  124.     }
  125.     else
  126.     pushed(n-1) = e;
  127.     sp -= (n-1);
  128.     return e;
  129. }
  130.  
  131. static Void local syntaxError(s)       /* report on syntax error           */
  132. String s; {
  133.     ERROR(row) "Syntax error in %s (unexpected %s)", s, unexpected()
  134.     EEND;
  135. }
  136.  
  137. static String local unexpected() {    /* find name for unexpected token  */
  138.     static char buffer[100];
  139.     static char *fmt = "%s \"%s\"";
  140.     static char *kwd = "keyword";
  141.     static char *hkw = "(Haskell) keyword";
  142.  
  143.     switch (yychar) {
  144.     case 0           : return "end of input";
  145.  
  146. #define keyword(kw) sprintf(buffer,fmt,kwd,kw); return buffer;
  147.     case INFIXL    : keyword("infixl");
  148.     case INFIXR    : keyword("infixr");
  149.     case INFIX     : keyword("infix");
  150.     case TINSTANCE : keyword("instance");
  151.     case TCLASS    : keyword("class");
  152.     case PRIMITIVE : keyword("primitive");
  153.     case CASEXP    : keyword("case");
  154.     case OF        : keyword("of");
  155.     case IF        : keyword("if");
  156.     case TRUNST    : keyword("runST");
  157.     case THEN      : keyword("then");
  158.     case ELSE      : keyword("else");
  159.     case WHERE     : keyword("where");
  160.     case TYPE      : keyword("type");
  161.     case DATA      : keyword("data");
  162.     case LET       : keyword("let");
  163.     case IN        : keyword("in");
  164.     case DERIVING  : keyword("deriving");
  165. #undef keyword
  166.  
  167. #define hasword(kw) sprintf(buffer,fmt,hkw,kw); return buffer;
  168.     case DEFAULT   : hasword("default");
  169.     case HIDING    : hasword("hiding");
  170.     case IMPORT    : hasword("import");
  171.     case INTERFACE : hasword("interface");
  172.     case MODULE    : hasword("module");
  173.     case RENAMING  : hasword("renaming");
  174.     case TO           : hasword("to");
  175. #undef hasword
  176.  
  177.     case FUNARROW  : return "`->'";
  178.     case '='       : return "`='";
  179.     case COCO      : return "`::'";
  180.     case '-'       : return "`-'";
  181.     case ','       : return "comma";
  182.     case '@'       : return "`@'";
  183.     case '('       : return "`('";
  184.     case ')'       : return "`)'";
  185.     case '|'       : return "`|'";
  186.     case ';'       : return "`;'";
  187.     case UPTO      : return "`..'";
  188.     case '['       : return "`['";
  189.     case ']'       : return "`]'";
  190.     case FROM      : return "`<-'";
  191.     case '\\'      : return "backslash (lambda)";
  192.     case '~'       : return "tilde";
  193.     case '`'       : return "backquote";
  194.     case VAROP     :
  195.     case VARID     :
  196.     case CONOP     :
  197.     case CONID     : sprintf(buffer,"symbol \"%s\"",
  198.                  textToStr(textOf(yylval)));
  199.              return buffer;
  200.     case NUMLIT    : return "numeric literal";
  201.     case CHARLIT   : return "character literal";
  202.     case STRINGLIT : return "string literal";
  203.     case IMPLIES   : return "`=>";
  204.     default           : return "token";
  205.     }
  206. }
  207.  
  208. static Cell local checkPrec(p)         /* Check for valid precedence value */
  209. Cell p; {
  210.     if (!isInt(p) || intOf(p)<MIN_PREC || intOf(p)>MAX_PREC) {
  211.         ERROR(row) "Precedence value must be an integer in the range [%d..%d]",
  212.                    MIN_PREC, MAX_PREC
  213.         EEND;
  214.     }
  215.     return p;
  216. }
  217.  
  218. static Void local fixDefn(a,line,p,ops)/* Declare syntax of operators      */
  219. Syntax a;
  220. Cell   line;
  221. Cell   p;
  222. List   ops; {
  223.     Int l = intOf(line);
  224.     a     = mkSyntax(a,intOf(p));
  225.     map2Proc(setSyntax,l,a,ops);
  226. }
  227.  
  228. static Void local setSyntax(line,sy,op)/* set syntax of individ. operator  */
  229. Int    line;
  230. Syntax sy;
  231. Cell   op; {
  232.     addSyntax(line,textOf(op),sy);
  233.     opDefns = cons(op,opDefns);
  234. }
  235.  
  236. static Cell local buildTuple(tup)      /* build tuple (x1,...,xn) from list*/
  237. List tup; {                            /* [xn,...,x1]                      */
  238.     Int  n = 0;
  239.     Cell t = tup;
  240.     Cell x;
  241.  
  242.     do {                               /*     .                    .       */
  243.         x      = fst(t);               /*    / \                  / \      */
  244.         fst(t) = snd(t);               /*   xn  .                .   xn    */
  245.         snd(t) = x;                    /*        .    ===>      .          */
  246.         x      = t;                    /*         .            .           */
  247.         t      = fun(x);               /*          .          .            */
  248.         n++;                           /*         / \        / \           */
  249.     } while (nonNull(t));              /*        x1  NIL   (n)  x1         */
  250.     fst(x) = mkTuple(n);
  251.     return tup;
  252. }
  253.  
  254. /* The yacc parser presented above is not sufficiently powerful to
  255.  * determine whether a tuple at the front of a sigType is part of a
  256.  * context:    e.g. (Eq a, Num a) => a -> a -> a
  257.  * or a type:  e.g.  (Tree a, Tree a) -> Tree a
  258.  *
  259.  * Rather than complicate the grammar, both are parsed as tuples of types,
  260.  * using the following checks afterwards to ensure that the correct syntax
  261.  * is used in the case of a tupled context.
  262.  */
  263.  
  264. static List local tupToList(tps)    /* Convert () | t | (t1,...,tn) to */
  265. Cell tps; {                /* a list of values:           */
  266.     if (tps==UNIT)            /*        [] | [t] | [t1,...,tn]   */
  267.     return NIL;
  268.     else if (whatIs(getHead(tps))==TUPLE) {
  269.     List qs = NIL;
  270.  
  271.     while (isAp(tps)) {        /* undo work of buildTuple  :-(    */
  272.         Cell temp = fun(tps);
  273.         fun(tps)  = arg(tps);
  274.         arg(tps)  = qs;
  275.         qs          = tps;
  276.         tps       = temp;
  277.     }
  278.     return qs;
  279.     }
  280.     else
  281.     return singleton(tps);
  282. }
  283.  
  284. static List local checkContext(con)    /* validate type class context       */
  285. Type con; {
  286.     mapOver(checkClass, con=tupToList(con));
  287.     return con;
  288. }
  289.  
  290. static Cell local checkClass(c)        /* check that type expr is a class */
  291. Cell c; {                /* constrnt of the form Class var  */
  292.     Cell cn = getHead(c);
  293.  
  294.     if (!isCon(cn))
  295.     syntaxError("class expression");
  296.     else if (argCount!=1) {
  297.     ERROR(row) "Class \"%s\" must have exactly one argument",
  298.            textToStr(textOf(cn))
  299.     EEND;
  300.     }
  301.     else if (whatIs(arg(c))!=VARIDCELL) {
  302.     ERROR(row) "Argument of class \"%s\" must be a variable",
  303.            /* Ha!  What do you think this is?  Gofer!? :-) */
  304.            textToStr(textOf(cn))
  305.     EEND;
  306.     }
  307.     return c;
  308. }
  309.  
  310. static Cell local checkInst(c)        /* check that type expr is a class */
  311. Cell c; {                /* constr of the form Class simple */
  312.     Cell cn = getHead(c);
  313.  
  314.     if (!isCon(cn))
  315.     syntaxError("class expression");
  316.     else if (argCount!=1) {
  317.     ERROR(row) "Class \"%s\" must have exactly one argument",
  318.            textToStr(textOf(cn))
  319.     EEND;
  320.     }
  321.     else {
  322.     Cell a  = arg(c);
  323.     Cell tn = getHead(a);
  324.     if (isCon(tn) || tn==ARROW || isTuple(tn) || tn==LIST || tn==UNIT) {
  325.         for (; isAp(a); a=fun(a))
  326.         if (whatIs(arg(a))!=VARIDCELL) {
  327.             ERROR(row) "Type variable expected in instance type"
  328.             EEND;
  329.         }
  330.     }
  331.     else {
  332.         ERROR(row) "Illegal type expression in instance declaration"
  333.         EEND;
  334.     }
  335.     }
  336.     return c;
  337. }
  338.  
  339. static Cell local checkTyLhs(c)        /* check that lhs is of the form   */
  340. Cell c; {                /* T a1 ... a               */
  341.     Cell tlhs = c;
  342.     while (isAp(tlhs) && whatIs(arg(tlhs))==VARIDCELL)
  343.     tlhs = fun(tlhs);
  344.     if (whatIs(tlhs)!=CONIDCELL) {
  345.     ERROR(row) "Illegal left hand side in datatype definition"
  346.     EEND;
  347.     }
  348.     return c;
  349. }
  350.  
  351. /* expressions involving a sequence of two or more infix operator symbols
  352.  * are parsed as elements of type:
  353.  *    InfixExpr ::= [Expr]
  354.  *         |  ap(ap(Operator,InfixExpr),Expr)
  355.  *
  356.  * thus x0 +1 x1 ... +n xn is parsed as: +n (....(+1 [x0] x1)....) xn
  357.  *
  358.  * Once the expression has been completely parsed, this parsed form is
  359.  * `tidied' according to the precedences and associativities declared for
  360.  * each operator symbol.
  361.  *
  362.  * The tidy process uses a `stack' of type:
  363.  *    TidyStack ::= ap(ap(Operator,TidyStack),Expr)
  364.  *         |  NIL
  365.  * when the ith layer of an InfixExpr has been transferred to the stack, the
  366.  * stack is of the form: +i (....(+n NIL xn)....) xi
  367.  *
  368.  * The tidy function is based on a simple shift-reduce parser:
  369.  *
  370.  *  tidy                :: InfixExpr -> TidyStack -> Expr
  371.  *  tidy [m]   ss        = foldl (\x f-> f x) m ss
  372.  *  tidy (m*n) []        = tidy m [(*n)]
  373.  *  tidy (m*n) ((+o):ss)
  374.  *           | amb     = error "Ambiguous"
  375.  *           | shift   = tidy m ((*n):(+o):ss)
  376.  *           | reduce  = tidy (m*(n+o)) ss
  377.  *               where sye     = syntaxOf (*)
  378.  *                 (ae,pe) = sye
  379.  *                 sys     = syntaxOf (+)
  380.  *                 (as,ps) = sys
  381.  *                 amb     = pe==ps && (ae/=as || ae==NON_ASS)
  382.  *                 shift   = pe>ps || (ps==pe && ae==LEFT_ASS)
  383.  *                 reduce  = otherwise
  384.  *
  385.  * N.B. the conditions amb, shift, reduce are NOT mutually exclusive and
  386.  * must be tested in that order.
  387.  *
  388.  * As a concession to efficiency, we lower the number of calls to syntaxOf
  389.  * by keeping track of the values of sye, sys throughout the process.  The
  390.  * value APPLIC is used to indicate that the syntax value is unknown.
  391.  */
  392.  
  393. static Cell local tidyInfix(e)         /* convert InfixExpr to Expr        */
  394. Cell e; {                              /* :: InfixExpr                     */
  395.     Cell   s   = NIL;                  /* :: TidyStack                     */
  396.     Syntax sye = APPLIC;               /* Syntax of op in e (init unknown) */
  397.     Syntax sys = APPLIC;               /* Syntax of op in s (init unknown) */
  398.     Cell   temp;
  399.  
  400.     while (nonNull(tl(e))) {
  401.         if (isNull(s)) {
  402.             s           = e;
  403.             e           = arg(fun(s));
  404.             arg(fun(s)) = NIL;
  405.             sys         = sye;
  406.             sye         = APPLIC;
  407.         }
  408.         else {
  409.             if (sye==APPLIC) {         /* calculate sye (if unknown)       */
  410.                 sye = syntaxOf(textOf(fun(fun(e))));
  411.                 if (sye==APPLIC) sye=DEF_OPSYNTAX;
  412.             }
  413.             if (sys==APPLIC) {         /* calculate sys (if unknown)       */
  414.                 sys = syntaxOf(textOf(fun(fun(s))));
  415.                 if (sys==APPLIC) sys=DEF_OPSYNTAX;
  416.             }
  417.  
  418.             if (precOf(sye)==precOf(sys) &&                      /* amb    */
  419.                    (assocOf(sye)!=assocOf(sys) || assocOf(sye)==NON_ASS)) {
  420.                 ERROR(row) "Ambiguous use of operator \"%s\" with \"%s\"",
  421.                            textToStr(textOf(fun(fun(e)))),
  422.                            textToStr(textOf(fun(fun(s))))
  423.                 EEND;
  424.             }
  425.             else if (precOf(sye)>precOf(sys) ||                  /* shift  */
  426.                        (precOf(sye)==precOf(sys) && assocOf(sye)==LEFT_ASS)) {
  427.                 temp        = arg(fun(e));
  428.                 arg(fun(e)) = s;
  429.                 s           = e;
  430.                 e           = temp;
  431.                 sys         = sye;
  432.                 sye         = APPLIC;
  433.             }
  434.             else {                                               /* reduce */
  435.                 temp        = arg(fun(s));
  436.                 arg(fun(s)) = arg(e);
  437.                 arg(e)      = s;
  438.                 s           = temp;
  439.                 sys         = APPLIC;
  440.                 /* sye unchanged */
  441.             }
  442.         }
  443.     }
  444.  
  445.     e = hd(e);
  446.     while (nonNull(s)) {
  447.         temp        = arg(fun(s));
  448.         arg(fun(s)) = e;
  449.         e           = s;
  450.         s           = temp;
  451.     }
  452.  
  453.     return e;
  454. }
  455.  
  456. /*-------------------------------------------------------------------------*/
  457. short yyexca[] ={
  458. -1, 1,
  459.     0, -1,
  460.     -2, 0,
  461. -1, 86,
  462.     259, 143,
  463.     44, 143,
  464.     -2, 169,
  465. -1, 95,
  466.     285, 75,
  467.     -2, 74,
  468. -1, 151,
  469.     285, 75,
  470.     -2, 118,
  471. -1, 154,
  472.     285, 75,
  473.     -2, 126,
  474. -1, 236,
  475.     264, 19,
  476.     -2, 41,
  477. -1, 271,
  478.     96, 78,
  479.     282, 78,
  480.     -2, 65,
  481.     };
  482. #define YYNPROD 215
  483. # define YYLAST 821
  484. short yyact[]={
  485.  
  486.   18, 318,  93,  95, 345, 339,   6, 130, 128,  21,
  487.  310, 268, 196, 233, 365,   5, 269, 364, 261,  34,
  488.   36, 204, 298, 311, 101, 287,  52,  53,  37, 223,
  489.  220, 330, 208,  86, 110,  62, 254, 168, 101,  85,
  490.   68, 104, 134, 384, 137, 370,  89, 105, 105, 360,
  491.  314, 215,  86, 141, 315,  84, 251,  36,  85, 148,
  492.  375, 349, 205,  38, 101, 171,  91,  72, 177,  90,
  493.   91, 136, 309,  90, 258, 102, 230,  70, 222, 232,
  494.  138, 147, 219, 148, 252, 151, 154, 155, 111, 102,
  495.  112, 179, 284,  86, 299, 256, 361,  22,  61,  85,
  496.  367,  39,  58, 161,  71, 173, 178, 299, 281, 148,
  497.  163, 216,   4,   2,   3, 102, 164, 264, 185, 216,
  498.  183,  96, 278,  42, 186, 276, 259, 187,  92,  51,
  499.   86, 188, 182, 189, 181, 148,  85, 201, 193, 248,
  500.  198, 124, 101,  56, 280, 109,  66, 207,  27,  11,
  501.  101, 140,  20,  45, 195, 383, 366, 362, 225, 224,
  502.  363, 157, 125, 307, 200, 273, 164, 235, 214, 157,
  503.   22, 257, 238, 239, 227,  10, 237, 229, 120, 357,
  504.  285, 145, 358,  19,  43,  86, 312, 342, 226, 135,
  505.  307,  85, 201, 102, 255, 282, 382, 246, 283, 330,
  506.  247, 102, 101, 194, 244, 235, 101, 245, 116, 267,
  507.  241, 270, 359, 242, 119, 147, 274, 120, 265, 250,
  508.  356,  27,  11, 174, 277,  20, 297, 279, 306, 117,
  509.  142, 143, 118, 296, 199,  45,  46, 115, 167,  22,
  510.   97, 114, 126, 240,  10, 192, 286, 239, 191, 304,
  511.  262, 288, 166, 102,  97, 131,  19, 102, 295, 294,
  512.   86,  99, 291, 235, 289, 290,  85, 100,  30, 300,
  513.  206, 302, 203, 228,  29,  99, 265,  86, 206,  86,
  514.   97, 100,  86,  85, 235,  85, 331, 172,  85, 293,
  515.   27,  11,  22, 322,  20, 328,  30,  10, 160, 255,
  516.  201,  99, 266,  29, 348, 340, 336, 100, 235, 335,
  517.  346, 319, 337,   7, 341, 270,  72, 350, 334, 270,
  518.   30, 343,  14, 333,  13,  19, 352, 351, 347, 332,
  519.  354,  12, 355,  59,  30,  23,  24,  25,  26,  60,
  520.   29, 329, 217,  27,  11,  16,  30,  20,  22,  91,
  521.  217, 146, 236,  10,  86, 372, 360, 209,  97, 323,
  522.   85, 201, 371, 324, 340, 378, 271, 346, 374, 377,
  523.  381, 380,  30, 341, 376, 379,  22, 131,  19,  99,
  524.  305,  10, 127, 213, 156, 100, 132,  99, 319,  22,
  525.   77,  78,  79, 100, 313,  14, 275,  13, 272,  27,
  526.   11,  75,  76,  20,  12, 303,  15,  30,  23,  24,
  527.   25,  26, 301,  29,  81,  44,  82,  48,  16,  80,
  528.   83,  46,  74, 325, 321, 243,  67,  27,  11, 169,
  529.  234,  20, 253, 131,  19,  35,  30,  49, 210,  99,
  530.   27,  22,  29,  99,  20, 100,  10,  40,  47, 100,
  531.    9,  28, 129,  63, 184,  73, 353, 162,  22,  77,
  532.   78,  79,  19,  10,  14,  48,  13,  88, 292,  87,
  533.   75,  76,  98,  12,  94,  19,  30,  23,  24,  25,
  534.   26,  69,  29,  81,  41,  82,  22,  16,  80,  83,
  535.  159,  74,  27,  11,  22, 190,  20, 158, 317,  10,
  536.  211, 212, 221, 121, 152, 133, 218,  65, 373,  27,
  537.   11,  22, 149,  20, 144, 176,  10,  14, 131,  13,
  538.  131, 175, 131,  22, 114, 369,  12,  19, 368,  30,
  539.   23,  24,  25,  26, 131,  29,   8,  27, 344,  22,
  540.   16,  20, 180, 308,  19,  27,  11, 327, 326,  20,
  541.  338, 139, 263, 231, 260, 202, 150, 153, 165,  64,
  542.   33,  32,  27,  11, 132,  31,  20,   1,   0, 170,
  543.    0,   0,  19,  14,  27,  13,   0, 103,  20,   0,
  544.   19,   0,  12,   0, 106,  30,  23,  24,  25,  26,
  545.   27,  29,   7,   0,  20,   0,  16,  19,   0,   0,
  546.    0,  14,   0,  13,   0,   0,   0,   0,   0,  19,
  547.   12,   0,   0,  30,  23,  24,  25,  26,   0,  29,
  548.    0,   0,   0,   0,  16,  19,  30,  23,  24,  25,
  549.   26,   0,  29,   0,   0,   0,   0,  16,   0,   0,
  550.    0,   0,   0,   0,   0,   0,   0, 170,   0, 132,
  551.    0, 132,   0, 132,   0,   0,   0, 320, 103,   0,
  552.    0,   0,   0,   0,   0, 132,  14,   0,  13,   0,
  553.    0,   0,   0,   0,   7,  12,   0,   0,  30,  23,
  554.   24,  25,  26,  14,  29,  13,   0,   0,   0,  16,
  555.    0,   0, 197,   0,   0,  30,  23,  24,  25,  26,
  556.    0,  29,   0,   0,   0,   0,  16,   0,   0, 107,
  557.    0,   0, 316,   0,   0,   0,   0, 249,   0,  14,
  558.    0,  13,   0,  30,  23,  24,  25,  26,  12,  29,
  559.    0,  30,  23,  24,  25,  26,  14,  29,  13,   0,
  560.    0,   0,  16,   0,   0,  12,   0,   0,  30,  23,
  561.   24,  25,  26,  17,  29,   0,   0,   0,   0,  16,
  562.   30,  23,  24,  25,  26,  50,  29,   0,   0,  54,
  563.   55,  16,   0,  57,   0,   0,  30,  23,  24,  25,
  564.   26,   0,  29,   0,   0,   0,   0,   0,   0,   0,
  565.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  566.    0,   0,  54, 108,   0,   0,   0,   0,   0,   0,
  567.  113,   0,   0,   0,   0,   0,   0,   0,   0, 122,
  568.  123 };
  569. short yypact[]={
  570.  
  571. -144,-1000, 336,-237,-1000,-207,-158,-1000, 139, 139,
  572.  349, 499,   6, 336, 336, 499, 499,-1000,  79, 499,
  573. -1000,-1000,  57,-1000,-1000,-1000,-1000, 336,-1000,-1000,
  574. -1000,-1000, 199,-274,-1000,-1000,-210,-1000,   5, 102,
  575.  471,-1000,-1000,-1000,-1000,-236,-1000, 471, 499, 446,
  576. -1000, 471,-180,-176,-1000,-1000, 499,-1000, 483, 196,
  577.  167,-1000, 188, 173, 139, 499, 499,  48, 118, 134,
  578.  393,-1000,-1000,-1000,-214,-212, 102,-225,-225,-225,
  579.   95, 102, 102, 102, 125,  42,  79,-1000, 212,-1000,
  580. -1000,-1000, 471,-1000,-248,-1000, 166,-1000,-1000,-1000,
  581. -1000,  24,  -2, 139,  38,  36,-1000, 336,-1000, 395,
  582. -1000, 336,   4,-1000,-1000,-1000,-1000,-1000, 336,-1000,
  583.  336, 454, 207, 204,-1000, 336, 418, 336,-1000, 130,
  584. -1000,-1000,-1000, -19,-1000,   1,-1000,-1000,  86,-253,
  585.  139,-1000, 139, 139, 124,-1000,-1000,-229,  66,-188,
  586. -255,-1000,-192,-256,-1000,-1000, 102,  43,-1000,-207,
  587. -1000, 336,  -8,-1000, 336,-194,  69, 395, 102, 102,
  588. -1000,-1000, 202, 169, 162, 163, 156,-1000,  46,-1000,
  589.  471,-1000,-1000,-1000, 308,-219,-185, 471,-1000,-1000,
  590. -1000,-1000,-1000,-169, 127,-1000,-199,   3,-1000,-1000,
  591. -1000,-1000,-277, 210,  19, 102,-1000, 110,-212, 121,
  592. -1000, 121, 121, 102,  43,-1000, 200, 196,-1000,   2,
  593.  102,-1000,  -1, 102,-1000,-1000,-1000,-1000,-1000,  83,
  594.  -15, 154,-1000,-1000,-172,-1000, 140,-1000,-1000,-1000,
  595. -1000,-1000, 102, -16,-1000,-1000,-1000, 102,-1000,-1000,
  596. -1000, 336, 336, 409,-1000, -30, 336, 418, 336, 471,
  597. -1000, 209,  19, 187, 119,-1000, 140,-203,-101,-1000,
  598.  -46,-1000,  -7, 139,-1000,-1000, 401,-1000, 471,-1000,
  599.  336, 199,-1000,  69,-1000, 159,-1000,-1000,-1000,-1000,
  600. -1000,-1000, 308,-1000,-207, -17, 336,-1000,-1000, 471,
  601. -1000,-1000,-1000, 395,  -9, 146,-1000,  19,-1000,  43,
  602. -1000, 110,  21, 102,-235, 110,-1000, 397,-1000,-1000,
  603. -1000, 395,-1000, 393,-1000, 179, 138, 171,-1000, 117,
  604.   74,-1000,-1000,-1000,-1000,-1000,-167,-219, 116,-1000,
  605. -279,-282,-1000,-1000, 112,-1000,-159,-1000,-1000,-238,
  606. -1000,-101,-1000, 252,-1000,-1000,-1000,-1000,  20,-1000,
  607.  167, 336,-1000,  -9,  43,  20,  43, 102, 155, 111,
  608. -1000,-1000,-1000,-1000,-1000,-233,-1000,-1000,-1000,-1000,
  609. -1000,-1000,-1000,-240,-1000 };
  610. short yypgo[]={
  611.  
  612.    0, 567,  12,  28, 565, 561,  77,   8, 560, 104,
  613.   34, 435, 430, 558, 555, 554, 553,  79,  13, 117,
  614.  552, 550,   5,   0,   9, 548, 547,  55, 189,   3,
  615.  543,  11,  10, 474, 538,   4,   2,  16, 123, 528,
  616.  525, 121, 472, 521, 515, 151, 357, 438, 484, 514,
  617.  181, 512, 506, 504, 502, 498,   1, 145,   6, 497,
  618.  490, 457, 110, 451, 536, 450, 406, 437, 432, 753,
  619.  453, 426,  36, 289, 259, 258,  22, 203, 154,   7 };
  620. short yyr1[]={
  621.  
  622.    0,   1,   1,   1,   1,   4,   4,   5,   6,   6,
  623.    6,   6,   6,   8,   8,  11,  11,   9,   9,  12,
  624.   12,  13,  13,  16,  16,  17,  17,  14,  14,  14,
  625.   20,  20,  19,  19,  15,  15,  21,  21,  22,  22,
  626.   18,  18,  18,  18,  18,  25,  25,  26,  26,   9,
  627.    9,   9,  28,  28,  28,  30,  30,  34,  34,  35,
  628.   35,  31,  31,  37,  37,  37,  32,  32,  32,  39,
  629.   39,  40,  40,  36,  36,  33,  29,  29,  29,  41,
  630.   41,  42,  42,  42,  42,  42,  42,  42,  42,  42,
  631.   42,  43,  43,  44,  44,   9,   9,   9,  45,  45,
  632.   46,  46,  47,  47,  47,  48,  48,  38,  38,   9,
  633.   49,  49,  49,  50,   9,   9,   9,  51,  51,  52,
  634.   52,  55,  55,  56,  56,  53,  53,  54,  54,  10,
  635.   10,  57,  57,  59,  59,  59,  60,  60,   3,  61,
  636.   61,  62,  27,  27,  23,  23,  63,  63,  24,  24,
  637.    2,   2,   2,  58,  58,  58,  65,  65,  64,  64,
  638.   64,  64,  64,  64,  67,  67,  66,  66,  66,  69,
  639.   69,  69,  69,  69,  69,  69,  69,  69,  69,  69,
  640.   69,  69,  69,  69,  69,  70,  70,  68,  68,  72,
  641.   73,  73,  74,  74,  74,  75,  75,  76,  71,  71,
  642.   71,  71,  71,  71,  71,  71,  77,  77,  78,  78,
  643.   78,   7,   7,  79,  79 };
  644. short yyr2[]={
  645.  
  646.    0,   2,   3,   2,   1,   3,   1,   1,   3,   3,
  647.    1,   1,   1,   2,   1,   7,   2,   4,   2,   1,
  648.    1,   0,   3,   3,   1,   1,   2,   0,   4,   3,
  649.    0,   1,   3,   1,   0,   4,   3,   1,   3,   3,
  650.    1,   1,   4,   4,   4,   3,   1,   0,   1,   5,
  651.    5,   7,   2,   1,   1,   2,   0,   3,   1,   3,
  652.    1,   3,   1,   3,   1,   1,   0,   2,   4,   0,
  653.    1,   3,   1,   3,   1,   1,   1,   3,   1,   2,
  654.    1,   1,   1,   2,   3,   3,   4,   3,   3,   3,
  655.    2,   2,   1,   3,   3,   3,   3,   3,   1,   0,
  656.    3,   1,   1,   1,   1,   1,   3,   1,   3,   4,
  657.    3,   1,   1,   2,   3,   3,   2,   3,   1,   4,
  658.    0,   3,   1,   1,   1,   3,   1,   4,   0,   3,
  659.    2,   3,   1,   2,   1,   1,   2,   1,   4,   2,
  660.    1,   4,   3,   1,   1,   3,   1,   3,   1,   3,
  661.    3,   1,   1,   1,   3,   1,   3,   5,   2,   4,
  662.    6,   6,   6,   1,   2,   1,   2,   2,   1,   1,
  663.    3,   2,   1,   1,   2,   1,   1,   1,   1,   3,
  664.    3,   3,   4,   4,   4,   3,   3,   3,   1,   2,
  665.    2,   1,   1,   2,   1,   2,   1,   4,   0,   1,
  666.    1,   3,   3,   4,   2,   5,   3,   1,   3,   1,
  667.    4,   2,   1,   1,   1 };
  668. short yychk[]={
  669.  
  670. -1000,  -1, 257, 258, 256,  -2, -58, 256, -64, -65,
  671.   45,  92, 274, 267, 265, -66, 288, -69, -23, 126,
  672.   95, -24,  40, 278, 279, 280, 281,  91, -63, 283,
  673.  277,  -4,  -5,  -8, 256, -11, 294,  -3, 270, 259,
  674.  -47, -48, -38,  45, 276,  96, 282, -47, -66, -67,
  675.  -69, 123,  -2,  -2, -69, -69,  64, -69,  45, 276,
  676.  282,  41,  -2, -70, -64, -48, -38, -71,  -2, -70,
  677.   -6,  -9, -10, 256, 292, 271, 272, 260, 261, 262,
  678.  289, 284, 286, 290, -27, -58, -23, -11, -12, 256,
  679.  283, 280, 123, -36, -33, -29, -41, 256, -42, 277,
  680.  283,  40,  91, -64, 277, 283, -64, 263, -69, -57,
  681.  -10, 268, 266, -69,  41,  41,  41,  41,  44,  41,
  682.   44, -47, -69, -69,  93,  44, 124, 264,  -7,  59,
  683.  -79, 125, 256, -12, 256, -28, 283, 256, -29, -33,
  684.  -45, 278, -45, -45, -49, -50, 256, -23,  40, -51,
  685.  -33, -29, -53, -33, -29, -29, 259,  44, -59, -60,
  686.  256,  61, -61, -62, 124, -13,  40, -57, 285, 263,
  687.  -42,  41, 263, -29, -41, -43, -44,  44, -29,  93,
  688.  -47,  96,  96,  -2,  59,  -7,  -2, 123,  -2,  -2,
  689.   41,  41,  41,  -2, -77, -78,  -2, 274,  -2,  -9,
  690.  -10, -79, -14, 291,  40,  61, 277,  61, 285, -46,
  691.  -47, -46, -46, 259,  44, 280,  45, 276, -52, 270,
  692.  285, -54, 270, 285, -36, -23,  -3,  -2, -62,  -2,
  693.  270, -16, -17, -18, -12, -23, 283,  -7, -29, -29,
  694.   41,  41,  44, 263,  41,  44,  41,  44,  93, -64,
  695.  -10, 275, 269, -68, -72, -58, 264,  44, 273, 123,
  696.  -15, 295,  40, -20, -19, -18, 283, -29, -31, -37,
  697.  -29, 256, -28,  44, -36, -50, 123, -29, 123, -29,
  698.   61, 123,  41,  44, 264,  40, -29,  41, -29,  -2,
  699.   -2,  -7,  59, -73, -74, -75, 263, 256, -76, 124,
  700.   -2, -78,  -2, -57,  40, -19,  41,  44, -30, 275,
  701.  -32, 124, 287, -38,  96,  61, -47, -55, -56, -10,
  702.  256, -57,  -2,  -6, -17, 264, -25, -26, -24, -27,
  703.   40, -23, -72,  -3, -76,  -2, -58,  -7, -21, -22,
  704.  -23, -24,  41, -18, -34, -35, -23, -37, 283,  40,
  705.  -29, -31,  -7,  59,  -7,  -7,  41,  41,  44,  41,
  706.  282, 263,  41,  44, 296, 296,  44, 259, -39, -40,
  707.  283, -32, -56, 256, -24,  40,  -2, -22, -23, -24,
  708.  -35, -36,  41,  44, 283 };
  709. short yydef[]={
  710.  
  711.    0,  -2,   0,   0,   4,   1, 151, 152, 153, 155,
  712.    0,   0,   0,   0,   0, 163,   0, 168, 169,   0,
  713.  172, 173,   0, 175, 176, 177, 178, 198, 144, 148,
  714.  146,   3,   0,   6,   7,  14,   0,   2,   0,   0,
  715.    0, 102, 103, 104, 105,   0, 107,   0, 158,   0,
  716.  165,   0,   0,   0, 166, 167,   0, 171,   0, 105,
  717.  107, 174,   0,   0, 153,   0,   0,   0, 199, 200,
  718.    0,  10,  11,  12,   0,   0,   0,  99,  99,  99,
  719.    0,   0,   0,   0,   0,   0,  -2,  13,  21,  16,
  720.   19,  20,   0, 150,   0,  -2,  76,  78,  80,  81,
  721.   82,   0,   0, 154,   0,   0, 156,   0, 164,   0,
  722.  132,   0,   0, 170, 145, 147, 149, 179,   0, 180,
  723.    0,   0,   0,   0, 181,   0,   0, 204,   5,   0,
  724.  212, 213, 214,  27,  18,   0,  53,  54,  75,   0,
  725.    0,  98,   0,   0,   0, 111, 112,   0,   0, 120,
  726.    0,  -2, 128,   0,  -2, 116,   0,   0, 130, 134,
  727.  135,   0, 137, 140,   0,   0,   0,   0,   0,   0,
  728.   79,  83,   0,   0,  76,   0,   0,  92,   0,  90,
  729.    0, 106, 108, 159,   0,   0,   0,   0, 186, 185,
  730.  182, 183, 184, 186, 201, 207, 209,   0, 202,   8,
  731.    9, 211,  34,   0,  30,   0,  52,   0,   0,  95,
  732.  101,  96,  97,   0,   0, 113,   0,   0, 114,   0,
  733.    0, 115,   0,   0, 129, 142, 133, 136, 139,   0,
  734.    0,   0,  24,  25,   0,  40,  -2, 138,  73,  77,
  735.   84,  85,   0,   0,  87,  91,  88,   0,  89, 157,
  736.  131,   0,   0,   0, 188,   0, 203,   0,   0,   0,
  737.   17,   0,   0,   0,  31,  33,  41,  56,  66,  62,
  738.   64,  -2,   0,   0, 109, 110,   0, 117,   0, 125,
  739.    0,   0,  22,   0,  26,  47,  94,  86,  93, 160,
  740.  161, 162,   0, 189, 191, 192,   0, 194, 196,   0,
  741.  205, 206, 208,   0,   0,   0,  29,   0,  49,   0,
  742.   50,   0,   0,   0,   0,   0, 100,   0, 122, 123,
  743.  124,   0, 141,   0,  23,   0,   0,   0,  46,  48,
  744.    0, 143, 187, 190, 195, 193,   0, 210,   0,  37,
  745.    0,   0,  28,  32,  55,  58,  60,  61,  67,  69,
  746.   63,  66, 119,   0, 127,  15,  42,  43,   0,  44,
  747.    0,   0,  35,   0,   0,   0,   0,   0,   0,  70,
  748.   72,  51, 121, 124,  45,   0, 197,  36,  38,  39,
  749.   57,  59,  68,   0,  71 };
  750. #define YYFLAG   -1000
  751. #define YYERROR  goto yyerrlab
  752. #define YYACCEPT return(0)
  753. #define YYABORT  return(1)
  754.  
  755. /*      parser for yacc output  */
  756.  
  757. #ifdef YYDEBUG
  758. int yydebug     = 0;     /* 1 for debugging */
  759. #endif
  760. YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
  761. int yychar      = -1;    /* current input token number */
  762. int yynerrs     = 0;     /* number of errors */
  763. short yyerrflag = 0;     /* error recovery flag */
  764.  
  765. int yyparse() {
  766.     short yys[YYMAXDEPTH];
  767.     short yyj, yym;
  768.     register YYSTYPE *yypvt;
  769.     register short yystate, *yyps, yyn;
  770.     register YYSTYPE *yypv;
  771.     register short *yyxi;
  772.  
  773.     yystate   = 0;
  774.     yychar    = -1;
  775.     yynerrs   = 0;
  776.     yyerrflag = 0;
  777.     yyps      = &yys[-1];
  778.     yypv      = &yyv[-1];
  779.  
  780. yystack:    /* put a state and value onto the stack */
  781.  
  782. #ifdef YYDEBUG
  783.     if (yydebug)
  784.         printf("state %d, char 0%o\n", yystate, yychar);
  785. #endif
  786.     if(++yyps>&yys[YYMAXDEPTH]) {
  787.         yyerror("yacc stack overflow");
  788.         return(1);
  789.     }
  790.     *yyps = yystate;
  791.     ++yypv;
  792. #ifdef UNION
  793.     yyunion(yypv, &yyval);
  794. #else
  795.     *yypv = yyval;
  796. #endif
  797.  
  798. yynewstate:
  799.  
  800.     yyn = yypact[yystate];
  801.  
  802.     if (yyn<=YYFLAG)
  803.         goto yydefault; /* simple state */
  804.  
  805.     if (yychar<0)
  806.         if ((yychar=yylex())<0)
  807.             yychar=0;
  808.     if ((yyn+=yychar)<0 || yyn>=YYLAST)
  809.         goto yydefault;
  810.  
  811.     if (yychk[yyn=yyact[yyn]]==yychar) {
  812.         /* valid shift */
  813.         yychar = -1;
  814. #ifdef UNION
  815.         yyunion(&yyval, &yylval);
  816. #else
  817.         yyval = yylval;
  818. #endif
  819.         yystate = yyn;
  820.         if (yyerrflag>0)
  821.             --yyerrflag;
  822.         goto yystack;
  823.  
  824.     }
  825.  
  826. yydefault:
  827.  
  828.     /* default state action */
  829.  
  830.     if ((yyn=yydef[yystate])== -2) {
  831.         if (yychar<0)
  832.             if ((yychar=yylex())<0)
  833.                 yychar = 0;
  834.         /* look through exception table */
  835.  
  836.         for (yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2)
  837.             ; /* VOID */
  838.  
  839.         for (yyxi+=2; *yyxi >= 0; yyxi+=2) {
  840.             if (*yyxi==yychar)
  841.                 break;
  842.         }
  843.         if ((yyn=yyxi[1])<0)
  844.             return(0);   /* accept */
  845.     }
  846.  
  847.     if (yyn==0) {
  848.         /* error */
  849.         /* error ... attempt to resume parsing */
  850.  
  851.         switch (yyerrflag) {
  852.             case 0: /* brand new error */
  853.                     yyerror( "syntax error" );
  854.  
  855. yyerrlab:           ++yynerrs;
  856.  
  857.             case 1:
  858.             case 2: /* incompletely recovered error ... try again */
  859.  
  860.                     yyerrflag = 3;
  861.  
  862.                     /* find a state where "error" is a legal shift action */
  863.  
  864.                     while (yyps>=yys) {
  865.                         yyn = yypact[*yyps] + YYERRCODE;
  866.                         if (yyn>=0 && yyn<YYLAST
  867.                                    && yychk[yyact[yyn]]==YYERRCODE) {
  868.                             yystate = yyact[yyn];
  869.                             /* simulate a shift of "error" */
  870.                             goto yystack;
  871.                         }
  872.                         yyn = yypact[*yyps];
  873.  
  874.                         /* the current yyps has no shift on "error",
  875.                            pop stack */
  876.  
  877. #ifdef YYDEBUG
  878.                         if (yydebug)
  879.                             printf("error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1]);
  880. #endif
  881.  
  882.                         --yyps;
  883.                         --yypv;
  884.                     }
  885.  
  886.                     /* there is no state on the stack with an error shift
  887.                        ... abort */
  888.  
  889. yyabort:            return(1);
  890.  
  891.  
  892.             case 3: /* no shift yet; clobber input char */
  893. #ifdef YYDEBUG
  894.                     if (yydebug)
  895.                         printf("error recovery discards char %d\n", yychar);
  896. #endif
  897.  
  898.                     if (yychar==0)
  899.                         goto yyabort; /* don't discard EOF, quit */
  900.                     yychar = -1;
  901.                     goto yynewstate;   /* try again in the same state */
  902.         }
  903.     }
  904.  
  905.     /* reduction by production yyn */
  906.  
  907. #ifdef YYDEBUG
  908.     if (yydebug)
  909.         printf("reduce %d\n",yyn);
  910. #endif
  911.     yyps -= yyr2[yyn];
  912.     yypvt = yypv;
  913.     yypv -= yyr2[yyn];
  914. #ifdef UNION
  915.     yyunion(&yyval, &yypv[1]);
  916. #else
  917.     yyval = yypv[1];
  918. #endif
  919.     yym=yyn;
  920.     /* consult goto table to find next state */
  921.     yyn = yyr1[yyn];
  922.     yyj = yypgo[yyn] + *yyps + 1;
  923.     if (yyj>=YYLAST || yychk[yystate=yyact[yyj]]!= -yyn)
  924.         yystate = yyact[yypgo[yyn]];
  925.     switch(yym) {
  926.         
  927. case 1:
  928. # line 86
  929. {inputExpr = yypvt[-0];        sp-=1;} break;
  930. case 2:
  931. # line 87
  932. {inputExpr = letrec(yypvt[-0],yypvt[-1]); sp-=2;} break;
  933. case 3:
  934. # line 88
  935. {valDefns  = yypvt[-0];        sp-=1;} break;
  936. case 4:
  937. # line 89
  938. {syntaxError("input");} break;
  939. case 5:
  940. # line 102
  941. {yyval = gc2(yypvt[-1]);} break;
  942. case 6:
  943. # line 103
  944. {yyval = yypvt[-0];} break;
  945. case 7:
  946. # line 105
  947. {yyerrok; goOffside(startColumn);} break;
  948. case 8:
  949. # line 107
  950. {yyval = gc2(yypvt[-2]);} break;
  951. case 9:
  952. # line 108
  953. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  954. case 10:
  955. # line 109
  956. {yyval = gc0(NIL);} break;
  957. case 11:
  958. # line 110
  959. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  960. case 12:
  961. # line 111
  962. {syntaxError("definition");} break;
  963. case 13:
  964. # line 113
  965. {yyval = gc2(appendOnto(yypvt[-0],yypvt[-1]));} break;
  966. case 14:
  967. # line 114
  968. {yyval = yypvt[-0];} break;
  969. case 15:
  970. # line 117
  971. {yyval = gc7(yypvt[-1]);} break;
  972. case 16:
  973. # line 118
  974. {syntaxError("module definition");} break;
  975. case 17:
  976. # line 120
  977. {sp-=4;} break;
  978. case 18:
  979. # line 121
  980. {syntaxError("import declaration");} break;
  981. case 19:
  982. # line 123
  983. {yyval = yypvt[-0];} break;
  984. case 20:
  985. # line 124
  986. {yyval = yypvt[-0];} break;
  987. case 21:
  988. # line 126
  989. {yyval = gc0(NIL);} break;
  990. case 22:
  991. # line 127
  992. {yyval = gc3(NIL);} break;
  993. case 23:
  994. # line 129
  995. {yyval = gc3(NIL);} break;
  996. case 24:
  997. # line 130
  998. {yyval = yypvt[-0];} break;
  999. case 25:
  1000. # line 132
  1001. {yyval = yypvt[-0];} break;
  1002. case 26:
  1003. # line 133
  1004. {yyval = gc2(NIL);} break;
  1005. case 27:
  1006. # line 135
  1007. {yyval = gc0(NIL);} break;
  1008. case 28:
  1009. # line 136
  1010. {yyval = gc4(NIL);} break;
  1011. case 29:
  1012. # line 137
  1013. {yyval = gc3(NIL);} break;
  1014. case 30:
  1015. # line 139
  1016. {yyval = gc0(NIL);} break;
  1017. case 31:
  1018. # line 140
  1019. {yyval = yypvt[-0];} break;
  1020. case 32:
  1021. # line 142
  1022. {yyval = gc3(NIL);} break;
  1023. case 33:
  1024. # line 143
  1025. {yyval = yypvt[-0];} break;
  1026. case 34:
  1027. # line 145
  1028. {yyval = gc0(NIL);} break;
  1029. case 35:
  1030. # line 146
  1031. {yyval = gc4(NIL);} break;
  1032. case 36:
  1033. # line 148
  1034. {yyval = gc3(NIL);} break;
  1035. case 37:
  1036. # line 149
  1037. {yyval = yypvt[-0];} break;
  1038. case 38:
  1039. # line 151
  1040. {yyval = gc3(NIL);} break;
  1041. case 39:
  1042. # line 152
  1043. {yyval = gc3(NIL);} break;
  1044. case 40:
  1045. # line 154
  1046. {yyval = yypvt[-0];} break;
  1047. case 41:
  1048. # line 155
  1049. {yyval = yypvt[-0];} break;
  1050. case 42:
  1051. # line 156
  1052. {yyval = gc4(NIL);} break;
  1053. case 43:
  1054. # line 157
  1055. {yyval = gc4(NIL);} break;
  1056. case 44:
  1057. # line 158
  1058. {yyval = gc4(NIL);} break;
  1059. case 45:
  1060. # line 160
  1061. {yyval = gc3(NIL);} break;
  1062. case 46:
  1063. # line 161
  1064. {yyval = yypvt[-0];} break;
  1065. case 47:
  1066. # line 163
  1067. {yyval = gc0(NIL);} break;
  1068. case 48:
  1069. # line 164
  1070. {yyval = yypvt[-0];} break;
  1071. case 49:
  1072. # line 169
  1073. {defTycon(5,yypvt[-2],yypvt[-3],yypvt[-1],yypvt[-0]);} break;
  1074. case 50:
  1075. # line 171
  1076. {defTycon(5,yypvt[-2],checkTyLhs(yypvt[-3]),
  1077.                             rev(yypvt[-1]),yypvt[-0]);} break;
  1078. case 51:
  1079. # line 174
  1080. {defTycon(7,yypvt[-2],yypvt[-3],
  1081.                           ap(QUAL,pair(yypvt[-5],rev(yypvt[-1]))),
  1082.                           yypvt[-0]);} break;
  1083. case 52:
  1084. # line 178
  1085. {yyval = gc2(ap(yypvt[-1],yypvt[-0]));} break;
  1086. case 53:
  1087. # line 179
  1088. {yyval = yypvt[-0];} break;
  1089. case 54:
  1090. # line 180
  1091. {syntaxError("type defn lhs");} break;
  1092. case 55:
  1093. # line 182
  1094. {yyval = gc2(yypvt[-0]);} break;
  1095. case 56:
  1096. # line 183
  1097. {yyval = gc0(SYNONYM);} break;
  1098. case 57:
  1099. # line 185
  1100. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1101. case 58:
  1102. # line 186
  1103. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1104. case 59:
  1105. # line 188
  1106. {yyval = gc3(sigdecl(yypvt[-1],singleton(yypvt[-2]),
  1107.                                  yypvt[-0]));} break;
  1108. case 60:
  1109. # line 190
  1110. {yyval = yypvt[-0];} break;
  1111. case 61:
  1112. # line 192
  1113. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1114. case 62:
  1115. # line 193
  1116. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1117. case 63:
  1118. # line 195
  1119. {yyval = gc3(ap(ap(yypvt[-1],yypvt[-2]),yypvt[-0]));} break;
  1120. case 64:
  1121. # line 196
  1122. {if (!isCon(getHead(yypvt[-0])))
  1123.                          syntaxError("data constructor");
  1124.                      yyval = yypvt[-0];} break;
  1125. case 65:
  1126. # line 199
  1127. {syntaxError("data type definition");} break;
  1128. case 66:
  1129. # line 201
  1130. {yyval = gc0(DATATYPE);} break;
  1131. case 67:
  1132. # line 202
  1133. {yyval = gc2(ap(DERIVE,singleton(yypvt[-0])));} break;
  1134. case 68:
  1135. # line 203
  1136. {yyval = gc4(yypvt[-1]);} break;
  1137. case 69:
  1138. # line 205
  1139. {yyval = gc0(DATATYPE);} break;
  1140. case 70:
  1141. # line 206
  1142. {yyval = gc1(ap(DERIVE,rev(yypvt[-0])));} break;
  1143. case 71:
  1144. # line 208
  1145. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1146. case 72:
  1147. # line 209
  1148. {yyval = gc1(singleton(yypvt[-0]));} break;
  1149. case 73:
  1150. # line 220
  1151. {yyval = gc3(ap(QUAL,pair(yypvt[-2],yypvt[-0])));} break;
  1152. case 74:
  1153. # line 221
  1154. {yyval = yypvt[-0];} break;
  1155. case 75:
  1156. # line 223
  1157. {yyval = gc1(checkContext(yypvt[-0]));} break;
  1158. case 76:
  1159. # line 225
  1160. {yyval = yypvt[-0];} break;
  1161. case 77:
  1162. # line 226
  1163. {yyval = gc3(ap(ap(ARROW,yypvt[-2]),yypvt[-0]));} break;
  1164. case 78:
  1165. # line 227
  1166. {syntaxError("type expression");} break;
  1167. case 79:
  1168. # line 229
  1169. {yyval = gc2(ap(yypvt[-1],yypvt[-0]));} break;
  1170. case 80:
  1171. # line 230
  1172. {yyval = yypvt[-0];} break;
  1173. case 81:
  1174. # line 232
  1175. {yyval = yypvt[-0];} break;
  1176. case 82:
  1177. # line 233
  1178. {yyval = yypvt[-0];} break;
  1179. case 83:
  1180. # line 234
  1181. {yyval = gc2(UNIT);} break;
  1182. case 84:
  1183. # line 235
  1184. {yyval = gc3(ARROW);} break;
  1185. case 85:
  1186. # line 236
  1187. {yyval = gc3(yypvt[-1]);} break;
  1188. case 86:
  1189. # line 237
  1190. {yyval = gc4(ap(ARROW,yypvt[-2]));} break;
  1191. case 87:
  1192. # line 238
  1193. {yyval = gc3(yypvt[-1]);} break;
  1194. case 88:
  1195. # line 239
  1196. {yyval = gc3(buildTuple(yypvt[-1]));} break;
  1197. case 89:
  1198. # line 240
  1199. {yyval = gc3(ap(LIST,yypvt[-1]));} break;
  1200. case 90:
  1201. # line 241
  1202. {yyval = gc2(LIST);} break;
  1203. case 91:
  1204. # line 243
  1205. {yyval = gc2(mkTuple(tupleOf(yypvt[-1])+1));} break;
  1206. case 92:
  1207. # line 244
  1208. {yyval = gc1(mkTuple(2));} break;
  1209. case 93:
  1210. # line 246
  1211. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1212. case 94:
  1213. # line 247
  1214. {yyval = gc3(cons(yypvt[-0],cons(yypvt[-2],NIL)));} break;
  1215. case 95:
  1216. # line 252
  1217. {fixDefn(LEFT_ASS,yypvt[-2],yypvt[-1],yypvt[-0]); sp-=3;} break;
  1218. case 96:
  1219. # line 253
  1220. {fixDefn(RIGHT_ASS,yypvt[-2],yypvt[-1],yypvt[-0]);sp-=3;} break;
  1221. case 97:
  1222. # line 254
  1223. {fixDefn(NON_ASS,yypvt[-2],yypvt[-1],yypvt[-0]);  sp-=3;} break;
  1224. case 98:
  1225. # line 256
  1226. {yyval = gc1(checkPrec(yypvt[-0]));} break;
  1227. case 99:
  1228. # line 257
  1229. {yyval = gc0(mkInt(DEF_PREC));} break;
  1230. case 100:
  1231. # line 259
  1232. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1233. case 101:
  1234. # line 260
  1235. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1236. case 102:
  1237. # line 262
  1238. {yyval = yypvt[-0];} break;
  1239. case 103:
  1240. # line 263
  1241. {yyval = yypvt[-0];} break;
  1242. case 104:
  1243. # line 264
  1244. {yyval = gc1(varMinus);} break;
  1245. case 105:
  1246. # line 266
  1247. {yyval = yypvt[-0];} break;
  1248. case 106:
  1249. # line 267
  1250. {yyval = gc3(yypvt[-1]);} break;
  1251. case 107:
  1252. # line 269
  1253. {yyval = yypvt[-0];} break;
  1254. case 108:
  1255. # line 270
  1256. {yyval = gc3(yypvt[-1]);} break;
  1257. case 109:
  1258. # line 275
  1259. {primDefn(yypvt[-3],yypvt[-2],yypvt[-0]); sp-=4;} break;
  1260. case 110:
  1261. # line 277
  1262. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1263. case 111:
  1264. # line 278
  1265. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1266. case 112:
  1267. # line 279
  1268. {syntaxError("primitive defn");} break;
  1269. case 113:
  1270. # line 281
  1271. {yyval = gc2(pair(yypvt[-1],yypvt[-0]));} break;
  1272. case 114:
  1273. # line 286
  1274. {classDefn(intOf(yypvt[-2]),yypvt[-1],yypvt[-0]); sp-=3;} break;
  1275. case 115:
  1276. # line 287
  1277. {instDefn(intOf(yypvt[-2]),yypvt[-1],yypvt[-0]);  sp-=3;} break;
  1278. case 116:
  1279. # line 288
  1280. {defaultDefn(intOf(yypvt[-1]),
  1281.                              tupToList(yypvt[-0])); sp-=2;} break;
  1282. case 117:
  1283. # line 291
  1284. {yyval = gc3(pair(yypvt[-2],checkClass(yypvt[-0])));} break;
  1285. case 118:
  1286. # line 292
  1287. {yyval = gc1(pair(NIL,checkClass(yypvt[-0])));} break;
  1288. case 119:
  1289. # line 294
  1290. {yyval = gc4(yypvt[-1]);} break;
  1291. case 120:
  1292. # line 295
  1293. {yyval = gc0(NIL);} break;
  1294. case 121:
  1295. # line 297
  1296. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1297. case 122:
  1298. # line 298
  1299. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1300. case 123:
  1301. # line 300
  1302. {yyval = gc1(yypvt[-0]);} break;
  1303. case 124:
  1304. # line 301
  1305. {syntaxError("class body");} break;
  1306. case 125:
  1307. # line 303
  1308. {yyval = gc3(pair(yypvt[-2],checkInst(yypvt[-0])));} break;
  1309. case 126:
  1310. # line 304
  1311. {yyval = gc1(pair(NIL,checkInst(yypvt[-0])));} break;
  1312. case 127:
  1313. # line 306
  1314. {yyval = gc4(yypvt[-1]);} break;
  1315. case 128:
  1316. # line 307
  1317. {yyval = gc0(NIL);} break;
  1318. case 129:
  1319. # line 312
  1320. {yyval = gc3(sigdecl(yypvt[-1],yypvt[-2],yypvt[-0]));} break;
  1321. case 130:
  1322. # line 313
  1323. {yyval = gc2(pair(yypvt[-1],yypvt[-0]));} break;
  1324. case 131:
  1325. # line 315
  1326. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1327. case 132:
  1328. # line 316
  1329. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1330. case 133:
  1331. # line 318
  1332. {yyval = gc2(letrec(yypvt[-0],yypvt[-1]));} break;
  1333. case 134:
  1334. # line 319
  1335. {yyval = yypvt[-0];} break;
  1336. case 135:
  1337. # line 320
  1338. {syntaxError("declaration");} break;
  1339. case 136:
  1340. # line 322
  1341. {yyval = gc2(pair(yypvt[-1],yypvt[-0]));} break;
  1342. case 137:
  1343. # line 323
  1344. {yyval = gc1(grded(rev(yypvt[-0])));} break;
  1345. case 138:
  1346. # line 325
  1347. {yyval = gc4(yypvt[-1]);} break;
  1348. case 139:
  1349. # line 327
  1350. {yyval = gc2(cons(yypvt[-0],yypvt[-1]));} break;
  1351. case 140:
  1352. # line 328
  1353. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1354. case 141:
  1355. # line 330
  1356. {yyval = gc4(pair(yypvt[-1],pair(yypvt[-2],yypvt[-0])));} break;
  1357. case 142:
  1358. # line 332
  1359. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1360. case 143:
  1361. # line 333
  1362. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1363. case 144:
  1364. # line 335
  1365. {yyval = yypvt[-0];} break;
  1366. case 145:
  1367. # line 336
  1368. {yyval = gc3(varMinus);} break;
  1369. case 146:
  1370. # line 338
  1371. {yyval = yypvt[-0];} break;
  1372. case 147:
  1373. # line 339
  1374. {yyval = gc3(yypvt[-1]);} break;
  1375. case 148:
  1376. # line 341
  1377. {yyval = yypvt[-0];} break;
  1378. case 149:
  1379. # line 342
  1380. {yyval = gc3(yypvt[-1]);} break;
  1381. case 150:
  1382. # line 347
  1383. {yyval = gc3(ap(ESIGN,pair(yypvt[-2],yypvt[-0])));} break;
  1384. case 151:
  1385. # line 348
  1386. {yyval = yypvt[-0];} break;
  1387. case 152:
  1388. # line 349
  1389. {syntaxError("expression");} break;
  1390. case 153:
  1391. # line 351
  1392. {yyval = yypvt[-0];} break;
  1393. case 154:
  1394. # line 352
  1395. {yyval = gc3(ap(ap(yypvt[-1],yypvt[-2]),yypvt[-0]));} break;
  1396. case 155:
  1397. # line 353
  1398. {yyval = gc1(tidyInfix(yypvt[-0]));} break;
  1399. case 156:
  1400. # line 355
  1401. {yyval = gc3(ap(ap(yypvt[-1],yypvt[-2]),yypvt[-0]));} break;
  1402. case 157:
  1403. # line 356
  1404. {yyval = gc5(ap(ap(yypvt[-1],
  1405.                             ap(ap(yypvt[-3],singleton(yypvt[-4])),
  1406.                                                            yypvt[-2])),yypvt[-0]));} break;
  1407. case 158:
  1408. # line 360
  1409. {if (isInt(yypvt[-0]))
  1410.                          yyval = gc2(mkInt(-intOf(yypvt[-0])));
  1411.                      else
  1412.                          yyval = gc2(ap(varNegate,yypvt[-0]));
  1413.                     } break;
  1414. case 159:
  1415. # line 365
  1416. {yyval = gc4(ap(LAMBDA,
  1417.                              pair(rev(yypvt[-2]),
  1418.                               pair(yypvt[-1],yypvt[-0]))));} break;
  1419. case 160:
  1420. # line 368
  1421. {yyval = gc6(letrec(yypvt[-3],yypvt[-0]));} break;
  1422. case 161:
  1423. # line 369
  1424. {yyval = gc6(ap(COND,triple(yypvt[-4],yypvt[-2],yypvt[-0])));} break;
  1425. case 162:
  1426. # line 370
  1427. {yyval = gc6(ap(CASE,pair(yypvt[-4],rev(yypvt[-1]))));} break;
  1428. case 163:
  1429. # line 371
  1430. {yyval = yypvt[-0];} break;
  1431. case 164:
  1432. # line 373
  1433. {yyval = gc2(cons(yypvt[-0],yypvt[-1]));} break;
  1434. case 165:
  1435. # line 374
  1436. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1437. case 166:
  1438. # line 376
  1439. {yyval = gc2(ap(yypvt[-1],yypvt[-0]));} break;
  1440. case 167:
  1441. # line 377
  1442. {yyval = gc2(ap(RUNST,yypvt[-0]));} break;
  1443. case 168:
  1444. # line 378
  1445. {yyval = yypvt[-0];} break;
  1446. case 169:
  1447. # line 380
  1448. {yyval = yypvt[-0];} break;
  1449. case 170:
  1450. # line 381
  1451. {yyval = gc3(ap(ASPAT,pair(yypvt[-2],yypvt[-0])));} break;
  1452. case 171:
  1453. # line 382
  1454. {yyval = gc2(ap(LAZYPAT,yypvt[-0]));} break;
  1455. case 172:
  1456. # line 383
  1457. {yyval = gc1(WILDCARD);} break;
  1458. case 173:
  1459. # line 384
  1460. {yyval = yypvt[-0];} break;
  1461. case 174:
  1462. # line 385
  1463. {yyval = gc2(UNIT);} break;
  1464. case 175:
  1465. # line 386
  1466. {yyval = yypvt[-0];} break;
  1467. case 176:
  1468. # line 387
  1469. {yyval = yypvt[-0];} break;
  1470. case 177:
  1471. # line 388
  1472. {yyval = yypvt[-0];} break;
  1473. case 178:
  1474. # line 389
  1475. {yyval = yypvt[-0];} break;
  1476. case 179:
  1477. # line 390
  1478. {yyval = gc3(yypvt[-1]);} break;
  1479. case 180:
  1480. # line 391
  1481. {yyval = gc3(buildTuple(yypvt[-1]));} break;
  1482. case 181:
  1483. # line 392
  1484. {yyval = gc3(yypvt[-1]);} break;
  1485. case 182:
  1486. # line 393
  1487. {yyval = gc4(ap(yypvt[-1],yypvt[-2]));} break;
  1488. case 183:
  1489. # line 394
  1490. {yyval = gc4(ap(ap(varFlip,yypvt[-2]),yypvt[-1]));} break;
  1491. case 184:
  1492. # line 395
  1493. {yyval = gc4(ap(ap(varFlip,yypvt[-2]),yypvt[-1]));} break;
  1494. case 185:
  1495. # line 397
  1496. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1497. case 186:
  1498. # line 398
  1499. {yyval = gc3(cons(yypvt[-0],cons(yypvt[-2],NIL)));} break;
  1500. case 187:
  1501. # line 400
  1502. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1503. case 188:
  1504. # line 401
  1505. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1506. case 189:
  1507. # line 403
  1508. {yyval = gc2(pair(yypvt[-1],yypvt[-0]));} break;
  1509. case 190:
  1510. # line 405
  1511. {yyval = gc2(letrec(yypvt[-0],yypvt[-1]));} break;
  1512. case 191:
  1513. # line 406
  1514. {yyval = yypvt[-0];} break;
  1515. case 192:
  1516. # line 408
  1517. {yyval = gc1(grded(rev(yypvt[-0])));} break;
  1518. case 193:
  1519. # line 409
  1520. {yyval = gc2(pair(yypvt[-1],yypvt[-0]));} break;
  1521. case 194:
  1522. # line 410
  1523. {syntaxError("case expression");} break;
  1524. case 195:
  1525. # line 412
  1526. {yyval = gc2(cons(yypvt[-0],yypvt[-1]));} break;
  1527. case 196:
  1528. # line 413
  1529. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1530. case 197:
  1531. # line 415
  1532. {yyval = gc4(pair(yypvt[-1],pair(yypvt[-2],yypvt[-0])));} break;
  1533. case 198:
  1534. # line 420
  1535. {yyval = gc0(nameNil);} break;
  1536. case 199:
  1537. # line 421
  1538. {yyval = gc1(ap(FINLIST,cons(yypvt[-0],NIL)));} break;
  1539. case 200:
  1540. # line 422
  1541. {yyval = gc1(ap(FINLIST,rev(yypvt[-0])));} break;
  1542. case 201:
  1543. # line 423
  1544. {yyval = gc3(ap(COMP,pair(yypvt[-2],rev(yypvt[-0]))));} break;
  1545. case 202:
  1546. # line 424
  1547. {yyval = gc3(ap(ap(varFromTo,yypvt[-2]),yypvt[-0]));} break;
  1548. case 203:
  1549. # line 425
  1550. {yyval = gc4(ap(ap(varFromThen,yypvt[-3]),yypvt[-1]));} break;
  1551. case 204:
  1552. # line 426
  1553. {yyval = gc2(ap(varFrom,yypvt[-1]));} break;
  1554. case 205:
  1555. # line 427
  1556. {yyval = gc5(ap(ap(ap(varFromThenTo,
  1557.                                                                yypvt[-4]),yypvt[-2]),yypvt[-0]));} break;
  1558. case 206:
  1559. # line 430
  1560. {yyval = gc3(cons(yypvt[-0],yypvt[-2]));} break;
  1561. case 207:
  1562. # line 431
  1563. {yyval = gc1(cons(yypvt[-0],NIL));} break;
  1564. case 208:
  1565. # line 433
  1566. {yyval = gc3(ap(FROMQUAL,pair(yypvt[-2],yypvt[-0])));} break;
  1567. case 209:
  1568. # line 434
  1569. {yyval = gc1(ap(BOOLQUAL,yypvt[-0]));} break;
  1570. case 210:
  1571. # line 435
  1572. {yyval = gc4(ap(QWHERE,yypvt[-1]));} break;
  1573. case 211:
  1574. # line 441
  1575. {yyval = gc2(yypvt[-0]);} break;
  1576. case 212:
  1577. # line 442
  1578. {yyval = yypvt[-0];} break;
  1579. case 213:
  1580. # line 444
  1581. {yyval = yypvt[-0];} break;
  1582. case 214:
  1583. # line 445
  1584. {yyerrok;
  1585.                                          if (canUnOffside()) {
  1586.                          unOffside();
  1587.                          /* insert extra token on stack*/
  1588.                          push(NIL);
  1589.                          pushed(0) = pushed(1);
  1590.                          pushed(1) = mkInt(column);
  1591.                      }
  1592.                                          else
  1593.                                              syntaxError("definition");
  1594.                                         } break;/* End of actions */
  1595.     }
  1596.     goto yystack;  /* stack new state and value */
  1597.  
  1598. }
  1599.