Annotation of OpenXM_contrib/gmp/demos/calc.c, Revision 1.1
1.1 ! maekawa 1:
! 2: /* A Bison parser, made from calc.y
! 3: by GNU Bison version 1.28 */
! 4:
! 5: #define YYBISON 1 /* Identify Bison output. */
! 6:
! 7: #define EOS 257
! 8: #define BAD 258
! 9: #define HEX 259
! 10: #define DECIMAL 260
! 11: #define QUIT 261
! 12: #define ABS 262
! 13: #define BIN 263
! 14: #define FIB 264
! 15: #define GCD 265
! 16: #define LCM 266
! 17: #define NEXTPRIME 267
! 18: #define POWM 268
! 19: #define ROOT 269
! 20: #define SQRT 270
! 21: #define NUMBER 271
! 22: #define VARIABLE 272
! 23: #define LOR 273
! 24: #define LAND 274
! 25: #define EQ 275
! 26: #define NE 276
! 27: #define LE 277
! 28: #define GE 278
! 29: #define LSHIFT 279
! 30: #define RSHIFT 280
! 31: #define UMINUS 281
! 32:
! 33: #line 99 "calc.y"
! 34:
! 35: #include <stdio.h>
! 36: #include <stdlib.h>
! 37:
! 38: #include "gmp.h"
! 39:
! 40: #define numberof(x) (sizeof (x) / sizeof ((x)[0]))
! 41:
! 42:
! 43: int ibase = 0;
! 44: int obase = 10;
! 45:
! 46:
! 47: /* The stack is a fixed size, which means there's a limit on the nesting
! 48: allowed in expressions. A more sophisticated program could let it grow
! 49: dynamically. */
! 50:
! 51: mpz_t stack[100];
! 52: mpz_ptr sp = stack[0];
! 53:
! 54: #define CHECK_OVERFLOW() \
! 55: if (sp >= stack[numberof(stack)]) \
! 56: { \
! 57: fprintf (stderr, \
! 58: "Value stack overflow, too much nesting in expression\n"); \
! 59: YYERROR; \
! 60: }
! 61:
! 62: #define CHECK_EMPTY() \
! 63: if (sp != stack[0]) \
! 64: { \
! 65: fprintf (stderr, "Oops, expected the value stack to be empty\n"); \
! 66: sp = stack[0]; \
! 67: }
! 68:
! 69:
! 70: mpz_t variable[26];
! 71:
! 72: #define CHECK_VARIABLE(var) \
! 73: if ((var) < 0 || (var) >= numberof (variable)) \
! 74: { \
! 75: fprintf (stderr, "Oops, bad variable somehow: %d\n", var); \
! 76: YYERROR; \
! 77: }
! 78:
! 79:
! 80: #define CHECK_UI(name,z) \
! 81: if (! mpz_fits_ulong_p (z)) \
! 82: { \
! 83: fprintf (stderr, \
! 84: "Operand must fit in an \"unsigned long\" for %s\n", name); \
! 85: YYERROR; \
! 86: }
! 87:
! 88:
! 89: #line 155 "calc.y"
! 90: typedef union {
! 91: char *str;
! 92: int var;
! 93: } YYSTYPE;
! 94: #include <stdio.h>
! 95:
! 96: #ifndef __cplusplus
! 97: #ifndef __STDC__
! 98: #define const
! 99: #endif
! 100: #endif
! 101:
! 102:
! 103:
! 104: #define YYFINAL 107
! 105: #define YYFLAG -32768
! 106: #define YYNTBASE 41
! 107:
! 108: #define YYTRANSLATE(x) ((unsigned)(x) <= 281 ? yytranslate[x] : 47)
! 109:
! 110: static const char yytranslate[] = { 0,
! 111: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 112: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 113: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 114: 2, 2, 36, 2, 2, 2, 33, 2, 2, 38,
! 115: 39, 31, 29, 40, 30, 2, 32, 2, 2, 2,
! 116: 2, 2, 2, 2, 2, 2, 2, 2, 2, 21,
! 117: 37, 22, 2, 2, 2, 2, 2, 2, 2, 2,
! 118: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 119: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 120: 2, 2, 2, 35, 2, 2, 2, 2, 2, 2,
! 121: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 122: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 123: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 124: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 125: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 126: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 127: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 128: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 129: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 130: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 131: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 132: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 133: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 134: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 135: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 136: 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
! 137: 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
! 138: 17, 18, 19, 20, 23, 24, 25, 26, 27, 28,
! 139: 34
! 140: };
! 141:
! 142: #if YYDEBUG != 0
! 143: static const short yyprhs[] = { 0,
! 144: 0, 2, 5, 8, 12, 15, 16, 18, 22, 24,
! 145: 26, 28, 32, 36, 40, 44, 48, 52, 56, 60,
! 146: 64, 67, 70, 74, 78, 82, 86, 90, 94, 98,
! 147: 102, 107, 114, 119, 124, 129, 134, 143, 150, 155,
! 148: 157, 159, 161, 165, 167
! 149: };
! 150:
! 151: static const short yyrhs[] = { 43,
! 152: 0, 42, 43, 0, 43, 3, 0, 42, 43, 3,
! 153: 0, 1, 3, 0, 0, 44, 0, 18, 37, 44,
! 154: 0, 5, 0, 6, 0, 7, 0, 38, 44, 39,
! 155: 0, 44, 29, 44, 0, 44, 30, 44, 0, 44,
! 156: 31, 44, 0, 44, 32, 44, 0, 44, 33, 44,
! 157: 0, 44, 35, 44, 0, 44, 27, 44, 0, 44,
! 158: 28, 44, 0, 44, 36, 0, 30, 44, 0, 44,
! 159: 21, 44, 0, 44, 25, 44, 0, 44, 23, 44,
! 160: 0, 44, 24, 44, 0, 44, 26, 44, 0, 44,
! 161: 22, 44, 0, 44, 20, 44, 0, 44, 19, 44,
! 162: 0, 8, 38, 44, 39, 0, 9, 38, 44, 40,
! 163: 44, 39, 0, 10, 38, 44, 39, 0, 11, 38,
! 164: 45, 39, 0, 12, 38, 46, 39, 0, 13, 38,
! 165: 44, 39, 0, 14, 38, 44, 40, 44, 40, 44,
! 166: 39, 0, 15, 38, 44, 40, 44, 39, 0, 16,
! 167: 38, 44, 39, 0, 18, 0, 17, 0, 44, 0,
! 168: 45, 40, 44, 0, 44, 0, 46, 40, 44, 0
! 169: };
! 170:
! 171: #endif
! 172:
! 173: #if YYDEBUG != 0
! 174: static const short yyrline[] = { 0,
! 175: 179, 181, 183, 185, 186, 188, 190, 195, 201, 202,
! 176: 203, 208, 210, 211, 212, 213, 214, 215, 217, 219,
! 177: 221, 223, 225, 226, 227, 228, 229, 230, 232, 233,
! 178: 235, 236, 238, 240, 241, 242, 243, 244, 246, 248,
! 179: 254, 264, 266, 268, 270
! 180: };
! 181: #endif
! 182:
! 183:
! 184: #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
! 185:
! 186: static const char * const yytname[] = { "$","error","$undefined.","EOS","BAD",
! 187: "HEX","DECIMAL","QUIT","ABS","BIN","FIB","GCD","LCM","NEXTPRIME","POWM","ROOT",
! 188: "SQRT","NUMBER","VARIABLE","LOR","LAND","'<'","'>'","EQ","NE","LE","GE","LSHIFT",
! 189: "RSHIFT","'+'","'-'","'*'","'/'","'%'","UMINUS","'^'","'!'","'='","'('","')'",
! 190: "','","top","statements","statement","e","gcdlist","lcmlist", NULL
! 191: };
! 192: #endif
! 193:
! 194: static const short yyr1[] = { 0,
! 195: 41, 41, 42, 42, 42, 43, 43, 43, 43, 43,
! 196: 43, 44, 44, 44, 44, 44, 44, 44, 44, 44,
! 197: 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
! 198: 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
! 199: 44, 45, 45, 46, 46
! 200: };
! 201:
! 202: static const short yyr2[] = { 0,
! 203: 1, 2, 2, 3, 2, 0, 1, 3, 1, 1,
! 204: 1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
! 205: 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
! 206: 4, 6, 4, 4, 4, 4, 8, 6, 4, 1,
! 207: 1, 1, 3, 1, 3
! 208: };
! 209:
! 210: static const short yydefact[] = { 0,
! 211: 0, 9, 10, 11, 0, 0, 0, 0, 0, 0,
! 212: 0, 0, 0, 41, 40, 0, 0, 6, 1, 7,
! 213: 5, 0, 0, 0, 0, 0, 0, 0, 0, 0,
! 214: 0, 40, 22, 0, 2, 3, 0, 0, 0, 0,
! 215: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
! 216: 0, 0, 21, 0, 0, 0, 42, 0, 44, 0,
! 217: 0, 0, 0, 0, 8, 12, 4, 30, 29, 23,
! 218: 28, 25, 26, 24, 27, 19, 20, 13, 14, 15,
! 219: 16, 17, 18, 31, 0, 33, 34, 0, 35, 0,
! 220: 36, 0, 0, 39, 0, 43, 45, 0, 0, 32,
! 221: 0, 38, 0, 37, 0, 0, 0
! 222: };
! 223:
! 224: static const short yydefgoto[] = { 105,
! 225: 18, 19, 20, 58, 60
! 226: };
! 227:
! 228: static const short yypact[] = { 37,
! 229: 15,-32768,-32768,-32768, -19, -18, 1, 3, 23, 26,
! 230: 28, 30, 32,-32768, 34, 92, 92, 81, 62, 368,
! 231: -32768, 92, 92, 92, 92, 92, 92, 92, 92, 92,
! 232: 92,-32768, -33, 200, 70,-32768, 92, 92, 92, 92,
! 233: 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
! 234: 92, 92,-32768, 221, 112, 242, 368, -35, 368, -23,
! 235: 263, 134, 156, 284, 368,-32768,-32768, 385, 401, 417,
! 236: 417, 417, 417, 417, 417, 27, 27, 47, 47, -33,
! 237: -33, -33, -33,-32768, 92,-32768,-32768, 92,-32768, 92,
! 238: -32768, 92, 92,-32768, 305, 368, 368, 178, 326,-32768,
! 239: 92,-32768, 347,-32768, 84, 113,-32768
! 240: };
! 241:
! 242: static const short yypgoto[] = {-32768,
! 243: -32768, 63, -16,-32768,-32768
! 244: };
! 245:
! 246:
! 247: #define YYLAST 453
! 248:
! 249:
! 250: static const short yytable[] = { 33,
! 251: 34, 52, 53, 87, 88, 54, 55, 56, 57, 59,
! 252: 61, 62, 63, 64, 65, 89, 90, 21, 22, 23,
! 253: 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
! 254: 78, 79, 80, 81, 82, 83, -6, 1, 24, -6,
! 255: 25, 2, 3, 4, 5, 6, 7, 8, 9, 10,
! 256: 11, 12, 13, 14, 15, 47, 48, 49, 50, 51,
! 257: 26, 52, 53, 27, 36, 28, 16, 29, 95, 30,
! 258: 31, 96, 67, 97, 17, 98, 99, 49, 50, 51,
! 259: 35, 52, 53, 106, 103, 2, 3, 4, 5, 6,
! 260: 7, 8, 9, 10, 11, 12, 13, 14, 15, 5,
! 261: 6, 7, 8, 9, 10, 11, 12, 13, 14, 32,
! 262: 16, 0, 107, 0, 0, 0, 0, 0, 17, 0,
! 263: 0, 16, 0, 0, 0, 0, 0, 0, 0, 17,
! 264: 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
! 265: 47, 48, 49, 50, 51, 0, 52, 53, 0, 0,
! 266: 0, 85, 37, 38, 39, 40, 41, 42, 43, 44,
! 267: 45, 46, 47, 48, 49, 50, 51, 0, 52, 53,
! 268: 0, 0, 0, 92, 37, 38, 39, 40, 41, 42,
! 269: 43, 44, 45, 46, 47, 48, 49, 50, 51, 0,
! 270: 52, 53, 0, 0, 0, 93, 37, 38, 39, 40,
! 271: 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
! 272: 51, 0, 52, 53, 0, 0, 0, 101, 37, 38,
! 273: 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
! 274: 49, 50, 51, 0, 52, 53, 0, 0, 66, 37,
! 275: 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
! 276: 48, 49, 50, 51, 0, 52, 53, 0, 0, 84,
! 277: 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
! 278: 47, 48, 49, 50, 51, 0, 52, 53, 0, 0,
! 279: 86, 37, 38, 39, 40, 41, 42, 43, 44, 45,
! 280: 46, 47, 48, 49, 50, 51, 0, 52, 53, 0,
! 281: 0, 91, 37, 38, 39, 40, 41, 42, 43, 44,
! 282: 45, 46, 47, 48, 49, 50, 51, 0, 52, 53,
! 283: 0, 0, 94, 37, 38, 39, 40, 41, 42, 43,
! 284: 44, 45, 46, 47, 48, 49, 50, 51, 0, 52,
! 285: 53, 0, 0, 100, 37, 38, 39, 40, 41, 42,
! 286: 43, 44, 45, 46, 47, 48, 49, 50, 51, 0,
! 287: 52, 53, 0, 0, 102, 37, 38, 39, 40, 41,
! 288: 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
! 289: 0, 52, 53, 0, 0, 104, 37, 38, 39, 40,
! 290: 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
! 291: 51, 0, 52, 53, 38, 39, 40, 41, 42, 43,
! 292: 44, 45, 46, 47, 48, 49, 50, 51, 0, 52,
! 293: 53, 39, 40, 41, 42, 43, 44, 45, 46, 47,
! 294: 48, 49, 50, 51, 0, 52, 53,-32768,-32768,-32768,
! 295: -32768,-32768,-32768, 45, 46, 47, 48, 49, 50, 51,
! 296: 0, 52, 53
! 297: };
! 298:
! 299: static const short yycheck[] = { 16,
! 300: 17, 35, 36, 39, 40, 22, 23, 24, 25, 26,
! 301: 27, 28, 29, 30, 31, 39, 40, 3, 38, 38,
! 302: 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
! 303: 47, 48, 49, 50, 51, 52, 0, 1, 38, 3,
! 304: 38, 5, 6, 7, 8, 9, 10, 11, 12, 13,
! 305: 14, 15, 16, 17, 18, 29, 30, 31, 32, 33,
! 306: 38, 35, 36, 38, 3, 38, 30, 38, 85, 38,
! 307: 37, 88, 3, 90, 38, 92, 93, 31, 32, 33,
! 308: 18, 35, 36, 0, 101, 5, 6, 7, 8, 9,
! 309: 10, 11, 12, 13, 14, 15, 16, 17, 18, 8,
! 310: 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
! 311: 30, -1, 0, -1, -1, -1, -1, -1, 38, -1,
! 312: -1, 30, -1, -1, -1, -1, -1, -1, -1, 38,
! 313: 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
! 314: 29, 30, 31, 32, 33, -1, 35, 36, -1, -1,
! 315: -1, 40, 19, 20, 21, 22, 23, 24, 25, 26,
! 316: 27, 28, 29, 30, 31, 32, 33, -1, 35, 36,
! 317: -1, -1, -1, 40, 19, 20, 21, 22, 23, 24,
! 318: 25, 26, 27, 28, 29, 30, 31, 32, 33, -1,
! 319: 35, 36, -1, -1, -1, 40, 19, 20, 21, 22,
! 320: 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
! 321: 33, -1, 35, 36, -1, -1, -1, 40, 19, 20,
! 322: 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
! 323: 31, 32, 33, -1, 35, 36, -1, -1, 39, 19,
! 324: 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
! 325: 30, 31, 32, 33, -1, 35, 36, -1, -1, 39,
! 326: 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
! 327: 29, 30, 31, 32, 33, -1, 35, 36, -1, -1,
! 328: 39, 19, 20, 21, 22, 23, 24, 25, 26, 27,
! 329: 28, 29, 30, 31, 32, 33, -1, 35, 36, -1,
! 330: -1, 39, 19, 20, 21, 22, 23, 24, 25, 26,
! 331: 27, 28, 29, 30, 31, 32, 33, -1, 35, 36,
! 332: -1, -1, 39, 19, 20, 21, 22, 23, 24, 25,
! 333: 26, 27, 28, 29, 30, 31, 32, 33, -1, 35,
! 334: 36, -1, -1, 39, 19, 20, 21, 22, 23, 24,
! 335: 25, 26, 27, 28, 29, 30, 31, 32, 33, -1,
! 336: 35, 36, -1, -1, 39, 19, 20, 21, 22, 23,
! 337: 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
! 338: -1, 35, 36, -1, -1, 39, 19, 20, 21, 22,
! 339: 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
! 340: 33, -1, 35, 36, 20, 21, 22, 23, 24, 25,
! 341: 26, 27, 28, 29, 30, 31, 32, 33, -1, 35,
! 342: 36, 21, 22, 23, 24, 25, 26, 27, 28, 29,
! 343: 30, 31, 32, 33, -1, 35, 36, 21, 22, 23,
! 344: 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
! 345: -1, 35, 36
! 346: };
! 347: /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
! 348: #line 3 "/usr/share/misc/bison.simple"
! 349: /* This file comes from bison-1.28. */
! 350:
! 351: /* Skeleton output parser for bison,
! 352: Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
! 353:
! 354: This program is free software; you can redistribute it and/or modify
! 355: it under the terms of the GNU General Public License as published by
! 356: the Free Software Foundation; either version 2, or (at your option)
! 357: any later version.
! 358:
! 359: This program is distributed in the hope that it will be useful,
! 360: but WITHOUT ANY WARRANTY; without even the implied warranty of
! 361: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 362: GNU General Public License for more details.
! 363:
! 364: You should have received a copy of the GNU General Public License
! 365: along with this program; if not, write to the Free Software
! 366: Foundation, Inc., 59 Temple Place - Suite 330,
! 367: Boston, MA 02111-1307, USA. */
! 368:
! 369: /* As a special exception, when this file is copied by Bison into a
! 370: Bison output file, you may use that output file without restriction.
! 371: This special exception was added by the Free Software Foundation
! 372: in version 1.24 of Bison. */
! 373:
! 374: /* This is the parser code that is written into each bison parser
! 375: when the %semantic_parser declaration is not specified in the grammar.
! 376: It was written by Richard Stallman by simplifying the hairy parser
! 377: used when %semantic_parser is specified. */
! 378:
! 379: #ifndef YYSTACK_USE_ALLOCA
! 380: #ifdef alloca
! 381: #define YYSTACK_USE_ALLOCA
! 382: #else /* alloca not defined */
! 383: #ifdef __GNUC__
! 384: #define YYSTACK_USE_ALLOCA
! 385: #define alloca __builtin_alloca
! 386: #else /* not GNU C. */
! 387: #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
! 388: #define YYSTACK_USE_ALLOCA
! 389: #include <alloca.h>
! 390: #else /* not sparc */
! 391: /* We think this test detects Watcom and Microsoft C. */
! 392: /* This used to test MSDOS, but that is a bad idea
! 393: since that symbol is in the user namespace. */
! 394: #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
! 395: #if 0 /* No need for malloc.h, which pollutes the namespace;
! 396: instead, just don't use alloca. */
! 397: #include <malloc.h>
! 398: #endif
! 399: #else /* not MSDOS, or __TURBOC__ */
! 400: #if defined(_AIX)
! 401: /* I don't know what this was needed for, but it pollutes the namespace.
! 402: So I turned it off. rms, 2 May 1997. */
! 403: /* #include <malloc.h> */
! 404: #pragma alloca
! 405: #define YYSTACK_USE_ALLOCA
! 406: #else /* not MSDOS, or __TURBOC__, or _AIX */
! 407: #if 0
! 408: #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
! 409: and on HPUX 10. Eventually we can turn this on. */
! 410: #define YYSTACK_USE_ALLOCA
! 411: #define alloca __builtin_alloca
! 412: #endif /* __hpux */
! 413: #endif
! 414: #endif /* not _AIX */
! 415: #endif /* not MSDOS, or __TURBOC__ */
! 416: #endif /* not sparc */
! 417: #endif /* not GNU C */
! 418: #endif /* alloca not defined */
! 419: #endif /* YYSTACK_USE_ALLOCA not defined */
! 420:
! 421: #ifdef YYSTACK_USE_ALLOCA
! 422: #define YYSTACK_ALLOC alloca
! 423: #else
! 424: #define YYSTACK_ALLOC malloc
! 425: #endif
! 426:
! 427: /* Note: there must be only one dollar sign in this file.
! 428: It is replaced by the list of actions, each action
! 429: as one case of the switch. */
! 430:
! 431: #define yyerrok (yyerrstatus = 0)
! 432: #define yyclearin (yychar = YYEMPTY)
! 433: #define YYEMPTY -2
! 434: #define YYEOF 0
! 435: #define YYACCEPT goto yyacceptlab
! 436: #define YYABORT goto yyabortlab
! 437: #define YYERROR goto yyerrlab1
! 438: /* Like YYERROR except do call yyerror.
! 439: This remains here temporarily to ease the
! 440: transition to the new meaning of YYERROR, for GCC.
! 441: Once GCC version 2 has supplanted version 1, this can go. */
! 442: #define YYFAIL goto yyerrlab
! 443: #define YYRECOVERING() (!!yyerrstatus)
! 444: #define YYBACKUP(token, value) \
! 445: do \
! 446: if (yychar == YYEMPTY && yylen == 1) \
! 447: { yychar = (token), yylval = (value); \
! 448: yychar1 = YYTRANSLATE (yychar); \
! 449: YYPOPSTACK; \
! 450: goto yybackup; \
! 451: } \
! 452: else \
! 453: { yyerror ("syntax error: cannot back up"); YYERROR; } \
! 454: while (0)
! 455:
! 456: #define YYTERROR 1
! 457: #define YYERRCODE 256
! 458:
! 459: #ifndef YYPURE
! 460: #define YYLEX yylex()
! 461: #endif
! 462:
! 463: #ifdef YYPURE
! 464: #ifdef YYLSP_NEEDED
! 465: #ifdef YYLEX_PARAM
! 466: #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
! 467: #else
! 468: #define YYLEX yylex(&yylval, &yylloc)
! 469: #endif
! 470: #else /* not YYLSP_NEEDED */
! 471: #ifdef YYLEX_PARAM
! 472: #define YYLEX yylex(&yylval, YYLEX_PARAM)
! 473: #else
! 474: #define YYLEX yylex(&yylval)
! 475: #endif
! 476: #endif /* not YYLSP_NEEDED */
! 477: #endif
! 478:
! 479: /* If nonreentrant, generate the variables here */
! 480:
! 481: #ifndef YYPURE
! 482:
! 483: int yychar; /* the lookahead symbol */
! 484: YYSTYPE yylval; /* the semantic value of the */
! 485: /* lookahead symbol */
! 486:
! 487: #ifdef YYLSP_NEEDED
! 488: YYLTYPE yylloc; /* location data for the lookahead */
! 489: /* symbol */
! 490: #endif
! 491:
! 492: int yynerrs; /* number of parse errors so far */
! 493: #endif /* not YYPURE */
! 494:
! 495: #if YYDEBUG != 0
! 496: int yydebug; /* nonzero means print parse trace */
! 497: /* Since this is uninitialized, it does not stop multiple parsers
! 498: from coexisting. */
! 499: #endif
! 500:
! 501: /* YYINITDEPTH indicates the initial size of the parser's stacks */
! 502:
! 503: #ifndef YYINITDEPTH
! 504: #define YYINITDEPTH 200
! 505: #endif
! 506:
! 507: /* YYMAXDEPTH is the maximum size the stacks can grow to
! 508: (effective only if the built-in stack extension method is used). */
! 509:
! 510: #if YYMAXDEPTH == 0
! 511: #undef YYMAXDEPTH
! 512: #endif
! 513:
! 514: #ifndef YYMAXDEPTH
! 515: #define YYMAXDEPTH 10000
! 516: #endif
! 517:
! 518: /* Define __yy_memcpy. Note that the size argument
! 519: should be passed with type unsigned int, because that is what the non-GCC
! 520: definitions require. With GCC, __builtin_memcpy takes an arg
! 521: of type size_t, but it can handle unsigned int. */
! 522:
! 523: #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
! 524: #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
! 525: #else /* not GNU C or C++ */
! 526: #ifndef __cplusplus
! 527:
! 528: /* This is the most reliable way to avoid incompatibilities
! 529: in available built-in functions on various systems. */
! 530: static void
! 531: __yy_memcpy (to, from, count)
! 532: char *to;
! 533: char *from;
! 534: unsigned int count;
! 535: {
! 536: register char *f = from;
! 537: register char *t = to;
! 538: register int i = count;
! 539:
! 540: while (i-- > 0)
! 541: *t++ = *f++;
! 542: }
! 543:
! 544: #else /* __cplusplus */
! 545:
! 546: /* This is the most reliable way to avoid incompatibilities
! 547: in available built-in functions on various systems. */
! 548: static void
! 549: __yy_memcpy (char *to, char *from, unsigned int count)
! 550: {
! 551: register char *t = to;
! 552: register char *f = from;
! 553: register int i = count;
! 554:
! 555: while (i-- > 0)
! 556: *t++ = *f++;
! 557: }
! 558:
! 559: #endif
! 560: #endif
! 561:
! 562: #line 217 "/usr/share/misc/bison.simple"
! 563:
! 564: /* The user can define YYPARSE_PARAM as the name of an argument to be passed
! 565: into yyparse. The argument should have type void *.
! 566: It should actually point to an object.
! 567: Grammar actions can access the variable by casting it
! 568: to the proper pointer type. */
! 569:
! 570: #ifdef YYPARSE_PARAM
! 571: #ifdef __cplusplus
! 572: #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
! 573: #define YYPARSE_PARAM_DECL
! 574: #else /* not __cplusplus */
! 575: #define YYPARSE_PARAM_ARG YYPARSE_PARAM
! 576: #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
! 577: #endif /* not __cplusplus */
! 578: #else /* not YYPARSE_PARAM */
! 579: #define YYPARSE_PARAM_ARG
! 580: #define YYPARSE_PARAM_DECL
! 581: #endif /* not YYPARSE_PARAM */
! 582:
! 583: /* Prevent warning if -Wstrict-prototypes. */
! 584: #ifdef __GNUC__
! 585: #ifdef YYPARSE_PARAM
! 586: int yyparse (void *);
! 587: #else
! 588: int yyparse (void);
! 589: #endif
! 590: #endif
! 591:
! 592: int
! 593: yyparse(YYPARSE_PARAM_ARG)
! 594: YYPARSE_PARAM_DECL
! 595: {
! 596: register int yystate;
! 597: register int yyn;
! 598: register short *yyssp;
! 599: register YYSTYPE *yyvsp;
! 600: int yyerrstatus; /* number of tokens to shift before error messages enabled */
! 601: int yychar1 = 0; /* lookahead token as an internal (translated) token number */
! 602:
! 603: short yyssa[YYINITDEPTH]; /* the state stack */
! 604: YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
! 605:
! 606: short *yyss = yyssa; /* refer to the stacks thru separate pointers */
! 607: YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
! 608:
! 609: #ifdef YYLSP_NEEDED
! 610: YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
! 611: YYLTYPE *yyls = yylsa;
! 612: YYLTYPE *yylsp;
! 613:
! 614: #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
! 615: #else
! 616: #define YYPOPSTACK (yyvsp--, yyssp--)
! 617: #endif
! 618:
! 619: int yystacksize = YYINITDEPTH;
! 620: int yyfree_stacks = 0;
! 621:
! 622: #ifdef YYPURE
! 623: int yychar;
! 624: YYSTYPE yylval;
! 625: int yynerrs;
! 626: #ifdef YYLSP_NEEDED
! 627: YYLTYPE yylloc;
! 628: #endif
! 629: #endif
! 630:
! 631: YYSTYPE yyval; /* the variable used to return */
! 632: /* semantic values from the action */
! 633: /* routines */
! 634:
! 635: int yylen;
! 636:
! 637: #if YYDEBUG != 0
! 638: if (yydebug)
! 639: fprintf(stderr, "Starting parse\n");
! 640: #endif
! 641:
! 642: yystate = 0;
! 643: yyerrstatus = 0;
! 644: yynerrs = 0;
! 645: yychar = YYEMPTY; /* Cause a token to be read. */
! 646:
! 647: /* Initialize stack pointers.
! 648: Waste one element of value and location stack
! 649: so that they stay on the same level as the state stack.
! 650: The wasted elements are never initialized. */
! 651:
! 652: yyssp = yyss - 1;
! 653: yyvsp = yyvs;
! 654: #ifdef YYLSP_NEEDED
! 655: yylsp = yyls;
! 656: #endif
! 657:
! 658: /* Push a new state, which is found in yystate . */
! 659: /* In all cases, when you get here, the value and location stacks
! 660: have just been pushed. so pushing a state here evens the stacks. */
! 661: yynewstate:
! 662:
! 663: *++yyssp = yystate;
! 664:
! 665: if (yyssp >= yyss + yystacksize - 1)
! 666: {
! 667: /* Give user a chance to reallocate the stack */
! 668: /* Use copies of these so that the &'s don't force the real ones into memory. */
! 669: YYSTYPE *yyvs1 = yyvs;
! 670: short *yyss1 = yyss;
! 671: #ifdef YYLSP_NEEDED
! 672: YYLTYPE *yyls1 = yyls;
! 673: #endif
! 674:
! 675: /* Get the current used size of the three stacks, in elements. */
! 676: int size = yyssp - yyss + 1;
! 677:
! 678: #ifdef yyoverflow
! 679: /* Each stack pointer address is followed by the size of
! 680: the data in use in that stack, in bytes. */
! 681: #ifdef YYLSP_NEEDED
! 682: /* This used to be a conditional around just the two extra args,
! 683: but that might be undefined if yyoverflow is a macro. */
! 684: yyoverflow("parser stack overflow",
! 685: &yyss1, size * sizeof (*yyssp),
! 686: &yyvs1, size * sizeof (*yyvsp),
! 687: &yyls1, size * sizeof (*yylsp),
! 688: &yystacksize);
! 689: #else
! 690: yyoverflow("parser stack overflow",
! 691: &yyss1, size * sizeof (*yyssp),
! 692: &yyvs1, size * sizeof (*yyvsp),
! 693: &yystacksize);
! 694: #endif
! 695:
! 696: yyss = yyss1; yyvs = yyvs1;
! 697: #ifdef YYLSP_NEEDED
! 698: yyls = yyls1;
! 699: #endif
! 700: #else /* no yyoverflow */
! 701: /* Extend the stack our own way. */
! 702: if (yystacksize >= YYMAXDEPTH)
! 703: {
! 704: yyerror("parser stack overflow");
! 705: if (yyfree_stacks)
! 706: {
! 707: free (yyss);
! 708: free (yyvs);
! 709: #ifdef YYLSP_NEEDED
! 710: free (yyls);
! 711: #endif
! 712: }
! 713: return 2;
! 714: }
! 715: yystacksize *= 2;
! 716: if (yystacksize > YYMAXDEPTH)
! 717: yystacksize = YYMAXDEPTH;
! 718: #ifndef YYSTACK_USE_ALLOCA
! 719: yyfree_stacks = 1;
! 720: #endif
! 721: yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
! 722: __yy_memcpy ((char *)yyss, (char *)yyss1,
! 723: size * (unsigned int) sizeof (*yyssp));
! 724: yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
! 725: __yy_memcpy ((char *)yyvs, (char *)yyvs1,
! 726: size * (unsigned int) sizeof (*yyvsp));
! 727: #ifdef YYLSP_NEEDED
! 728: yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
! 729: __yy_memcpy ((char *)yyls, (char *)yyls1,
! 730: size * (unsigned int) sizeof (*yylsp));
! 731: #endif
! 732: #endif /* no yyoverflow */
! 733:
! 734: yyssp = yyss + size - 1;
! 735: yyvsp = yyvs + size - 1;
! 736: #ifdef YYLSP_NEEDED
! 737: yylsp = yyls + size - 1;
! 738: #endif
! 739:
! 740: #if YYDEBUG != 0
! 741: if (yydebug)
! 742: fprintf(stderr, "Stack size increased to %d\n", yystacksize);
! 743: #endif
! 744:
! 745: if (yyssp >= yyss + yystacksize - 1)
! 746: YYABORT;
! 747: }
! 748:
! 749: #if YYDEBUG != 0
! 750: if (yydebug)
! 751: fprintf(stderr, "Entering state %d\n", yystate);
! 752: #endif
! 753:
! 754: goto yybackup;
! 755: yybackup:
! 756:
! 757: /* Do appropriate processing given the current state. */
! 758: /* Read a lookahead token if we need one and don't already have one. */
! 759: /* yyresume: */
! 760:
! 761: /* First try to decide what to do without reference to lookahead token. */
! 762:
! 763: yyn = yypact[yystate];
! 764: if (yyn == YYFLAG)
! 765: goto yydefault;
! 766:
! 767: /* Not known => get a lookahead token if don't already have one. */
! 768:
! 769: /* yychar is either YYEMPTY or YYEOF
! 770: or a valid token in external form. */
! 771:
! 772: if (yychar == YYEMPTY)
! 773: {
! 774: #if YYDEBUG != 0
! 775: if (yydebug)
! 776: fprintf(stderr, "Reading a token: ");
! 777: #endif
! 778: yychar = YYLEX;
! 779: }
! 780:
! 781: /* Convert token to internal form (in yychar1) for indexing tables with */
! 782:
! 783: if (yychar <= 0) /* This means end of input. */
! 784: {
! 785: yychar1 = 0;
! 786: yychar = YYEOF; /* Don't call YYLEX any more */
! 787:
! 788: #if YYDEBUG != 0
! 789: if (yydebug)
! 790: fprintf(stderr, "Now at end of input.\n");
! 791: #endif
! 792: }
! 793: else
! 794: {
! 795: yychar1 = YYTRANSLATE(yychar);
! 796:
! 797: #if YYDEBUG != 0
! 798: if (yydebug)
! 799: {
! 800: fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
! 801: /* Give the individual parser a way to print the precise meaning
! 802: of a token, for further debugging info. */
! 803: #ifdef YYPRINT
! 804: YYPRINT (stderr, yychar, yylval);
! 805: #endif
! 806: fprintf (stderr, ")\n");
! 807: }
! 808: #endif
! 809: }
! 810:
! 811: yyn += yychar1;
! 812: if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
! 813: goto yydefault;
! 814:
! 815: yyn = yytable[yyn];
! 816:
! 817: /* yyn is what to do for this token type in this state.
! 818: Negative => reduce, -yyn is rule number.
! 819: Positive => shift, yyn is new state.
! 820: New state is final state => don't bother to shift,
! 821: just return success.
! 822: 0, or most negative number => error. */
! 823:
! 824: if (yyn < 0)
! 825: {
! 826: if (yyn == YYFLAG)
! 827: goto yyerrlab;
! 828: yyn = -yyn;
! 829: goto yyreduce;
! 830: }
! 831: else if (yyn == 0)
! 832: goto yyerrlab;
! 833:
! 834: if (yyn == YYFINAL)
! 835: YYACCEPT;
! 836:
! 837: /* Shift the lookahead token. */
! 838:
! 839: #if YYDEBUG != 0
! 840: if (yydebug)
! 841: fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
! 842: #endif
! 843:
! 844: /* Discard the token being shifted unless it is eof. */
! 845: if (yychar != YYEOF)
! 846: yychar = YYEMPTY;
! 847:
! 848: *++yyvsp = yylval;
! 849: #ifdef YYLSP_NEEDED
! 850: *++yylsp = yylloc;
! 851: #endif
! 852:
! 853: /* count tokens shifted since error; after three, turn off error status. */
! 854: if (yyerrstatus) yyerrstatus--;
! 855:
! 856: yystate = yyn;
! 857: goto yynewstate;
! 858:
! 859: /* Do the default action for the current state. */
! 860: yydefault:
! 861:
! 862: yyn = yydefact[yystate];
! 863: if (yyn == 0)
! 864: goto yyerrlab;
! 865:
! 866: /* Do a reduction. yyn is the number of a rule to reduce with. */
! 867: yyreduce:
! 868: yylen = yyr2[yyn];
! 869: if (yylen > 0)
! 870: yyval = yyvsp[1-yylen]; /* implement default value of the action */
! 871:
! 872: #if YYDEBUG != 0
! 873: if (yydebug)
! 874: {
! 875: int i;
! 876:
! 877: fprintf (stderr, "Reducing via rule %d (line %d), ",
! 878: yyn, yyrline[yyn]);
! 879:
! 880: /* Print the symbols being reduced, and their result. */
! 881: for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
! 882: fprintf (stderr, "%s ", yytname[yyrhs[i]]);
! 883: fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
! 884: }
! 885: #endif
! 886:
! 887:
! 888: switch (yyn) {
! 889:
! 890: case 5:
! 891: #line 186 "calc.y"
! 892: { sp = stack[0]; yyerrok; ;
! 893: break;}
! 894: case 7:
! 895: #line 190 "calc.y"
! 896: {
! 897: mpz_out_str (stdout, obase, sp); putchar ('\n');
! 898: sp--;
! 899: CHECK_EMPTY ();
! 900: ;
! 901: break;}
! 902: case 8:
! 903: #line 195 "calc.y"
! 904: {
! 905: CHECK_VARIABLE (yyvsp[-2].var);
! 906: mpz_swap (variable[yyvsp[-2].var], sp);
! 907: sp--;
! 908: CHECK_EMPTY ();
! 909: ;
! 910: break;}
! 911: case 9:
! 912: #line 201 "calc.y"
! 913: { ibase = 16; obase = -16; ;
! 914: break;}
! 915: case 10:
! 916: #line 202 "calc.y"
! 917: { ibase = 0; obase = 10; ;
! 918: break;}
! 919: case 11:
! 920: #line 203 "calc.y"
! 921: { exit (0); ;
! 922: break;}
! 923: case 13:
! 924: #line 210 "calc.y"
! 925: { sp--; mpz_add (sp, sp, sp+1); ;
! 926: break;}
! 927: case 14:
! 928: #line 211 "calc.y"
! 929: { sp--; mpz_sub (sp, sp, sp+1); ;
! 930: break;}
! 931: case 15:
! 932: #line 212 "calc.y"
! 933: { sp--; mpz_mul (sp, sp, sp+1); ;
! 934: break;}
! 935: case 16:
! 936: #line 213 "calc.y"
! 937: { sp--; mpz_fdiv_q (sp, sp, sp+1); ;
! 938: break;}
! 939: case 17:
! 940: #line 214 "calc.y"
! 941: { sp--; mpz_fdiv_r (sp, sp, sp+1); ;
! 942: break;}
! 943: case 18:
! 944: #line 215 "calc.y"
! 945: { CHECK_UI ("exponentiation", sp);
! 946: sp--; mpz_pow_ui (sp, sp, mpz_get_ui (sp+1)); ;
! 947: break;}
! 948: case 19:
! 949: #line 217 "calc.y"
! 950: { CHECK_UI ("lshift", sp);
! 951: sp--; mpz_mul_2exp (sp, sp, mpz_get_ui (sp+1)); ;
! 952: break;}
! 953: case 20:
! 954: #line 219 "calc.y"
! 955: { CHECK_UI ("rshift", sp);
! 956: sp--; mpz_fdiv_q_2exp (sp, sp, mpz_get_ui (sp+1)); ;
! 957: break;}
! 958: case 21:
! 959: #line 221 "calc.y"
! 960: { CHECK_UI ("factorial", sp);
! 961: mpz_fac_ui (sp, mpz_get_ui (sp)); ;
! 962: break;}
! 963: case 22:
! 964: #line 223 "calc.y"
! 965: { mpz_neg (sp, sp); ;
! 966: break;}
! 967: case 23:
! 968: #line 225 "calc.y"
! 969: { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) < 0); ;
! 970: break;}
! 971: case 24:
! 972: #line 226 "calc.y"
! 973: { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) <= 0); ;
! 974: break;}
! 975: case 25:
! 976: #line 227 "calc.y"
! 977: { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) == 0); ;
! 978: break;}
! 979: case 26:
! 980: #line 228 "calc.y"
! 981: { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) != 0); ;
! 982: break;}
! 983: case 27:
! 984: #line 229 "calc.y"
! 985: { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) >= 0); ;
! 986: break;}
! 987: case 28:
! 988: #line 230 "calc.y"
! 989: { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) > 0); ;
! 990: break;}
! 991: case 29:
! 992: #line 232 "calc.y"
! 993: { sp--; mpz_set_ui (sp, mpz_sgn (sp) && mpz_sgn (sp+1)); ;
! 994: break;}
! 995: case 30:
! 996: #line 233 "calc.y"
! 997: { sp--; mpz_set_ui (sp, mpz_sgn (sp) || mpz_sgn (sp+1)); ;
! 998: break;}
! 999: case 31:
! 1000: #line 235 "calc.y"
! 1001: { mpz_abs (sp, sp); ;
! 1002: break;}
! 1003: case 32:
! 1004: #line 236 "calc.y"
! 1005: { sp--; CHECK_UI ("binomial", sp+1);
! 1006: mpz_bin_ui (sp, sp, mpz_get_ui (sp+1)); ;
! 1007: break;}
! 1008: case 33:
! 1009: #line 238 "calc.y"
! 1010: { CHECK_UI ("fibonacci", sp);
! 1011: mpz_fib_ui (sp, mpz_get_ui (sp)); ;
! 1012: break;}
! 1013: case 36:
! 1014: #line 242 "calc.y"
! 1015: { mpz_nextprime (sp, sp); ;
! 1016: break;}
! 1017: case 37:
! 1018: #line 243 "calc.y"
! 1019: { sp -= 2; mpz_powm (sp, sp, sp+1, sp+2); ;
! 1020: break;}
! 1021: case 38:
! 1022: #line 244 "calc.y"
! 1023: { sp--; CHECK_UI ("nth-root", sp+1);
! 1024: mpz_root (sp, sp, mpz_get_ui (sp+1)); ;
! 1025: break;}
! 1026: case 39:
! 1027: #line 246 "calc.y"
! 1028: { mpz_sqrt (sp, sp); ;
! 1029: break;}
! 1030: case 40:
! 1031: #line 248 "calc.y"
! 1032: {
! 1033: sp++;
! 1034: CHECK_OVERFLOW ();
! 1035: CHECK_VARIABLE (yyvsp[0].var);
! 1036: mpz_set (sp, variable[yyvsp[0].var]);
! 1037: ;
! 1038: break;}
! 1039: case 41:
! 1040: #line 254 "calc.y"
! 1041: {
! 1042: sp++;
! 1043: CHECK_OVERFLOW ();
! 1044: if (mpz_set_str (sp, yyvsp[0].str, ibase) != 0)
! 1045: {
! 1046: fprintf (stderr, "Invalid number: %s\n", yyvsp[0].str);
! 1047: YYERROR;
! 1048: }
! 1049: ;
! 1050: break;}
! 1051: case 43:
! 1052: #line 266 "calc.y"
! 1053: { sp--; mpz_gcd (sp, sp, sp+1); ;
! 1054: break;}
! 1055: case 45:
! 1056: #line 270 "calc.y"
! 1057: { sp--; mpz_lcm (sp, sp, sp+1); ;
! 1058: break;}
! 1059: }
! 1060: /* the action file gets copied in in place of this dollarsign */
! 1061: #line 543 "/usr/share/misc/bison.simple"
! 1062:
! 1063: yyvsp -= yylen;
! 1064: yyssp -= yylen;
! 1065: #ifdef YYLSP_NEEDED
! 1066: yylsp -= yylen;
! 1067: #endif
! 1068:
! 1069: #if YYDEBUG != 0
! 1070: if (yydebug)
! 1071: {
! 1072: short *ssp1 = yyss - 1;
! 1073: fprintf (stderr, "state stack now");
! 1074: while (ssp1 != yyssp)
! 1075: fprintf (stderr, " %d", *++ssp1);
! 1076: fprintf (stderr, "\n");
! 1077: }
! 1078: #endif
! 1079:
! 1080: *++yyvsp = yyval;
! 1081:
! 1082: #ifdef YYLSP_NEEDED
! 1083: yylsp++;
! 1084: if (yylen == 0)
! 1085: {
! 1086: yylsp->first_line = yylloc.first_line;
! 1087: yylsp->first_column = yylloc.first_column;
! 1088: yylsp->last_line = (yylsp-1)->last_line;
! 1089: yylsp->last_column = (yylsp-1)->last_column;
! 1090: yylsp->text = 0;
! 1091: }
! 1092: else
! 1093: {
! 1094: yylsp->last_line = (yylsp+yylen-1)->last_line;
! 1095: yylsp->last_column = (yylsp+yylen-1)->last_column;
! 1096: }
! 1097: #endif
! 1098:
! 1099: /* Now "shift" the result of the reduction.
! 1100: Determine what state that goes to,
! 1101: based on the state we popped back to
! 1102: and the rule number reduced by. */
! 1103:
! 1104: yyn = yyr1[yyn];
! 1105:
! 1106: yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
! 1107: if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
! 1108: yystate = yytable[yystate];
! 1109: else
! 1110: yystate = yydefgoto[yyn - YYNTBASE];
! 1111:
! 1112: goto yynewstate;
! 1113:
! 1114: yyerrlab: /* here on detecting error */
! 1115:
! 1116: if (! yyerrstatus)
! 1117: /* If not already recovering from an error, report this error. */
! 1118: {
! 1119: ++yynerrs;
! 1120:
! 1121: #ifdef YYERROR_VERBOSE
! 1122: yyn = yypact[yystate];
! 1123:
! 1124: if (yyn > YYFLAG && yyn < YYLAST)
! 1125: {
! 1126: int size = 0;
! 1127: char *msg;
! 1128: int x, count;
! 1129:
! 1130: count = 0;
! 1131: /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
! 1132: for (x = (yyn < 0 ? -yyn : 0);
! 1133: x < (sizeof(yytname) / sizeof(char *)); x++)
! 1134: if (yycheck[x + yyn] == x)
! 1135: size += strlen(yytname[x]) + 15, count++;
! 1136: msg = (char *) malloc(size + 15);
! 1137: if (msg != 0)
! 1138: {
! 1139: strcpy(msg, "parse error");
! 1140:
! 1141: if (count < 5)
! 1142: {
! 1143: count = 0;
! 1144: for (x = (yyn < 0 ? -yyn : 0);
! 1145: x < (sizeof(yytname) / sizeof(char *)); x++)
! 1146: if (yycheck[x + yyn] == x)
! 1147: {
! 1148: strcat(msg, count == 0 ? ", expecting `" : " or `");
! 1149: strcat(msg, yytname[x]);
! 1150: strcat(msg, "'");
! 1151: count++;
! 1152: }
! 1153: }
! 1154: yyerror(msg);
! 1155: free(msg);
! 1156: }
! 1157: else
! 1158: yyerror ("parse error; also virtual memory exceeded");
! 1159: }
! 1160: else
! 1161: #endif /* YYERROR_VERBOSE */
! 1162: yyerror("parse error");
! 1163: }
! 1164:
! 1165: goto yyerrlab1;
! 1166: yyerrlab1: /* here on error raised explicitly by an action */
! 1167:
! 1168: if (yyerrstatus == 3)
! 1169: {
! 1170: /* if just tried and failed to reuse lookahead token after an error, discard it. */
! 1171:
! 1172: /* return failure if at end of input */
! 1173: if (yychar == YYEOF)
! 1174: YYABORT;
! 1175:
! 1176: #if YYDEBUG != 0
! 1177: if (yydebug)
! 1178: fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
! 1179: #endif
! 1180:
! 1181: yychar = YYEMPTY;
! 1182: }
! 1183:
! 1184: /* Else will try to reuse lookahead token
! 1185: after shifting the error token. */
! 1186:
! 1187: yyerrstatus = 3; /* Each real token shifted decrements this */
! 1188:
! 1189: goto yyerrhandle;
! 1190:
! 1191: yyerrdefault: /* current state does not do anything special for the error token. */
! 1192:
! 1193: #if 0
! 1194: /* This is wrong; only states that explicitly want error tokens
! 1195: should shift them. */
! 1196: yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
! 1197: if (yyn) goto yydefault;
! 1198: #endif
! 1199:
! 1200: yyerrpop: /* pop the current state because it cannot handle the error token */
! 1201:
! 1202: if (yyssp == yyss) YYABORT;
! 1203: yyvsp--;
! 1204: yystate = *--yyssp;
! 1205: #ifdef YYLSP_NEEDED
! 1206: yylsp--;
! 1207: #endif
! 1208:
! 1209: #if YYDEBUG != 0
! 1210: if (yydebug)
! 1211: {
! 1212: short *ssp1 = yyss - 1;
! 1213: fprintf (stderr, "Error: state stack now");
! 1214: while (ssp1 != yyssp)
! 1215: fprintf (stderr, " %d", *++ssp1);
! 1216: fprintf (stderr, "\n");
! 1217: }
! 1218: #endif
! 1219:
! 1220: yyerrhandle:
! 1221:
! 1222: yyn = yypact[yystate];
! 1223: if (yyn == YYFLAG)
! 1224: goto yyerrdefault;
! 1225:
! 1226: yyn += YYTERROR;
! 1227: if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
! 1228: goto yyerrdefault;
! 1229:
! 1230: yyn = yytable[yyn];
! 1231: if (yyn < 0)
! 1232: {
! 1233: if (yyn == YYFLAG)
! 1234: goto yyerrpop;
! 1235: yyn = -yyn;
! 1236: goto yyreduce;
! 1237: }
! 1238: else if (yyn == 0)
! 1239: goto yyerrpop;
! 1240:
! 1241: if (yyn == YYFINAL)
! 1242: YYACCEPT;
! 1243:
! 1244: #if YYDEBUG != 0
! 1245: if (yydebug)
! 1246: fprintf(stderr, "Shifting error token, ");
! 1247: #endif
! 1248:
! 1249: *++yyvsp = yylval;
! 1250: #ifdef YYLSP_NEEDED
! 1251: *++yylsp = yylloc;
! 1252: #endif
! 1253:
! 1254: yystate = yyn;
! 1255: goto yynewstate;
! 1256:
! 1257: yyacceptlab:
! 1258: /* YYACCEPT comes here. */
! 1259: if (yyfree_stacks)
! 1260: {
! 1261: free (yyss);
! 1262: free (yyvs);
! 1263: #ifdef YYLSP_NEEDED
! 1264: free (yyls);
! 1265: #endif
! 1266: }
! 1267: return 0;
! 1268:
! 1269: yyabortlab:
! 1270: /* YYABORT comes here. */
! 1271: if (yyfree_stacks)
! 1272: {
! 1273: free (yyss);
! 1274: free (yyvs);
! 1275: #ifdef YYLSP_NEEDED
! 1276: free (yyls);
! 1277: #endif
! 1278: }
! 1279: return 1;
! 1280: }
! 1281: #line 272 "calc.y"
! 1282:
! 1283:
! 1284: yyerror (char *s)
! 1285: {
! 1286: fprintf (stderr, "%s\n", s);
! 1287: }
! 1288:
! 1289: int
! 1290: main (void)
! 1291: {
! 1292: int i;
! 1293:
! 1294: for (i = 0; i < numberof (variable); i++)
! 1295: mpz_init (variable[i]);
! 1296:
! 1297: for (i = 0; i < numberof (stack); i++)
! 1298: mpz_init (stack[i]);
! 1299:
! 1300: return yyparse ();
! 1301: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>