#include #ifndef lint #if 0 static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; #else __IDSTRING(yyrcsid, "$NetBSD: skeleton.c,v 1.14 1997/10/20 03:41:16 lukem Exp $"); #endif #endif #include #define YYBYACC 1 #define YYMAJOR 1 #define YYMINOR 9 #define YYLEX yylex() #define YYEMPTY -1 #define yyclearin (yychar=(YYEMPTY)) #define yyerrok (yyerrflag=0) #define YYRECOVERING (yyerrflag!=0) #define YYPREFIX "yy" #line 2 "moo.y" /* $Id: moo.y,v 1.16 2007/01/11 19:03:07 ray Exp $ */ /* * Written by Raymond Lai . * Public domain. */ #include #include #include #include #include #include #include #include #include #include #include #include "extern.h" extern FILE *yyin; static int bflag; static int nb_operands; static int print_hex; static int print_dec; static int print_oct; static int print_bin; static int print_signed; static int print_unsigned; static int used_bin; static int used_dec; static int used_hex; static int used_oct; static void divbyzero(void); static void printnum(int64_t); __dead2 static void usage(void); void yyerror(char *); int yylex(void); int yyparse(void); #line 46 "moo.y" typedef union { int64_t number; } YYSTYPE; #line 67 "y.tab.c" #define INTEGER 257 #define EQ 258 #define NEQ 259 #define LS 260 #define RS 261 #define LOR 262 #define LAND 263 #define BOR 264 #define XOR 265 #define BAND 266 #define LT 267 #define GT 268 #define LE 269 #define GE 270 #define PLUS 271 #define MINUS 272 #define TIMES 273 #define DIV 274 #define MOD 275 #define NOT 276 #define INVERSE 277 #define NL 278 #define LPAREN 279 #define RPAREN 280 #define YYERRCODE 256 short yylhs[] = { -1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; short yylen[] = { 2, 3, 0, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 3, }; short yydefred[] = { 0, 0, 0, 3, 4, 0, 0, 0, 0, 0, 25, 24, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 9, }; short yydgoto[] = { 2, 9, }; short yysindex[] = { -256, -228, 7, 0, 0, 7, 7, 7, 7, 29, 0, 0, 0, -229, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 166, 166, -265, -265, 78, 96, 114, 132, 150, 171, 171, 171, 171, -226, -226, 0, 0, 0, }; short yyrindex[] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -21, -12, -160, -137, -166, 43, 55, 51, 46, -114, -91, -68, -45, -206, -183, 0, 0, 0, }; short yygindex[] = { 0, -3, }; #define YYTABLESIZE 446 short yytable[] = { 1, 2, 10, 11, 12, 13, 27, 28, 29, 30, 31, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 29, 30, 31, 3, 33, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 5, 0, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0, 0, 6, 14, 6, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 0, 14, 0, 14, 0, 0, 0, 21, 0, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 0, 0, 0, 0, 0, 0, 0, 22, 0, 22, 17, 17, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 18, 18, 0, 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, 0, 0, 0, 0, 0, 0, 18, 0, 18, 19, 19, 0, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 0, 0, 0, 0, 0, 0, 0, 19, 0, 19, 20, 20, 0, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 15, 15, 0, 0, 15, 15, 15, 15, 15, 16, 16, 0, 0, 16, 16, 16, 16, 16, 0, 0, 15, 2, 15, 0, 0, 0, 0, 4, 0, 16, 0, 16, 0, 0, 0, 0, 2, 0, 0, 0, 2, 2, 5, 2, 0, 0, 6, 7, 0, 8, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 13, 13, 32, 10, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 0, 13, 0, 13, 10, 0, 10, 0, 0, 11, 0, 11, 0, 12, 0, 12, 14, 15, 16, 17, 0, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 14, 15, 16, 17, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 14, 15, 16, 17, 0, 0, 0, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 14, 15, 16, 17, 0, 0, 0, 0, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 14, 15, 16, 17, 0, 0, 0, 0, 0, 23, 24, 25, 26, 27, 28, 29, 30, 31, 16, 17, 0, 0, 0, 16, 17, 23, 24, 25, 26, 27, 28, 29, 30, 31, 27, 28, 29, 30, 31, }; short yycheck[] = { 256, 0, 5, 6, 7, 8, 271, 272, 273, 274, 275, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 273, 274, 275, 278, 280, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, -1, -1, -1, -1, 278, -1, 280, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, -1, -1, -1, -1, 278, 262, 280, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, -1, 278, -1, 280, -1, -1, -1, 278, -1, 280, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, -1, -1, -1, -1, -1, -1, -1, 278, -1, 280, 258, 259, -1, -1, 262, 263, 264, 265, 266, 267, 268, 269, 270, -1, -1, -1, -1, -1, -1, -1, 278, -1, 280, 258, 259, -1, -1, 262, 263, 264, 265, 266, 267, 268, 269, 270, -1, -1, -1, -1, -1, -1, -1, 278, -1, 280, 258, 259, -1, -1, 262, 263, 264, 265, 266, 267, 268, 269, 270, -1, -1, -1, -1, -1, -1, -1, 278, -1, 280, 258, 259, -1, -1, 262, 263, 264, 265, 266, 267, 268, 269, 270, -1, -1, -1, -1, -1, -1, -1, 278, -1, 280, -1, 258, 259, -1, -1, 262, 263, 264, 265, 266, 258, 259, -1, -1, 262, 263, 264, 265, 266, -1, -1, 278, 257, 280, -1, -1, -1, -1, 257, -1, 278, -1, 280, -1, -1, -1, -1, 272, -1, -1, -1, 276, 277, 272, 279, -1, -1, 276, 277, -1, 279, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 262, 263, 278, 262, 263, 264, 265, 266, 262, 263, 264, 265, 262, 263, 264, -1, 278, -1, 280, 278, -1, 280, -1, -1, 278, -1, 280, -1, 278, -1, 280, 258, 259, 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 258, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 258, 259, 260, 261, -1, -1, -1, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 258, 259, 260, 261, -1, -1, -1, -1, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 258, 259, 260, 261, -1, -1, -1, -1, -1, 267, 268, 269, 270, 271, 272, 273, 274, 275, 260, 261, -1, -1, -1, 260, 261, 267, 268, 269, 270, 271, 272, 273, 274, 275, 271, 272, 273, 274, 275, }; #define YYFINAL 2 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 280 #if YYDEBUG char *yyname[] = { "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"INTEGER","EQ","NEQ","LS","RS", "LOR","LAND","BOR","XOR","BAND","LT","GT","LE","GE","PLUS","MINUS","TIMES", "DIV","MOD","NOT","INVERSE","NL","LPAREN","RPAREN", }; char *yyrule[] = { "$accept : program", "program : program expr NL", "program :", "program : error NL", "expr : INTEGER", "expr : expr PLUS expr", "expr : expr MINUS expr", "expr : expr TIMES expr", "expr : expr DIV expr", "expr : expr MOD expr", "expr : expr BAND expr", "expr : expr XOR expr", "expr : expr BOR expr", "expr : expr LAND expr", "expr : expr LOR expr", "expr : expr EQ expr", "expr : expr NEQ expr", "expr : expr LT expr", "expr : expr GT expr", "expr : expr LE expr", "expr : expr GE expr", "expr : expr LS expr", "expr : expr RS expr", "expr : INVERSE expr", "expr : NOT expr", "expr : MINUS expr", "expr : LPAREN expr RPAREN", }; #endif #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #define YYINITSTACKSIZE 200 int yydebug; int yynerrs; int yyerrflag; int yychar; short *yyssp; YYSTYPE *yyvsp; YYSTYPE yyval; YYSTYPE yylval; short *yyss; short *yysslim; YYSTYPE *yyvs; int yystacksize; #line 114 "moo.y" void divbyzero(void) { warnx("divide by zero"); /* Don't print anything. */ used_hex = used_dec = used_oct = used_bin = 0; } void yyerror(char *s) { fprintf(stderr, "%s\n", s); } /* * Print numbers in bases that were input or in bases that were specified. */ static void printnum(int64_t num) { int printed; /* Print tabs between numbers as necessary. */ #define printspace() do { \ if (printed++) \ printf("\t"); \ } while (0) printed = 0; /* If no bases were specified, print the ones that were input. */ if (!bflag) { /* If only one term was entered, print it in all bases */ if (nb_operands == 1) print_hex = print_dec = print_oct = print_bin = 1; else { /* Reset print flags. */ print_hex = print_dec = print_oct = print_bin = 0; if (used_hex) print_hex = 1; if (used_dec) print_dec = 1; if (used_oct) print_oct = 1; if (used_bin) print_bin = 1; /* Reset used flags. */ used_hex = used_dec = used_oct = used_bin = 0; } } if (print_hex) { printspace(); printf("0x%" PRIx64, num); } if (print_dec) { if (print_unsigned) { printspace(); printf("%" PRIu64, num); } if (print_signed) { printspace(); printf("%" PRId64, num); } } if (print_oct) { printspace(); printf("0%" PRIo64, num); } if (print_bin) { int bit, printed_bit; printed_bit = 0; printspace(); printf("0b"); for (bit = sizeof(num) * 8; bit > 0; --bit) if (num & (1LL << (bit - 1))) { printf("1"); ++printed_bit; /* Print leading zeroes if any bits were printed. */ } else { if (printed_bit) { printf("0"); ++printed_bit; } } /* * If no bits were printed out (num == 0) then print a 0 * so we don't just print ``0b''. */ if (!printed_bit) printf("0"); } printf("\n"); return; TOOLONG: errx(1, "format string too long"); } /* * Read binary number string and convert to int. */ int64_t getbin(const char *nptr) { int64_t num; const char *p; ++nb_operands; used_bin = 1; if (strncmp("0b", nptr, 2) != 0) errx(2, "not a binary number: %s", nptr); /* XXX - buffer overflow */ for (p = nptr + 2, num = 0; *p != '\0'; ++p) { num <<= 1; switch (*p) { case '1': ++num; /* FALLTHROUGH */ case '0': break; default: errx(2, "not a binary number: %s", nptr); } } return (num); } /* * Accept hex, decimal, and octal integers. */ int64_t getnum(const char *nptr) { int64_t num; char *ep; int64_t lval; errno = 0; lval = strtoll(nptr, &ep, 0); if (*nptr == '\0' || *ep != '\0') errx(1, "invalid number: %s", nptr); if ((errno == ERANGE && (lval == LLONG_MAX || lval == LLONG_MIN)) || (lval > INT64_MAX || lval < INT64_MIN)) errx(1, "out of range: %s", nptr); num = lval; ++nb_operands; if (strncmp(nptr, "0x", 2) == 0) used_hex = 1; else if (nptr[0] == '0' && nptr[1] != '\0') used_oct = 1; else used_dec = 1; return (num); } int main(int argc, char *argv[]) { int ch; while ((ch = getopt(argc, argv, "0123456789b:suw:")) != -1) switch (ch) { /* * If we get a numerical flag it may be a negative * number, so pop the argument back in and let the * argument parser handle it. */ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': --optind; goto DONEPARSING; case 'b': bflag = 1; if (optarg[0] == 'a') { print_hex = print_dec = print_oct = print_bin = 1; break; } /* Only allow certain bases to be printed. */ switch (getnum(optarg)) { case 16: print_hex = 1; break; case 10: print_dec = 1; break; case 8: print_oct = 1; break; case 2: print_bin = 1; break; default: errx(1, "invalid base: %s", optarg); } break; case 's': print_signed = 1; break; case 'u': print_unsigned = 1; break; default: usage(); } DONEPARSING: argc -= optind; argv += optind; /* Print signed decimal numbers by default. */ if (!(print_signed || print_unsigned)) print_signed = 1; /* If arguments were given calculate arguments instead of stdin. */ if (argc > 0) { FILE *sfp; int fd, i; char *sfn; if (asprintf(&sfn, "%s/moo.XXXXXXXXXX", getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp") == -1) err(1, "asprintf"); if ((fd = mkstemp(sfn)) == -1 || (sfp = fdopen(fd, "w+")) == NULL) { warn("%s", sfn); if (fd != -1) unlink(sfn); exit(1); } if (unlink(sfn) == -1) warn("%s", sfn); /* Copy arguments to temp file. */ for (i = 0; i < argc; ++i) if (fputs(argv[i], sfp)) err(1, "error writing %s", sfn); /* Parser needs a newline at end. */ if (fputs("\n", sfp)) err(1, "error writing %s", sfn); free(sfn); rewind(sfp); yyin = sfp; } yyparse(); return (0); } void usage(void) { extern char *__progname; fprintf(stderr, "usage: %s [-su] [-b base] expr\n", __progname); exit(1); } #line 569 "y.tab.c" /* allocate initial stack or double stack size, up to YYMAXDEPTH */ int yyparse __P((void)); static int yygrowstack __P((void)); static int yygrowstack() { int newsize, i; short *newss; YYSTYPE *newvs; if ((newsize = yystacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return -1; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = yyssp - yyss; if ((newss = (short *)realloc(yyss, newsize * sizeof *newss)) == NULL) return -1; yyss = newss; yyssp = newss + i; if ((newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs)) == NULL) return -1; yyvs = newvs; yyvsp = newvs + i; yystacksize = newsize; yysslim = yyss + newsize - 1; return 0; } #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab int yyparse() { int yym, yyn, yystate; #if YYDEBUG char *yys; if ((yys = getenv("YYDEBUG")) != NULL) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } #endif yynerrs = 0; yyerrflag = 0; yychar = (-1); if (yyss == NULL && yygrowstack()) goto yyoverflow; yyssp = yyss; yyvsp = yyvs; *yyssp = yystate = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { if ((yychar = yylex()) < 0) yychar = 0; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif } if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif if (yyssp >= yysslim && yygrowstack()) { goto yyoverflow; } *++yyssp = yystate = yytable[yyn]; *++yyvsp = yylval; yychar = (-1); if (yyerrflag > 0) --yyerrflag; goto yyloop; } if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag) goto yyinrecovery; goto yynewerror; yynewerror: yyerror("syntax error"); goto yyerrlab; yyerrlab: ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, error recovery shifting\ to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); #endif if (yyssp >= yysslim && yygrowstack()) { goto yyoverflow; } *++yyssp = yystate = yytable[yyn]; *++yyvsp = yylval; goto yyloop; } else { #if YYDEBUG if (yydebug) printf("%sdebug: error recovery discarding state %d\n", YYPREFIX, *yyssp); #endif if (yyssp <= yyss) goto yyabort; --yyssp; --yyvsp; } } } else { if (yychar == 0) goto yyabort; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif yychar = (-1); goto yyloop; } yyreduce: #if YYDEBUG if (yydebug) printf("%sdebug: state %d, reducing by rule %d (%s)\n", YYPREFIX, yystate, yyn, yyrule[yyn]); #endif yym = yylen[yyn]; yyval = yyvsp[1-yym]; switch (yyn) { case 1: #line 67 "moo.y" { if (used_hex || used_dec || used_oct || used_bin) printnum(yyvsp[-1].number); nb_operands = used_hex = used_dec = used_oct = used_bin = 0; } break; case 3: #line 75 "moo.y" { yyerrok; } break; case 4: #line 79 "moo.y" { yyval.number = yyvsp[0].number; } break; case 5: #line 80 "moo.y" { yyval.number = yyvsp[-2].number + yyvsp[0].number; } break; case 6: #line 81 "moo.y" { yyval.number = yyvsp[-2].number - yyvsp[0].number; } break; case 7: #line 82 "moo.y" { yyval.number = yyvsp[-2].number * yyvsp[0].number; } break; case 8: #line 83 "moo.y" { if (yyvsp[0].number == 0) divbyzero(); else yyval.number = yyvsp[-2].number / yyvsp[0].number; } break; case 9: #line 89 "moo.y" { if (yyvsp[0].number == 0) divbyzero(); else yyval.number = yyvsp[-2].number % yyvsp[0].number; } break; case 10: #line 95 "moo.y" { yyval.number = yyvsp[-2].number & yyvsp[0].number; } break; case 11: #line 96 "moo.y" { yyval.number = yyvsp[-2].number ^ yyvsp[0].number; } break; case 12: #line 97 "moo.y" { yyval.number = yyvsp[-2].number | yyvsp[0].number; } break; case 13: #line 98 "moo.y" { yyval.number = yyvsp[-2].number && yyvsp[0].number; } break; case 14: #line 99 "moo.y" { yyval.number = yyvsp[-2].number || yyvsp[0].number; } break; case 15: #line 100 "moo.y" { yyval.number = yyvsp[-2].number == yyvsp[0].number; } break; case 16: #line 101 "moo.y" { yyval.number = yyvsp[-2].number != yyvsp[0].number; } break; case 17: #line 102 "moo.y" { yyval.number = yyvsp[-2].number < yyvsp[0].number; } break; case 18: #line 103 "moo.y" { yyval.number = yyvsp[-2].number > yyvsp[0].number; } break; case 19: #line 104 "moo.y" { yyval.number = yyvsp[-2].number <= yyvsp[0].number; } break; case 20: #line 105 "moo.y" { yyval.number = yyvsp[-2].number >= yyvsp[0].number; } break; case 21: #line 106 "moo.y" { yyval.number = yyvsp[-2].number << yyvsp[0].number; } break; case 22: #line 107 "moo.y" { yyval.number = yyvsp[-2].number >> yyvsp[0].number; } break; case 23: #line 108 "moo.y" { yyval.number = ~yyvsp[0].number; } break; case 24: #line 109 "moo.y" { yyval.number = !yyvsp[0].number; } break; case 25: #line 110 "moo.y" { yyval.number = -yyvsp[0].number; } break; case 26: #line 111 "moo.y" { yyval.number = yyvsp[-1].number; } break; #line 851 "y.tab.c" } yyssp -= yym; yystate = *yyssp; yyvsp -= yym; yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state 0 to\ state %d\n", YYPREFIX, YYFINAL); #endif yystate = YYFINAL; *++yyssp = YYFINAL; *++yyvsp = yyval; if (yychar < 0) { if ((yychar = yylex()) < 0) yychar = 0; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, YYFINAL, yychar, yys); } #endif } if (yychar == 0) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state %d \ to state %d\n", YYPREFIX, *yyssp, yystate); #endif if (yyssp >= yysslim && yygrowstack()) { goto yyoverflow; } *++yyssp = yystate; *++yyvsp = yyval; goto yyloop; yyoverflow: yyerror("yacc stack overflow"); yyabort: return (1); yyaccept: return (0); }