home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume15 / reversi2 / part01 / makeedge.c next >
C/C++ Source or Header  |  1993-01-27  |  30KB  |  1,079 lines

  1. extern char *malloc(), *realloc();
  2.  
  3. # line 2 "makeedge.y"
  4. /*
  5.  *    ex:set ts=8 sw=8:
  6.  */
  7. int    score;
  8. extern int    position;
  9.  
  10. # line 8 "makeedge.y"
  11. typedef union  {
  12.     struct {
  13.         int    width;
  14.         int    position;
  15.         int    base;
  16.     } field;
  17.     int    ival;
  18. } YYSTYPE;
  19. # define WHITE 257
  20. # define BLACK 258
  21. # define EMPTY 259
  22. # define NL 260
  23. #define yyclearin yychar = -1
  24. #define yyerrok yyerrflag = 0
  25. extern int yychar;
  26. extern int yyerrflag;
  27. #ifndef YYMAXDEPTH
  28. #define YYMAXDEPTH 150
  29. #endif
  30. YYSTYPE yylval, yyval;
  31. # define YYERRCODE 256
  32.  
  33. # line 381 "makeedge.y"
  34.  
  35.  
  36. # include    <stdio.h>
  37.  
  38. main ()
  39. {
  40.     return yyparse ();
  41. }
  42.  
  43. char    line[80];
  44. char    *lp = line;
  45.  
  46. yyerror (s)
  47. char *s;
  48. {
  49.     fprintf (stderr, "%s in %s\n", s, line);
  50. }
  51.  
  52. yywrap ()
  53. {
  54.     return 1;
  55. }
  56.  
  57. int position = 1;
  58.  
  59. int base[] = { 0, 20, -30, 15, -5, -5, 15, -30, 20, 0 };
  60.  
  61. yylex ()
  62. {
  63.     char *gets();
  64.  
  65.     if (*lp == '\0')
  66.         if (fgets (line, 80, stdin) == 0)
  67.             return -1;
  68.         else
  69.             lp = line;
  70.     for (;;) {
  71.         switch (*lp++) {
  72.         case ' ':
  73.         case '\t':
  74.             break;
  75.         case '\n':
  76.             lp[-1] = '\0';
  77.             position = 1;
  78.             return NL;
  79.         case 'O':
  80.             yylval.field.base = -
  81.                 base[yylval.field.position = position++];
  82.             yylval.field.width = 1;
  83.             return BLACK;
  84.         case '*':
  85.             yylval.field.base =
  86.                 base[yylval.field.position = position++];
  87.             yylval.field.width = 1;
  88.             return WHITE;
  89.         case '-':
  90.             yylval.field.base = 0;
  91.             yylval.field.position = position++;
  92.             yylval.field.width = 1;
  93.             return EMPTY;
  94.         }
  95.     }
  96. }
  97. int yyexca[] ={
  98. -1, 1,
  99.     0, -1,
  100.     -2, 0,
  101.     };
  102. # define YYNPROD 50
  103. # define YYLAST 189
  104. int yyact[]={
  105.  
  106.      6,    14,    12,     9,     7,    12,     6,     7,    26,     6,
  107.     14,    50,     9,     7,    47,     6,    14,    41,     9,     7,
  108.     38,     6,     7,    12,     6,     7,     5,    14,    12,     9,
  109.     56,    12,    25,    36,    32,    22,     6,     7,     6,    26,
  110.      7,    59,     1,    31,    30,    27,    29,    60,     4,    35,
  111.     10,    37,    20,    21,    17,     2,     0,    46,     8,     0,
  112.      0,     0,    33,     0,    13,     0,    39,    55,     0,     0,
  113.     10,     0,     0,     0,     0,    49,     0,    66,     0,    69,
  114.      0,    68,    45,     0,    72,    65,    74,    62,    63,    10,
  115.     62,     0,     0,     0,    28,     0,     3,    71,    54,    15,
  116.     19,    64,    78,     0,    58,    23,    80,     0,    39,     0,
  117.     83,     0,    84,     0,     0,    42,     0,    81,    82,     0,
  118.      0,     0,    62,    62,    52,    70,     0,     0,    15,    11,
  119.     16,    18,    73,    57,    15,    61,    24,    75,    61,     0,
  120.      0,    34,    67,    76,     0,    40,    43,    77,     0,    44,
  121.      0,    79,     0,     0,    48,    51,     0,    42,     0,    53,
  122.      0,     0,     0,     0,     0,    16,     0,     0,    11,     0,
  123.     61,    61,     0,     0,     0,     0,     0,     0,     0,     0,
  124.      0,     0,     0,     0,     0,     0,     0,    40,    43 };
  125. int yypact[]={
  126.  
  127.  -1000,  -233, -1000,  -254,  -257,  -236, -1000, -1000,  -225, -1000,
  128.   -257,  -251, -1000,  -226, -1000,  -254,  -251,  -227,  -251,  -239,
  129.   -242, -1000, -1000,  -254,  -251, -1000, -1000, -1000,  -245,  -248,
  130.  -1000, -1000, -1000,  -257,  -251, -1000, -1000,  -230,  -219,  -257,
  131.   -251,  -218,  -254,  -251,  -251, -1000, -1000,  -219,  -251,  -231,
  132.   -218,  -251,  -228,  -251, -1000, -1000, -1000,  -228, -1000, -1000,
  133.  -1000,  -254,  -257,  -231, -1000, -1000, -1000,  -228, -1000,  -221,
  134.   -220,  -231, -1000,  -221, -1000,  -221,  -221,  -221, -1000,  -221,
  135.  -1000, -1000, -1000, -1000, -1000 };
  136. int yypgo[]={
  137.  
  138.      0,    55,    94,    46,   125,    79,    58,    64,    41,    47,
  139.     54,    32,    45,    44,    43,    42 };
  140. int yyr1[]={
  141.  
  142.      0,    15,    15,     1,     1,     1,     1,     6,     6,     6,
  143.      6,     6,     6,     7,     7,     7,     7,     7,     7,    11,
  144.     11,     2,     2,     3,     3,     4,     4,     8,     8,    10,
  145.     10,    10,     9,     9,     9,     9,     9,     9,    12,    12,
  146.     12,    12,    12,    12,    12,    12,    13,    14,     5,     5 };
  147. int yyr2[]={
  148.  
  149.      0,     5,     0,     7,     7,     7,     9,     9,     7,     7,
  150.      3,     5,     1,     9,     7,     7,     3,     5,     1,     3,
  151.      1,     5,     3,     5,     3,     5,     3,     3,     1,    11,
  152.     11,     2,     7,     7,     7,     7,     3,     3,    11,     7,
  153.     11,     7,     3,     3,     3,     3,     9,     9,     3,     1 };
  154. int yychk[]={
  155.  
  156.  -1000,   -15,    -1,    -2,    -3,   259,   257,   258,    -6,   257,
  157.     -3,    -4,   259,    -7,   258,    -2,    -4,   -10,    -4,    -2,
  158.     -3,    -9,   260,    -2,    -4,   -11,   259,   -12,    -2,    -3,
  159.    -13,   -14,   260,    -3,    -4,   -11,   260,   -11,   259,    -3,
  160.     -4,   259,    -2,    -4,    -4,    -6,   -11,   259,    -4,    -3,
  161.    259,    -4,    -2,    -4,    -7,   -11,   260,    -2,    -7,    -8,
  162.     -9,    -2,    -3,    -3,    -6,    -8,   -11,    -2,   -11,    -5,
  163.     -4,    -3,   -11,    -5,   -11,    -5,    -5,    -5,   -11,    -5,
  164.    -11,    -8,    -8,   -11,   -11 };
  165. int yydef[]={
  166.  
  167.      2,    -2,     1,    12,    18,     0,    22,    24,     0,    21,
  168.     10,    20,    26,     0,    23,    16,    20,     0,    20,    36,
  169.     37,    31,     3,    12,    20,    11,    25,    19,    42,    43,
  170.     44,    45,     4,    18,    20,    17,     5,     0,    26,    18,
  171.     28,    26,    12,    28,    20,     8,     9,    26,    20,    49,
  172.     26,    20,    49,    20,    14,    15,     6,    49,    32,    34,
  173.     27,    36,    37,    49,    33,    35,     7,    49,    39,    20,
  174.     48,    49,    41,    20,    13,    28,    28,    20,    46,    20,
  175.     47,    29,    30,    38,    40 };
  176. typedef struct { char *t_name; int t_val; } yytoktype;
  177. #ifndef YYDEBUG
  178. #    define YYDEBUG    0    /* don't allow debugging */
  179. #endif
  180.  
  181. #if YYDEBUG
  182.  
  183. yytoktype yytoks[] =
  184. {
  185.     "WHITE",    257,
  186.     "BLACK",    258,
  187.     "EMPTY",    259,
  188.     "NL",    260,
  189.     "-unknown-",    -1    /* ends search */
  190. };
  191.  
  192. char * yyreds[] =
  193. {
  194.     "-no such reduction-",
  195.     "lines : lines line",
  196.     "lines : /* empty */",
  197.     "line : whites type1 NL",
  198.     "line : blacks type2 NL",
  199.     "line : EMPTY type3 NL",
  200.     "line : EMPTY empties otype4 NL",
  201.     "type1 : blacks whites empties otype4",
  202.     "type1 : blacks whites type1",
  203.     "type1 : blacks empties otype4",
  204.     "type1 : blacks",
  205.     "type1 : empties otype4",
  206.     "type1 : /* empty */",
  207.     "type2 : whites blacks empties otype4",
  208.     "type2 : whites blacks type2",
  209.     "type2 : whites empties otype4",
  210.     "type2 : whites",
  211.     "type2 : empties otype4",
  212.     "type2 : /* empty */",
  213.     "otype4 : type4",
  214.     "otype4 : /* empty */",
  215.     "whites : whites WHITE",
  216.     "whites : WHITE",
  217.     "blacks : blacks BLACK",
  218.     "blacks : BLACK",
  219.     "empties : empties EMPTY",
  220.     "empties : EMPTY",
  221.     "otype3e : type3e",
  222.     "otype3e : /* empty */",
  223.     "type3 : whites EMPTY whites oempties otype3e",
  224.     "type3 : blacks EMPTY blacks oempties otype3e",
  225.     "type3 : type3e",
  226.     "type3e : whites blacks type2",
  227.     "type3e : blacks whites type1",
  228.     "type3e : whites empties otype3e",
  229.     "type3e : blacks empties otype3e",
  230.     "type3e : whites",
  231.     "type3e : blacks",
  232.     "type4 : whites EMPTY whites oempties otype4",
  233.     "type4 : whites empties otype4",
  234.     "type4 : blacks EMPTY blacks oempties otype4",
  235.     "type4 : blacks empties otype4",
  236.     "type4 : whites",
  237.     "type4 : blacks",
  238.     "type4 : type4.w",
  239.     "type4 : type4.b",
  240.     "type4.w : whites blacks oempties otype4",
  241.     "type4.b : blacks whites oempties otype4",
  242.     "oempties : empties",
  243.     "oempties : /* empty */",
  244. };
  245. #endif /* YYDEBUG */
  246. #line 1 "/usr/lib/yaccpar"
  247. /*    @(#)yaccpar 1.10 89/04/04 SMI; from S5R3 1.10    */
  248.  
  249. /*
  250. ** Skeleton parser driver for yacc output
  251. */
  252.  
  253. /*
  254. ** yacc user known macros and defines
  255. */
  256. #define YYERROR        goto yyerrlab
  257. #define YYACCEPT    { free(yys); free(yyv); return(0); }
  258. #define YYABORT        { free(yys); free(yyv); return(1); }
  259. #define YYBACKUP( newtoken, newvalue )\
  260. {\
  261.     if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
  262.     {\
  263.         yyerror( "syntax error - cannot backup" );\
  264.         goto yyerrlab;\
  265.     }\
  266.     yychar = newtoken;\
  267.     yystate = *yyps;\
  268.     yylval = newvalue;\
  269.     goto yynewstate;\
  270. }
  271. #define YYRECOVERING()    (!!yyerrflag)
  272. #ifndef YYDEBUG
  273. #    define YYDEBUG    1    /* make debugging available */
  274. #endif
  275.  
  276. /*
  277. ** user known globals
  278. */
  279. int yydebug;            /* set to 1 to get debugging */
  280.  
  281. /*
  282. ** driver internal defines
  283. */
  284. #define YYFLAG        (-1000)
  285.  
  286. /*
  287. ** static variables used by the parser
  288. */
  289. static YYSTYPE *yyv;            /* value stack */
  290. static int *yys;            /* state stack */
  291.  
  292. static YYSTYPE *yypv;            /* top of value stack */
  293. static int *yyps;            /* top of state stack */
  294.  
  295. static int yystate;            /* current state */
  296. static int yytmp;            /* extra var (lasts between blocks) */
  297.  
  298. int yynerrs;            /* number of errors */
  299.  
  300. int yyerrflag;            /* error recovery flag */
  301. int yychar;            /* current input token number */
  302.  
  303.  
  304. /*
  305. ** yyparse - return 0 if worked, 1 if syntax error not recovered from
  306. */
  307. int
  308. yyparse()
  309. {
  310.     register YYSTYPE *yypvt;    /* top of value stack for $vars */
  311.     unsigned yymaxdepth = YYMAXDEPTH;
  312.  
  313.     /*
  314.     ** Initialize externals - yyparse may be called more than once
  315.     */
  316.     yyv = (YYSTYPE*)malloc(yymaxdepth*sizeof(YYSTYPE));
  317.     yys = (int*)malloc(yymaxdepth*sizeof(int));
  318.     if (!yyv || !yys)
  319.     {
  320.         yyerror( "out of memory" );
  321.         return(1);
  322.     }
  323.     yypv = &yyv[-1];
  324.     yyps = &yys[-1];
  325.     yystate = 0;
  326.     yytmp = 0;
  327.     yynerrs = 0;
  328.     yyerrflag = 0;
  329.     yychar = -1;
  330.  
  331.     goto yystack;
  332.     {
  333.         register YYSTYPE *yy_pv;    /* top of value stack */
  334.         register int *yy_ps;        /* top of state stack */
  335.         register int yy_state;        /* current state */
  336.         register int  yy_n;        /* internal state number info */
  337.  
  338.         /*
  339.         ** get globals into registers.
  340.         ** branch to here only if YYBACKUP was called.
  341.         */
  342.     yynewstate:
  343.         yy_pv = yypv;
  344.         yy_ps = yyps;
  345.         yy_state = yystate;
  346.         goto yy_newstate;
  347.  
  348.         /*
  349.         ** get globals into registers.
  350.         ** either we just started, or we just finished a reduction
  351.         */
  352.     yystack:
  353.         yy_pv = yypv;
  354.         yy_ps = yyps;
  355.         yy_state = yystate;
  356.  
  357.         /*
  358.         ** top of for (;;) loop while no reductions done
  359.         */
  360.     yy_stack:
  361.         /*
  362.         ** put a state and value onto the stacks
  363.         */
  364. #if YYDEBUG
  365.         /*
  366.         ** if debugging, look up token value in list of value vs.
  367.         ** name pairs.  0 and negative (-1) are special values.
  368.         ** Note: linear search is used since time is not a real
  369.         ** consideration while debugging.
  370.         */
  371.         if ( yydebug )
  372.         {
  373.             register int yy_i;
  374.  
  375.             (void)printf( "State %d, token ", yy_state );
  376.             if ( yychar == 0 )
  377.                 (void)printf( "end-of-file\n" );
  378.             else if ( yychar < 0 )
  379.                 (void)printf( "-none-\n" );
  380.             else
  381.             {
  382.                 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
  383.                     yy_i++ )
  384.                 {
  385.                     if ( yytoks[yy_i].t_val == yychar )
  386.                         break;
  387.                 }
  388.                 (void)printf( "%s\n", yytoks[yy_i].t_name );
  389.             }
  390.         }
  391. #endif /* YYDEBUG */
  392.         if ( ++yy_ps >= &yys[ yymaxdepth ] )    /* room on stack? */
  393.         {
  394.             /*
  395.             ** reallocate and recover.  Note that pointers
  396.             ** have to be reset, or bad things will happen
  397.             */
  398.             int yyps_index = (yy_ps - yys);
  399.             int yypv_index = (yy_pv - yyv);
  400.             int yypvt_index = (yypvt - yyv);
  401.             yymaxdepth += YYMAXDEPTH;
  402.             yyv = (YYSTYPE*)realloc((char*)yyv,
  403.                 yymaxdepth * sizeof(YYSTYPE));
  404.             yys = (int*)realloc((char*)yys,
  405.                 yymaxdepth * sizeof(int));
  406.             if (!yyv || !yys)
  407.             {
  408.                 yyerror( "yacc stack overflow" );
  409.                 return(1);
  410.             }
  411.             yy_ps = yys + yyps_index;
  412.             yy_pv = yyv + yypv_index;
  413.             yypvt = yyv + yypvt_index;
  414.         }
  415.         *yy_ps = yy_state;
  416.         *++yy_pv = yyval;
  417.  
  418.         /*
  419.         ** we have a new state - find out what to do
  420.         */
  421.     yy_newstate:
  422.         if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
  423.             goto yydefault;        /* simple state */
  424. #if YYDEBUG
  425.         /*
  426.         ** if debugging, need to mark whether new token grabbed
  427.         */
  428.         yytmp = yychar < 0;
  429. #endif
  430.         if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
  431.             yychar = 0;        /* reached EOF */
  432. #if YYDEBUG
  433.         if ( yydebug && yytmp )
  434.         {
  435.             register int yy_i;
  436.  
  437.             (void)printf( "Received token " );
  438.             if ( yychar == 0 )
  439.                 (void)printf( "end-of-file\n" );
  440.             else if ( yychar < 0 )
  441.                 (void)printf( "-none-\n" );
  442.             else
  443.             {
  444.                 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
  445.                     yy_i++ )
  446.                 {
  447.                     if ( yytoks[yy_i].t_val == yychar )
  448.                         break;
  449.                 }
  450.                 (void)printf( "%s\n", yytoks[yy_i].t_name );
  451.             }
  452.         }
  453. #endif /* YYDEBUG */
  454.         if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
  455.             goto yydefault;
  456.         if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar )    /*valid shift*/
  457.         {
  458.             yychar = -1;
  459.             yyval = yylval;
  460.             yy_state = yy_n;
  461.             if ( yyerrflag > 0 )
  462.                 yyerrflag--;
  463.             goto yy_stack;
  464.         }
  465.  
  466.     yydefault:
  467.         if ( ( yy_n = yydef[ yy_state ] ) == -2 )
  468.         {
  469. #if YYDEBUG
  470.             yytmp = yychar < 0;
  471. #endif
  472.             if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )
  473.                 yychar = 0;        /* reached EOF */
  474. #if YYDEBUG
  475.             if ( yydebug && yytmp )
  476.             {
  477.                 register int yy_i;
  478.  
  479.                 (void)printf( "Received token " );
  480.                 if ( yychar == 0 )
  481.                     (void)printf( "end-of-file\n" );
  482.                 else if ( yychar < 0 )
  483.                     (void)printf( "-none-\n" );
  484.                 else
  485.                 {
  486.                     for ( yy_i = 0;
  487.                         yytoks[yy_i].t_val >= 0;
  488.                         yy_i++ )
  489.                     {
  490.                         if ( yytoks[yy_i].t_val
  491.                             == yychar )
  492.                         {
  493.                             break;
  494.                         }
  495.                     }
  496.                     (void)printf( "%s\n", yytoks[yy_i].t_name );
  497.                 }
  498.             }
  499. #endif /* YYDEBUG */
  500.             /*
  501.             ** look through exception table
  502.             */
  503.             {
  504.                 register int *yyxi = yyexca;
  505.  
  506.                 while ( ( *yyxi != -1 ) ||
  507.                     ( yyxi[1] != yy_state ) )
  508.                 {
  509.                     yyxi += 2;
  510.                 }
  511.                 while ( ( *(yyxi += 2) >= 0 ) &&
  512.                     ( *yyxi != yychar ) )
  513.                     ;
  514.                 if ( ( yy_n = yyxi[1] ) < 0 )
  515.                     YYACCEPT;
  516.             }
  517.         }
  518.  
  519.         /*
  520.         ** check for syntax error
  521.         */
  522.         if ( yy_n == 0 )    /* have an error */
  523.         {
  524.             /* no worry about speed here! */
  525.             switch ( yyerrflag )
  526.             {
  527.             case 0:        /* new error */
  528.                 yyerror( "syntax error" );
  529.                 goto skip_init;
  530.             yyerrlab:
  531.                 /*
  532.                 ** get globals into registers.
  533.                 ** we have a user generated syntax type error
  534.                 */
  535.                 yy_pv = yypv;
  536.                 yy_ps = yyps;
  537.                 yy_state = yystate;
  538.                 yynerrs++;
  539.             skip_init:
  540.             case 1:
  541.             case 2:        /* incompletely recovered error */
  542.                     /* try again... */
  543.                 yyerrflag = 3;
  544.                 /*
  545.                 ** find state where "error" is a legal
  546.                 ** shift action
  547.                 */
  548.                 while ( yy_ps >= yys )
  549.                 {
  550.                     yy_n = yypact[ *yy_ps ] + YYERRCODE;
  551.                     if ( yy_n >= 0 && yy_n < YYLAST &&
  552.                         yychk[yyact[yy_n]] == YYERRCODE)                    {
  553.                         /*
  554.                         ** simulate shift of "error"
  555.                         */
  556.                         yy_state = yyact[ yy_n ];
  557.                         goto yy_stack;
  558.                     }
  559.                     /*
  560.                     ** current state has no shift on
  561.                     ** "error", pop stack
  562.                     */
  563. #if YYDEBUG
  564. #    define _POP_ "Error recovery pops state %d, uncovers state %d\n"
  565.                     if ( yydebug )
  566.                         (void)printf( _POP_, *yy_ps,
  567.                             yy_ps[-1] );
  568. #    undef _POP_
  569. #endif
  570.                     yy_ps--;
  571.                     yy_pv--;
  572.                 }
  573.                 /*
  574.                 ** there is no state on stack with "error" as
  575.                 ** a valid shift.  give up.
  576.                 */
  577.                 YYABORT;
  578.             case 3:        /* no shift yet; eat a token */
  579. #if YYDEBUG
  580.                 /*
  581.                 ** if debugging, look up token in list of
  582.                 ** pairs.  0 and negative shouldn't occur,
  583.                 ** but since timing doesn't matter when
  584.                 ** debugging, it doesn't hurt to leave the
  585.                 ** tests here.
  586.                 */
  587.                 if ( yydebug )
  588.                 {
  589.                     register int yy_i;
  590.  
  591.                     (void)printf( "Error recovery discards " );
  592.                     if ( yychar == 0 )
  593.                         (void)printf( "token end-of-file\n" );
  594.                     else if ( yychar < 0 )
  595.                         (void)printf( "token -none-\n" );
  596.                     else
  597.                     {
  598.                         for ( yy_i = 0;
  599.                             yytoks[yy_i].t_val >= 0;
  600.                             yy_i++ )
  601.                         {
  602.                             if ( yytoks[yy_i].t_val
  603.                                 == yychar )
  604.                             {
  605.                                 break;
  606.                             }
  607.                         }
  608.                         (void)printf( "token %s\n",
  609.                             yytoks[yy_i].t_name );
  610.                     }
  611.                 }
  612. #endif /* YYDEBUG */
  613.                 if ( yychar == 0 )    /* reached EOF. quit */
  614.                     YYABORT;
  615.                 yychar = -1;
  616.                 goto yy_newstate;
  617.             }
  618.         }/* end if ( yy_n == 0 ) */
  619.         /*
  620.         ** reduction by production yy_n
  621.         ** put stack tops, etc. so things right after switch
  622.         */
  623. #if YYDEBUG
  624.         /*
  625.         ** if debugging, print the string that is the user's
  626.         ** specification of the reduction which is just about
  627.         ** to be done.
  628.         */
  629.         if ( yydebug )
  630.             (void)printf( "Reduce by (%d) \"%s\"\n",
  631.                 yy_n, yyreds[ yy_n ] );
  632. #endif
  633.         yytmp = yy_n;            /* value to switch over */
  634.         yypvt = yy_pv;            /* $vars top of value stack */
  635.         /*
  636.         ** Look in goto table for next state
  637.         ** Sorry about using yy_state here as temporary
  638.         ** register variable, but why not, if it works...
  639.         ** If yyr2[ yy_n ] doesn't have the low order bit
  640.         ** set, then there is no action to be done for
  641.         ** this reduction.  So, no saving & unsaving of
  642.         ** registers done.  The only difference between the
  643.         ** code just after the if and the body of the if is
  644.         ** the goto yy_stack in the body.  This way the test
  645.         ** can be made before the choice of what to do is needed.
  646.         */
  647.         {
  648.             /* length of production doubled with extra bit */
  649.             register int yy_len = yyr2[ yy_n ];
  650.  
  651.             if ( !( yy_len & 01 ) )
  652.             {
  653.                 yy_len >>= 1;
  654.                 yyval = ( yy_pv -= yy_len )[1];    /* $$ = $1 */
  655.                 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
  656.                     *( yy_ps -= yy_len ) + 1;
  657.                 if ( yy_state >= YYLAST ||
  658.                     yychk[ yy_state =
  659.                     yyact[ yy_state ] ] != -yy_n )
  660.                 {
  661.                     yy_state = yyact[ yypgo[ yy_n ] ];
  662.                 }
  663.                 goto yy_stack;
  664.             }
  665.             yy_len >>= 1;
  666.             yyval = ( yy_pv -= yy_len )[1];    /* $$ = $1 */
  667.             yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
  668.                 *( yy_ps -= yy_len ) + 1;
  669.             if ( yy_state >= YYLAST ||
  670.                 yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
  671.             {
  672.                 yy_state = yyact[ yypgo[ yy_n ] ];
  673.             }
  674.         }
  675.                     /* save until reenter driver code */
  676.         yystate = yy_state;
  677.         yyps = yy_ps;
  678.         yypv = yy_pv;
  679.     }
  680.     /*
  681.     ** code supplied by user is placed in this switch
  682.     */
  683.     switch( yytmp )
  684.     {
  685.         
  686. case 1:
  687. # line 22 "makeedge.y"
  688. { printf ("\t%5d,\t/*%s */\n", yypvt[-0].field.base, line); } break;
  689. case 3:
  690. # line 26 "makeedge.y"
  691. { yyval.field.base = 20 * yypvt[-2].field.width + yypvt[-1].field.base; } break;
  692. case 4:
  693. # line 28 "makeedge.y"
  694. { yyval.field.base = -20 * yypvt[-2].field.width + yypvt[-1].field.base; } break;
  695. case 5:
  696. # line 30 "makeedge.y"
  697. { yyval.field.base = yypvt[-1].field.base; } break;
  698. case 6:
  699. # line 32 "makeedge.y"
  700. { yyval.field.base = yypvt[-1].field.base; } break;
  701. case 7:
  702. # line 35 "makeedge.y"
  703. {
  704.                 yyval.field.base = yypvt[-0].field.base;
  705.                 switch (yypvt[-2].field.position) {
  706.                 case 7:
  707.                     yyval.field.base -= (yypvt[-2].field.width + yypvt[-3].field.width+1) * 15;
  708.                     break;
  709.                 default:
  710.                     if (yypvt[-1].field.width == 1)
  711.                         yyval.field.base -=
  712.                         (yypvt[-3].field.width + yypvt[-2].field.width+1) * 15;
  713.                     else
  714.                         yyval.field.base +=
  715.                         (yypvt[-2].field.width - yypvt[-3].field.width) * 20;
  716.                     break;
  717.                 }
  718.                 yyval.field.position = yypvt[-0].field.position;
  719.                 yyval.field.width = yypvt[-3].field.width + yypvt[-2].field.width + yypvt[-1].field.width;
  720.             } break;
  721. case 8:
  722. # line 54 "makeedge.y"
  723. {
  724.                 yyval.field.base = yypvt[-0].field.base;
  725.                 yyval.field.base -= (yypvt[-2].field.width - yypvt[-1].field.width) * 20;
  726.                 yyval.field.position = yypvt[-0].field.position;
  727.                 yyval.field.width = yypvt[-2].field.width + yypvt[-1].field.width + yypvt[-0].field.width;
  728.             } break;
  729. case 9:
  730. # line 61 "makeedge.y"
  731. {
  732.                 yyval.field.base = (yypvt[-2].field.width + 1) * 15 + yypvt[-0].field.base;
  733.                 yyval.field.width = yypvt[-2].field.width + yypvt[-1].field.width + yypvt[-0].field.width;
  734.                 yyval.field.position = yypvt[-0].field.position;
  735.             } break;
  736. case 10:
  737. # line 67 "makeedge.y"
  738. {
  739.                 yyval.field = yypvt[-0].field;
  740.                 yyval.field.base = - yypvt[-0].field.width * 20;
  741.             } break;
  742. case 11:
  743. # line 72 "makeedge.y"
  744. {
  745.                 yyval.field.position = yypvt[-0].field.position;
  746.                 yyval.field.width = yypvt[-1].field.width+yypvt[-0].field.width;
  747.                 yyval.field.base = yypvt[-0].field.base;
  748.             } break;
  749. case 12:
  750. # line 78 "makeedge.y"
  751. { yyval.field.position = position; yyval.field.width = 0; yyval.field.base = 0; } break;
  752. case 13:
  753. # line 81 "makeedge.y"
  754. {
  755.                 yyval.field.base = yypvt[-0].field.base;
  756.                 switch (yypvt[-2].field.position) {
  757.                 case 7:
  758.                     yyval.field.base += (yypvt[-2].field.width + yypvt[-3].field.width+1) * 15;
  759.                     break;
  760.                 default:
  761.                     if (yypvt[-1].field.width == 1)
  762.                         yyval.field.base +=
  763.                         (yypvt[-3].field.width + yypvt[-2].field.width+1) * 15;
  764.                     else
  765.                         yyval.field.base -=
  766.                         (yypvt[-2].field.width - yypvt[-3].field.width) * 20;
  767.                     break;
  768.                 }
  769.                 yyval.field.position = yypvt[-0].field.position;
  770.                 yyval.field.width = yypvt[-3].field.width + yypvt[-2].field.width + yypvt[-1].field.width
  771.                      + yypvt[-0].field.width;
  772.             } break;
  773. case 14:
  774. # line 101 "makeedge.y"
  775. {
  776.                 yyval.field.base = yypvt[-0].field.base;
  777.                 yyval.field.base += (yypvt[-2].field.width - yypvt[-1].field.width) * 20;
  778.                 yyval.field.position = yypvt[-0].field.position;
  779.                 yyval.field.width = yypvt[-2].field.width + yypvt[-1].field.width + yypvt[-0].field.width;
  780.             } break;
  781. case 15:
  782. # line 108 "makeedge.y"
  783. {
  784.                 yyval.field.base = - (yypvt[-2].field.width + 1) * 15 + yypvt[-0].field.base;
  785.                 yyval.field.width = yypvt[-2].field.width + yypvt[-1].field.width + yypvt[-0].field.width;
  786.                 yyval.field.position = yypvt[-0].field.position;
  787.             } break;
  788. case 16:
  789. # line 114 "makeedge.y"
  790. {
  791.                 yyval.field = yypvt[-0].field;
  792.                 yyval.field.base = yypvt[-0].field.width * 20;
  793.             } break;
  794. case 17:
  795. # line 119 "makeedge.y"
  796. {
  797.                 yyval.field.position = yypvt[-0].field.position;
  798.                 yyval.field.width = yypvt[-1].field.width+yypvt[-0].field.width;
  799.                 yyval.field.base = yypvt[-0].field.base;
  800.             } break;
  801. case 18:
  802. # line 125 "makeedge.y"
  803. { yyval.field.position = 0; yyval.field.width = 0; yyval.field.base = 0; } break;
  804. case 19:
  805. # line 128 "makeedge.y"
  806. { yyval.field = yypvt[-0].field; } break;
  807. case 20:
  808. # line 130 "makeedge.y"
  809. { yyval.field.position = position; yyval.field.width = 0; yyval.field.base = 0; } break;
  810. case 21:
  811. # line 133 "makeedge.y"
  812. {
  813.                 yyval.field.position = yypvt[-0].field.position;
  814.                 yyval.field.width = yypvt[-1].field.width + yypvt[-0].field.width;
  815.                 yyval.field.base = yypvt[-1].field.base + yypvt[-0].field.base;
  816.             } break;
  817. case 22:
  818. # line 139 "makeedge.y"
  819. { yyval.field = yypvt[-0].field; } break;
  820. case 23:
  821. # line 142 "makeedge.y"
  822. {
  823.                 yyval.field.position = yypvt[-0].field.position;
  824.                 yyval.field.width = yypvt[-1].field.width + yypvt[-0].field.width;
  825.                 yyval.field.base = yypvt[-1].field.base + yypvt[-0].field.base;
  826.             } break;
  827. case 24:
  828. # line 148 "makeedge.y"
  829. { yyval.field = yypvt[-0].field; } break;
  830. case 25:
  831. # line 151 "makeedge.y"
  832. {
  833.                 yyval.field.position = yypvt[-0].field.position;
  834.                 yyval.field.width = yypvt[-1].field.width + yypvt[-0].field.width;
  835.                 yyval.field.base = yypvt[-1].field.base + yypvt[-0].field.base;
  836.             } break;
  837. case 26:
  838. # line 157 "makeedge.y"
  839. { yyval.field = yypvt[-0].field; } break;
  840. case 27:
  841. # line 160 "makeedge.y"
  842. { yyval.field = yypvt[-0].field; } break;
  843. case 28:
  844. # line 162 "makeedge.y"
  845. { yyval.field.position = position; yyval.field.width = 0; yyval.field.base = 0; } break;
  846. case 29:
  847. # line 165 "makeedge.y"
  848. {
  849.                 yyval.field.base = -(yypvt[-4].field.width + yypvt[-2].field.width + 2) * 15 +
  850.                     yypvt[-0].field.base;
  851.                 yyval.field.width = yypvt[-4].field.width + yypvt[-3].field.width + yypvt[-2].field.width 
  852.                      + yypvt[-1].field.width + yypvt[-0].field.width;
  853.                 yyval.field.position = yypvt[-0].field.position;
  854.             } break;
  855. case 30:
  856. # line 173 "makeedge.y"
  857. {
  858.                 yyval.field.base = (yypvt[-4].field.width + yypvt[-2].field.width + 2) * 15 +
  859.                     yypvt[-0].field.base;
  860.                 yyval.field.width = yypvt[-4].field.width + yypvt[-3].field.width + yypvt[-2].field.width 
  861.                      + yypvt[-1].field.width + yypvt[-0].field.width;
  862.                 yyval.field.position = yypvt[-0].field.position;
  863.             } break;
  864. case 32:
  865. # line 183 "makeedge.y"
  866. {
  867.                 yyval.field.base = -15 * (yypvt[-2].field.width + yypvt[-1].field.width + 1);
  868.                 yyval.field.width = yypvt[-2].field.width + yypvt[-1].field.width + yypvt[-0].field.width;
  869.                 yyval.field.position = yypvt[-0].field.position;
  870.             } break;
  871. case 33:
  872. # line 189 "makeedge.y"
  873. {
  874.                 yyval.field.base = 15 * (yypvt[-2].field.width + yypvt[-1].field.width + 1);
  875.                 yyval.field.width = yypvt[-2].field.width + yypvt[-1].field.width + yypvt[-0].field.width;
  876.                 yyval.field.position = yypvt[-0].field.position;
  877.             } break;
  878. case 34:
  879. # line 195 "makeedge.y"
  880. {
  881.                 if (yypvt[-2].field.position - yypvt[-2].field.width == 1) {
  882.                     switch (yypvt[-2].field.width) {
  883.                     case 1:
  884.                         yyval.field.base = -30;
  885.                         break;
  886.                     case 6:
  887.                         yyval.field.base = -20;
  888.                         break;
  889.                     case 2:
  890.                         yyval.field.base = -15;
  891.                         break;
  892.                     case 3:
  893.                         yyval.field.base = -10;
  894.                         break;
  895.                     case 4:
  896.                         yyval.field.base = -5;
  897.                         break;
  898.                     case 5:
  899.                         yyval.field.base = 10;
  900.                         break;
  901.                     default:
  902.                         yyerror ("weirdo");
  903.                         break;
  904.                     }
  905.                 } else {
  906.                     yyval.field.base = yypvt[-2].field.base;
  907.                 }
  908.                 yyval.field.base += yypvt[-0].field.base;
  909.                 yyval.field.position = yypvt[-0].field.position;
  910.                 yyval.field.width = yypvt[-2].field.width + yypvt[-1].field.width + yypvt[-0].field.width;
  911.             } break;
  912. case 35:
  913. # line 228 "makeedge.y"
  914. {
  915.                 if (yypvt[-2].field.position - yypvt[-2].field.width == 1) {
  916.                     switch (yypvt[-2].field.width) {
  917.                     case 1:
  918.                         yyval.field.base = 30;
  919.                         break;
  920.                     case 6:
  921.                         yyval.field.base = 20;
  922.                     break;
  923.                     case 2:
  924.                         yyval.field.base = 15;
  925.                         break;
  926.                     case 3:
  927.                         yyval.field.base = 10;
  928.                         break;
  929.                     case 4:
  930.                         yyval.field.base = 5;
  931.                         break;
  932.                     case 5:
  933.                         yyval.field.base = -10;
  934.                         break;
  935.                     default:
  936.                         yyerror ("weirdo");
  937.                         break;
  938.                     }
  939.                 } else {
  940.                     yyval.field.base = yypvt[-2].field.base;
  941.                 }
  942.                 yyval.field.base += yypvt[-0].field.base;
  943.                 yyval.field.position = yypvt[-0].field.position;
  944.                 yyval.field.width = yypvt[-2].field.width + yypvt[-1].field.width + yypvt[-0].field.width;
  945.             } break;
  946. case 36:
  947. # line 261 "makeedge.y"
  948. {
  949.                 yyval.field.base = 20 * yypvt[-0].field.width;
  950.                 yyval.field.position = yypvt[-0].field.position;
  951.                 yyval.field.width = yypvt[-0].field.width;
  952.             } break;
  953. case 37:
  954. # line 267 "makeedge.y"
  955. {
  956.                 yyval.field.base = -20 * yypvt[-0].field.width;
  957.                 yyval.field.position = yypvt[-0].field.position;
  958.                 yyval.field.width = yypvt[-0].field.width;
  959.             } break;
  960. case 38:
  961. # line 274 "makeedge.y"
  962. {
  963.             if (yypvt[-1].field.position == 8) {
  964.                 yyval.field.base = -(yypvt[-4].field.width + yypvt[-2].field.width + 2) * 15;
  965.             } else {
  966.                 yyval.field.base = 0;
  967.                 if (yypvt[-4].field.position - yypvt[-4].field.width + 1 == 3)
  968.                     yyval.field.base = yypvt[-4].field.width * 15;
  969.                 else
  970.                     yyval.field.base = yypvt[-4].field.base;
  971.                 if (yypvt[-2].field.position == 6)
  972.                     yyval.field.base += yypvt[-2].field.width * 15;
  973.                 else
  974.                     yyval.field.base += yypvt[-2].field.base;
  975.                 yyval.field.base += yypvt[-0].field.base;
  976.             }
  977.             yyval.field.width = yypvt[-4].field.width + yypvt[-3].field.width + yypvt[-2].field.width
  978.                  + yypvt[-1].field.width + yypvt[-0].field.width;
  979.             yyval.field.position = yypvt[-0].field.position;
  980.         } break;
  981. case 39:
  982. # line 294 "makeedge.y"
  983. {
  984.                 if (yypvt[-2].field.position - yypvt[-2].field.width + 1 == 3)
  985.                     yyval.field.base = yypvt[-2].field.width * 15 + yypvt[-0].field.base;
  986.                 else if (yypvt[-2].field.position == 6)
  987.                     yyval.field.base = yypvt[-2].field.width * 15 + yypvt[-0].field.base;
  988.                 else
  989.                     yyval.field.base = yypvt[-2].field.base + yypvt[-0].field.base;
  990.                 yyval.field.position = yypvt[-0].field.position;
  991.                 yyval.field.width = yypvt[-2].field.width + yypvt[-1].field.width + yypvt[-0].field.width;
  992.             } break;
  993. case 40:
  994. # line 305 "makeedge.y"
  995. {
  996.             if (yypvt[-1].field.position == 8) {
  997.                 yyval.field.base = (yypvt[-4].field.width + yypvt[-2].field.width + 2) * 15;
  998.             } else {
  999.                 yyval.field.base = 0;
  1000.                 if (yypvt[-4].field.position - yypvt[-4].field.width + 1 == 3)
  1001.                     yyval.field.base = -yypvt[-4].field.width * 15;
  1002.                 else
  1003.                     yyval.field.base = yypvt[-4].field.base;
  1004.                 if (yypvt[-2].field.position == 6)
  1005.                     yyval.field.base +=  -yypvt[-2].field.width * 15;
  1006.                 else
  1007.                     yyval.field.base += yypvt[-2].field.base;
  1008.                 yyval.field.base += yypvt[-0].field.base;
  1009.             }
  1010.             yyval.field.width = yypvt[-4].field.width + yypvt[-3].field.width + yypvt[-2].field.width
  1011.                  + yypvt[-1].field.width + yypvt[-0].field.width;
  1012.             yyval.field.position = yypvt[-0].field.position;
  1013.         } break;
  1014. case 41:
  1015. # line 325 "makeedge.y"
  1016. {
  1017.                 if (yypvt[-2].field.position - yypvt[-2].field.width + 1 == 3)
  1018.                     yyval.field.base = -yypvt[-2].field.width * 15 + yypvt[-0].field.base;
  1019.                 else if (yypvt[-2].field.position == 6)
  1020.                     yyval.field.base = -yypvt[-2].field.width * 15 + yypvt[-0].field.base;
  1021.                 else
  1022.                     yyval.field.base = yypvt[-2].field.base + yypvt[-0].field.base;
  1023.                 yyval.field.position = yypvt[-0].field.position;
  1024.                 yyval.field.width = yypvt[-2].field.width + yypvt[-1].field.width + yypvt[-0].field.width;
  1025.             } break;
  1026. case 42:
  1027. # line 336 "makeedge.y"
  1028. {
  1029.                 yyval.field.base = 20 * yypvt[-0].field.width;
  1030.                 yyval.field.position = yypvt[-0].field.position;
  1031.                 yyval.field.width = yypvt[-0].field.width;
  1032.             } break;
  1033. case 43:
  1034. # line 342 "makeedge.y"
  1035. {
  1036.                 yyval.field.base = -20 * yypvt[-0].field.width;
  1037.                 yyval.field.position = yypvt[-0].field.position;
  1038.                 yyval.field.width = yypvt[-0].field.width;
  1039.             } break;
  1040. case 44:
  1041. # line 348 "makeedge.y"
  1042. { yyval.field = yypvt[-0].field; } break;
  1043. case 45:
  1044. # line 350 "makeedge.y"
  1045. { yyval.field = yypvt[-0].field; } break;
  1046. case 46:
  1047. # line 353 "makeedge.y"
  1048. {
  1049.             if (yypvt[-2].field.position == 8)
  1050.                 yyval.field.base = - (yypvt[-3].field.width + yypvt[-2].field.width + 1) * 15;
  1051.             else if (yypvt[-1].field.position == 8 && yypvt[-1].field.width == 1)
  1052.                 yyval.field.base = (yypvt[-3].field.width + yypvt[-2].field.width + 1) * 10;
  1053.             else
  1054.                 yyval.field.base = yypvt[-3].field.base + yypvt[-2].field.base + yypvt[-0].field.base;
  1055.             yyval.field.position = yypvt[-0].field.position;
  1056.             yyval.field.width = yypvt[-3].field.width + yypvt[-2].field.width + yypvt[-1].field.width + yypvt[-0].field.width;
  1057.         } break;
  1058. case 47:
  1059. # line 365 "makeedge.y"
  1060. {
  1061.             if (yypvt[-2].field.position == 8)
  1062.                 yyval.field.base = (yypvt[-3].field.width + yypvt[-2].field.width + 1) * 15;
  1063.             else if (yypvt[-1].field.position == 8 && yypvt[-1].field.width == 1)
  1064.                 yyval.field.base = - (yypvt[-3].field.width + yypvt[-2].field.width + 1) * 10;
  1065.             else
  1066.                 yyval.field.base = yypvt[-3].field.base + yypvt[-2].field.base + yypvt[-0].field.base;
  1067.             yyval.field.position = yypvt[-0].field.position;
  1068.             yyval.field.width = yypvt[-3].field.width + yypvt[-2].field.width + yypvt[-1].field.width + yypvt[-0].field.width;
  1069.         } break;
  1070. case 48:
  1071. # line 377 "makeedge.y"
  1072. { yyval.field = yypvt[-0].field; } break;
  1073. case 49:
  1074. # line 379 "makeedge.y"
  1075. { yyval.field.position = position; yyval.field.width = 0; yyval.field.base = 0; } break;
  1076.     }
  1077.     goto yystack;        /* reset registers in driver code */
  1078. }
  1079.