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