|
|
1.1 root 1: 1.1.1.7 ! root 2: /* A Bison parser, made from ../gcc-1.37/cexp.y */ 1.1 root 3: 4: #define INT 258 5: #define CHAR 259 6: #define NAME 260 7: #define ERROR 261 8: #define OR 262 9: #define AND 263 10: #define EQUAL 264 11: #define NOTEQUAL 265 12: #define LEQ 266 13: #define GEQ 267 14: #define LSH 268 15: #define RSH 269 16: #define UNARY 270 17: 1.1.1.7 ! root 18: #line 26 "../gcc-1.37/cexp.y" 1.1 root 19: 1.1.1.2 root 20: #include "config.h" 1.1 root 21: #include <setjmp.h> 22: /* #define YYDEBUG 1 */ 23: 1.1.1.3 root 24: int yylex (); 25: void yyerror (); 1.1 root 26: int expression_value; 27: 28: static jmp_buf parse_return_error; 29: 30: /* some external tables of character types */ 31: extern unsigned char is_idstart[], is_idchar[]; 32: 1.1.1.7 ! root 33: #ifndef CHAR_TYPE_SIZE ! 34: #define CHAR_TYPE_SIZE BITS_PER_UNIT ! 35: #endif 1.1 root 36: 1.1.1.7 ! root 37: #line 45 "../gcc-1.37/cexp.y" 1.1 root 38: typedef union { 1.1.1.7 ! root 39: struct constant {long value; int unsignedp;} integer; 1.1 root 40: int voidval; 41: char *sval; 42: } YYSTYPE; 43: 44: #ifndef YYLTYPE 45: typedef 46: struct yyltype 1.1.1.7 ! root 47: { 1.1 root 48: int timestamp; 49: int first_line; 50: int first_column; 51: int last_line; 52: int last_column; 53: char *text; 54: } 1.1.1.7 ! root 55: yyltype; 1.1 root 56: 57: #define YYLTYPE yyltype 58: #endif 59: 60: #include <stdio.h> 61: 1.1.1.2 root 62: #ifndef __STDC__ 63: #define const 64: #endif 65: 1.1 root 66: 67: 1.1.1.7 ! root 68: #define YYFINAL 61 1.1 root 69: #define YYFLAG -32768 70: #define YYNTBASE 33 71: 1.1.1.2 root 72: #define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 36) 1.1 root 73: 1.1.1.2 root 74: static const char yytranslate[] = { 0, 1.1 root 75: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 76: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 77: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 78: 2, 2, 29, 2, 2, 2, 27, 14, 2, 31, 79: 32, 25, 23, 9, 24, 2, 26, 2, 2, 2, 80: 2, 2, 2, 2, 2, 2, 2, 8, 2, 17, 81: 2, 18, 7, 2, 2, 2, 2, 2, 2, 2, 82: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 83: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 84: 2, 2, 2, 13, 2, 2, 2, 2, 2, 2, 85: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 86: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 87: 2, 2, 2, 12, 2, 30, 2, 2, 2, 2, 88: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 89: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 90: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 91: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 92: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 93: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 94: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 95: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 96: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 97: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 98: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 99: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 100: 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 101: 6, 10, 11, 15, 16, 19, 20, 21, 22, 28 102: }; 103: 1.1.1.2 root 104: static const short yyrline[] = { 0, 1.1.1.7 ! root 105: 74, 79, 80, 85, 88, 91, 93, 96, 101, 107, ! 106: 118, 129, 132, 135, 141, 147, 150, 153, 159, 165, ! 107: 171, 177, 180, 183, 186, 189, 192, 195, 197, 199 1.1 root 108: }; 109: 1.1.1.2 root 110: static const char * const yytname[] = { 0, 1.1 root 111: "error","$illegal.","INT","CHAR","NAME","ERROR","'?'","':'","','","OR", 112: "AND","'|'","'^'","'&'","EQUAL","NOTEQUAL","'<'","'>'","LEQ","GEQ", 113: "LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'","'~'", 114: "'('","')'","start" 115: }; 116: 1.1.1.2 root 117: static const short yyr1[] = { 0, 1.1 root 118: 33, 34, 34, 35, 35, 35, 35, 35, 35, 35, 119: 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 1.1.1.7 ! root 120: 35, 35, 35, 35, 35, 35, 35, 35, 35, 35 1.1 root 121: }; 122: 1.1.1.2 root 123: static const short yyr2[] = { 0, 1.1.1.7 ! root 124: 1, 1, 3, 2, 2, 2, 2, 3, 3, 3, 1.1 root 125: 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1.1.1.7 ! root 126: 3, 3, 3, 3, 3, 3, 5, 1, 1, 1 1.1 root 127: }; 128: 1.1.1.2 root 129: static const short yydefact[] = { 0, 1.1.1.7 ! root 130: 28, 29, 30, 0, 0, 0, 0, 0, 1, 2, ! 131: 6, 4, 5, 7, 0, 0, 0, 0, 0, 0, 1.1 root 132: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.1.1.7 ! root 133: 0, 0, 0, 0, 0, 8, 3, 0, 26, 25, ! 134: 24, 23, 22, 16, 17, 20, 21, 18, 19, 14, ! 135: 15, 12, 13, 9, 10, 11, 0, 27, 0, 0, ! 136: 0 1.1 root 137: }; 138: 1.1.1.7 ! root 139: static const short yydefgoto[] = { 59, ! 140: 9, 10 1.1 root 141: }; 142: 1.1.1.7 ! root 143: static const short yypact[] = { 31, ! 144: -32768,-32768,-32768, 31, 31, 31, 31, 31, 1, 77, ! 145: -32768,-32768,-32768,-32768, 0, 31, 31, 31, 31, 31, ! 146: 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, ! 147: 31, 31, 31, 31, 31,-32768, 77, 56, 94, 25, ! 148: 109, 123, 136, 147, 147, 154, 154, 154, 154, -19, ! 149: -19, 32, 32,-32768,-32768,-32768, 31, 77, 11, 33, ! 150: -32768 1.1 root 151: }; 152: 1.1.1.2 root 153: static const short yypgoto[] = {-32768, 1.1.1.7 ! root 154: 48, -4 1.1 root 155: }; 156: 157: 1.1.1.7 ! root 158: #define YYLAST 181 1.1 root 159: 160: 1.1.1.7 ! root 161: static const short yytable[] = { 11, ! 162: 12, 13, 14, 31, 32, 33, 34, 35, 16, 16, ! 163: 60, 37, 38, 39, 40, 41, 42, 43, 44, 45, ! 164: 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, ! 165: 56, 36, 61, 1, 2, 3, 20, 21, 22, 23, 1.1 root 166: 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 1.1.1.7 ! root 167: 34, 35, 58, 4, 5, 15, 33, 34, 35, 6, ! 168: 7, 8, 17, 57, 0, 18, 19, 20, 21, 22, 1.1 root 169: 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 1.1.1.7 ! root 170: 33, 34, 35, 17, 0, 0, 18, 19, 20, 21, 1.1 root 171: 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 1.1.1.7 ! root 172: 32, 33, 34, 35, 19, 20, 21, 22, 23, 24, ! 173: 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, ! 174: 35, 21, 22, 23, 24, 25, 26, 27, 28, 29, ! 175: 30, 31, 32, 33, 34, 35, 22, 23, 24, 25, ! 176: 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, ! 177: 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, ! 178: 33, 34, 35, 25, 26, 27, 28, 29, 30, 31, ! 179: 32, 33, 34, 35, 29, 30, 31, 32, 33, 34, ! 180: 35 1.1 root 181: }; 182: 1.1.1.2 root 183: static const short yycheck[] = { 4, 1.1.1.7 ! root 184: 5, 6, 7, 23, 24, 25, 26, 27, 9, 9, ! 185: 0, 16, 17, 18, 19, 20, 21, 22, 23, 24, ! 186: 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, ! 187: 35, 32, 0, 3, 4, 5, 12, 13, 14, 15, ! 188: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, ! 189: 26, 27, 57, 23, 24, 8, 25, 26, 27, 29, ! 190: 30, 31, 7, 8, -1, 10, 11, 12, 13, 14, 1.1 root 191: 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 1.1.1.7 ! root 192: 25, 26, 27, 7, -1, -1, 10, 11, 12, 13, ! 193: 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, ! 194: 24, 25, 26, 27, 11, 12, 13, 14, 15, 16, 1.1 root 195: 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 1.1.1.7 ! root 196: 27, 13, 14, 15, 16, 17, 18, 19, 20, 21, ! 197: 22, 23, 24, 25, 26, 27, 14, 15, 16, 17, 1.1 root 198: 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 1.1.1.7 ! root 199: 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, ! 200: 25, 26, 27, 17, 18, 19, 20, 21, 22, 23, ! 201: 24, 25, 26, 27, 21, 22, 23, 24, 25, 26, ! 202: 27 1.1 root 203: }; 204: #define YYPURE 1 205: 1.1.1.6 root 206: /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ 207: #line 3 "bison.simple" 1.1 root 208: 209: /* Skeleton output parser for bison, 1.1.1.7 ! root 210: Copyright (C) 1984 Bob Corbett and Richard Stallman 1.1 root 211: 1.1.1.7 ! root 212: This program is free software; you can redistribute it and/or modify ! 213: it under the terms of the GNU General Public License as published by ! 214: the Free Software Foundation; either version 1, or (at your option) ! 215: any later version. ! 216: ! 217: This program is distributed in the hope that it will be useful, ! 218: but WITHOUT ANY WARRANTY; without even the implied warranty of ! 219: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! 220: GNU General Public License for more details. ! 221: ! 222: You should have received a copy of the GNU General Public License ! 223: along with this program; if not, write to the Free Software ! 224: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 1.1.1.2 root 225: 1.1 root 226: 1.1.1.6 root 227: #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) 228: #include <alloca.h> 229: #endif 230: 1.1 root 231: /* This is the parser code that is written into each bison parser 232: when the %semantic_parser declaration is not specified in the grammar. 233: It was written by Richard Stallman by simplifying the hairy parser 234: used when %semantic_parser is specified. */ 235: 236: /* Note: there must be only one dollar sign in this file. 237: It is replaced by the list of actions, each action 238: as one case of the switch. */ 239: 240: #define yyerrok (yyerrstatus = 0) 241: #define yyclearin (yychar = YYEMPTY) 242: #define YYEMPTY -2 243: #define YYEOF 0 244: #define YYFAIL goto yyerrlab; 1.1.1.6 root 245: #define YYACCEPT return(0) 246: #define YYABORT return(1) 247: #define YYERROR goto yyerrlab 1.1 root 248: 249: #define YYTERROR 1 1.1.1.7 ! root 250: #define YYERRCODE 256 1.1 root 251: 252: #ifndef YYIMPURE 253: #define YYLEX yylex() 254: #endif 255: 256: #ifndef YYPURE 257: #define YYLEX yylex(&yylval, &yylloc) 258: #endif 259: 260: /* If nonreentrant, generate the variables here */ 261: 262: #ifndef YYIMPURE 263: 264: int yychar; /* the lookahead symbol */ 265: YYSTYPE yylval; /* the semantic value of the */ 266: /* lookahead symbol */ 267: 268: YYLTYPE yylloc; /* location data for the lookahead */ 269: /* symbol */ 270: 1.1.1.6 root 271: int yynerrs; /* number of parse errors so far */ 1.1 root 272: #endif /* YYIMPURE */ 273: 1.1.1.6 root 274: #if YYDEBUG != 0 275: int yydebug; /* nonzero means print parse trace */ 276: /* Since this is uninitialized, it does not stop multiple parsers 277: from coexisting. */ 278: #endif 1.1 root 279: 280: /* YYMAXDEPTH indicates the initial size of the parser's stacks */ 281: 282: #ifndef YYMAXDEPTH 283: #define YYMAXDEPTH 200 284: #endif 285: 286: /* YYMAXLIMIT is the maximum size the stacks can grow to 287: (effective only if the built-in stack extension method is used). */ 288: 289: #ifndef YYMAXLIMIT 290: #define YYMAXLIMIT 10000 291: #endif 292: 293: 1.1.1.7 ! root 294: #line 90 "bison.simple" 1.1 root 295: int 296: yyparse() 297: { 298: register int yystate; 299: register int yyn; 300: register short *yyssp; 301: register YYSTYPE *yyvsp; 302: YYLTYPE *yylsp; 303: int yyerrstatus; /* number of tokens to shift before error messages enabled */ 304: int yychar1; /* lookahead token as an internal (translated) token number */ 305: 306: short yyssa[YYMAXDEPTH]; /* the state stack */ 307: YYSTYPE yyvsa[YYMAXDEPTH]; /* the semantic value stack */ 308: YYLTYPE yylsa[YYMAXDEPTH]; /* the location stack */ 309: 310: short *yyss = yyssa; /* refer to the stacks thru separate pointers */ 311: YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ 312: YYLTYPE *yyls = yylsa; 313: 314: int yymaxdepth = YYMAXDEPTH; 315: 316: #ifndef YYPURE 317: int yychar; 318: YYSTYPE yylval; 319: YYLTYPE yylloc; 1.1.1.6 root 320: int yynerrs; 1.1.1.2 root 321: #endif 1.1 root 322: 323: YYSTYPE yyval; /* the variable used to return */ 324: /* semantic values from the action */ 325: /* routines */ 326: 327: int yylen; 328: 1.1.1.6 root 329: #if YYDEBUG != 0 1.1 root 330: if (yydebug) 331: fprintf(stderr, "Starting parse\n"); 1.1.1.2 root 332: #endif 1.1 root 333: 334: yystate = 0; 335: yyerrstatus = 0; 1.1.1.6 root 336: yynerrs = 0; 1.1 root 337: yychar = YYEMPTY; /* Cause a token to be read. */ 338: 339: /* Initialize stack pointers. 340: Waste one element of value and location stack 341: so that they stay on the same level as the state stack. */ 342: 343: yyssp = yyss - 1; 344: yyvsp = yyvs; 345: yylsp = yyls; 346: 347: /* Push a new state, which is found in yystate . */ 348: /* In all cases, when you get here, the value and location stacks 349: have just been pushed. so pushing a state here evens the stacks. */ 350: yynewstate: 351: 352: *++yyssp = yystate; 353: 354: if (yyssp >= yyss + yymaxdepth - 1) 355: { 356: /* Give user a chance to reallocate the stack */ 357: /* Use copies of these so that the &'s don't force the real ones into memory. */ 358: YYSTYPE *yyvs1 = yyvs; 359: YYLTYPE *yyls1 = yyls; 360: short *yyss1 = yyss; 361: 362: /* Get the current used size of the three stacks, in elements. */ 363: int size = yyssp - yyss + 1; 364: 365: #ifdef yyoverflow 366: /* Each stack pointer address is followed by the size of 367: the data in use in that stack, in bytes. */ 368: yyoverflow("parser stack overflow", 369: &yyss1, size * sizeof (*yyssp), 370: &yyvs1, size * sizeof (*yyvsp), 371: &yyls1, size * sizeof (*yylsp), 372: &yymaxdepth); 373: 374: yyss = yyss1; yyvs = yyvs1; yyls = yyls1; 375: #else /* no yyoverflow */ 376: /* Extend the stack our own way. */ 377: if (yymaxdepth >= YYMAXLIMIT) 378: yyerror("parser stack overflow"); 379: yymaxdepth *= 2; 380: if (yymaxdepth > YYMAXLIMIT) 381: yymaxdepth = YYMAXLIMIT; 382: yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp)); 383: bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp)); 384: yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp)); 385: bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp)); 1.1.1.3 root 386: #ifdef YYLSP_NEEDED 1.1.1.2 root 387: yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp)); 388: bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp)); 389: #endif 1.1 root 390: #endif /* no yyoverflow */ 391: 392: yyssp = yyss + size - 1; 393: yyvsp = yyvs + size - 1; 1.1.1.3 root 394: #ifdef YYLSP_NEEDED 1.1.1.2 root 395: yylsp = yyls + size - 1; 396: #endif 1.1 root 397: 1.1.1.6 root 398: #if YYDEBUG != 0 1.1 root 399: if (yydebug) 400: fprintf(stderr, "Stack size increased to %d\n", yymaxdepth); 1.1.1.2 root 401: #endif 1.1 root 402: 403: if (yyssp >= yyss + yymaxdepth - 1) 1.1.1.6 root 404: YYABORT; 1.1 root 405: } 406: 1.1.1.6 root 407: #if YYDEBUG != 0 1.1 root 408: if (yydebug) 409: fprintf(stderr, "Entering state %d\n", yystate); 1.1.1.2 root 410: #endif 1.1 root 411: 412: /* Do appropriate processing given the current state. */ 413: /* Read a lookahead token if we need one and don't already have one. */ 414: yyresume: 415: 416: /* First try to decide what to do without reference to lookahead token. */ 417: 418: yyn = yypact[yystate]; 419: if (yyn == YYFLAG) 420: goto yydefault; 421: 422: /* Not known => get a lookahead token if don't already have one. */ 423: 424: /* yychar is either YYEMPTY or YYEOF 425: or a valid token in external form. */ 426: 427: if (yychar == YYEMPTY) 428: { 1.1.1.6 root 429: #if YYDEBUG != 0 1.1.1.2 root 430: if (yydebug) 431: fprintf(stderr, "Reading a token: "); 432: #endif 1.1 root 433: yychar = YYLEX; 434: } 435: 436: /* Convert token to internal form (in yychar1) for indexing tables with */ 437: 438: if (yychar <= 0) /* This means end of input. */ 439: { 440: yychar1 = 0; 441: yychar = YYEOF; /* Don't call YYLEX any more */ 442: 1.1.1.6 root 443: #if YYDEBUG != 0 1.1 root 444: if (yydebug) 445: fprintf(stderr, "Now at end of input.\n"); 1.1.1.2 root 446: #endif 1.1 root 447: } 448: else 449: { 450: yychar1 = YYTRANSLATE(yychar); 451: 1.1.1.6 root 452: #if YYDEBUG != 0 1.1 root 453: if (yydebug) 1.1.1.2 root 454: fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]); 455: #endif 1.1 root 456: } 457: 458: yyn += yychar1; 459: if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) 460: goto yydefault; 461: 462: yyn = yytable[yyn]; 463: 464: /* yyn is what to do for this token type in this state. 465: Negative => reduce, -yyn is rule number. 466: Positive => shift, yyn is new state. 467: New state is final state => don't bother to shift, 468: just return success. 469: 0, or most negative number => error. */ 470: 471: if (yyn < 0) 472: { 473: if (yyn == YYFLAG) 474: goto yyerrlab; 475: yyn = -yyn; 476: goto yyreduce; 477: } 478: else if (yyn == 0) 479: goto yyerrlab; 480: 481: if (yyn == YYFINAL) 482: YYACCEPT; 483: 484: /* Shift the lookahead token. */ 485: 1.1.1.6 root 486: #if YYDEBUG != 0 1.1 root 487: if (yydebug) 488: fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); 1.1.1.2 root 489: #endif 1.1 root 490: 491: /* Discard the token being shifted unless it is eof. */ 492: if (yychar != YYEOF) 493: yychar = YYEMPTY; 494: 495: *++yyvsp = yylval; 1.1.1.3 root 496: #ifdef YYLSP_NEEDED 1.1 root 497: *++yylsp = yylloc; 1.1.1.2 root 498: #endif 1.1 root 499: 500: /* count tokens shifted since error; after three, turn off error status. */ 501: if (yyerrstatus) yyerrstatus--; 502: 503: yystate = yyn; 504: goto yynewstate; 505: 506: /* Do the default action for the current state. */ 507: yydefault: 508: 509: yyn = yydefact[yystate]; 510: if (yyn == 0) 511: goto yyerrlab; 512: 513: /* Do a reduction. yyn is the number of a rule to reduce with. */ 514: yyreduce: 515: yylen = yyr2[yyn]; 516: yyval = yyvsp[1-yylen]; /* implement default value of the action */ 517: 1.1.1.6 root 518: #if YYDEBUG != 0 1.1 root 519: if (yydebug) 520: { 521: if (yylen == 1) 522: fprintf (stderr, "Reducing 1 value via line %d, ", 523: yyrline[yyn]); 524: else 525: fprintf (stderr, "Reducing %d values via line %d, ", 526: yylen, yyrline[yyn]); 527: } 1.1.1.2 root 528: #endif 1.1 root 529: 530: 531: switch (yyn) { 532: 533: case 1: 1.1.1.7 ! root 534: #line 75 "../gcc-1.37/cexp.y" ! 535: { expression_value = yyvsp[0].integer.value; ; 1.1 root 536: break;} 537: case 3: 1.1.1.7 ! root 538: #line 81 "../gcc-1.37/cexp.y" ! 539: { yyval.integer = yyvsp[0].integer; ; 1.1 root 540: break;} 541: case 4: 1.1.1.7 ! root 542: #line 86 "../gcc-1.37/cexp.y" ! 543: { yyval.integer.value = - yyvsp[0].integer.value; ! 544: yyval.integer.unsignedp = yyvsp[0].integer.unsignedp; ; 1.1 root 545: break;} 546: case 5: 1.1.1.7 ! root 547: #line 89 "../gcc-1.37/cexp.y" ! 548: { yyval.integer.value = ! yyvsp[0].integer.value; ! 549: yyval.integer.unsignedp = 0; ; 1.1 root 550: break;} 551: case 6: 1.1.1.7 ! root 552: #line 92 "../gcc-1.37/cexp.y" ! 553: { yyval.integer = yyvsp[0].integer; ; 1.1 root 554: break;} 555: case 7: 1.1.1.7 ! root 556: #line 94 "../gcc-1.37/cexp.y" ! 557: { yyval.integer.value = ~ yyvsp[0].integer.value; ! 558: yyval.integer.unsignedp = yyvsp[0].integer.unsignedp; ; 1.1 root 559: break;} 560: case 8: 1.1.1.7 ! root 561: #line 97 "../gcc-1.37/cexp.y" ! 562: { yyval.integer = yyvsp[-1].integer; ; 1.1 root 563: break;} 564: case 9: 1.1.1.7 ! root 565: #line 102 "../gcc-1.37/cexp.y" ! 566: { yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ! 567: if (yyval.integer.unsignedp) ! 568: yyval.integer.value = (unsigned) yyvsp[-2].integer.value * yyvsp[0].integer.value; ! 569: else ! 570: yyval.integer.value = yyvsp[-2].integer.value * yyvsp[0].integer.value; ; 1.1 root 571: break;} 572: case 10: 1.1.1.7 ! root 573: #line 108 "../gcc-1.37/cexp.y" ! 574: { if (yyvsp[0].integer.value == 0) 1.1.1.6 root 575: { 576: error ("division by zero in #if"); 1.1.1.7 ! root 577: yyvsp[0].integer.value = 1; 1.1.1.6 root 578: } 1.1.1.7 ! root 579: yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ! 580: if (yyval.integer.unsignedp) ! 581: yyval.integer.value = (unsigned) yyvsp[-2].integer.value / yyvsp[0].integer.value; ! 582: else ! 583: yyval.integer.value = yyvsp[-2].integer.value / yyvsp[0].integer.value; ; 1.1 root 584: break;} 585: case 11: 1.1.1.7 ! root 586: #line 119 "../gcc-1.37/cexp.y" ! 587: { if (yyvsp[0].integer.value == 0) ! 588: { ! 589: error ("division by zero in #if"); ! 590: yyvsp[0].integer.value = 1; ! 591: } ! 592: yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ! 593: if (yyval.integer.unsignedp) ! 594: yyval.integer.value = (unsigned) yyvsp[-2].integer.value % yyvsp[0].integer.value; ! 595: else ! 596: yyval.integer.value = yyvsp[-2].integer.value % yyvsp[0].integer.value; ; 1.1 root 597: break;} 598: case 12: 1.1.1.7 ! root 599: #line 130 "../gcc-1.37/cexp.y" ! 600: { yyval.integer.value = yyvsp[-2].integer.value + yyvsp[0].integer.value; ! 601: yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ; 1.1 root 602: break;} 603: case 13: 1.1.1.7 ! root 604: #line 133 "../gcc-1.37/cexp.y" ! 605: { yyval.integer.value = yyvsp[-2].integer.value - yyvsp[0].integer.value; ! 606: yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ; 1.1 root 607: break;} 608: case 14: 1.1.1.7 ! root 609: #line 136 "../gcc-1.37/cexp.y" ! 610: { yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp; ! 611: if (yyval.integer.unsignedp) ! 612: yyval.integer.value = (unsigned) yyvsp[-2].integer.value << yyvsp[0].integer.value; ! 613: else ! 614: yyval.integer.value = yyvsp[-2].integer.value << yyvsp[0].integer.value; ; 1.1 root 615: break;} 616: case 15: 1.1.1.7 ! root 617: #line 142 "../gcc-1.37/cexp.y" ! 618: { yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp; ! 619: if (yyval.integer.unsignedp) ! 620: yyval.integer.value = (unsigned) yyvsp[-2].integer.value >> yyvsp[0].integer.value; ! 621: else ! 622: yyval.integer.value = yyvsp[-2].integer.value >> yyvsp[0].integer.value; ; 1.1 root 623: break;} 624: case 16: 1.1.1.7 ! root 625: #line 148 "../gcc-1.37/cexp.y" ! 626: { yyval.integer.value = (yyvsp[-2].integer.value == yyvsp[0].integer.value); ! 627: yyval.integer.unsignedp = 0; ; 1.1 root 628: break;} 629: case 17: 1.1.1.7 ! root 630: #line 151 "../gcc-1.37/cexp.y" ! 631: { yyval.integer.value = (yyvsp[-2].integer.value != yyvsp[0].integer.value); ! 632: yyval.integer.unsignedp = 0; ; 1.1 root 633: break;} 634: case 18: 1.1.1.7 ! root 635: #line 154 "../gcc-1.37/cexp.y" ! 636: { yyval.integer.unsignedp = 0; ! 637: if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp) ! 638: yyval.integer.value = (unsigned) yyvsp[-2].integer.value <= yyvsp[0].integer.value; ! 639: else ! 640: yyval.integer.value = yyvsp[-2].integer.value <= yyvsp[0].integer.value; ; 1.1 root 641: break;} 642: case 19: 1.1.1.7 ! root 643: #line 160 "../gcc-1.37/cexp.y" ! 644: { yyval.integer.unsignedp = 0; ! 645: if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp) ! 646: yyval.integer.value = (unsigned) yyvsp[-2].integer.value >= yyvsp[0].integer.value; ! 647: else ! 648: yyval.integer.value = yyvsp[-2].integer.value >= yyvsp[0].integer.value; ; 1.1 root 649: break;} 650: case 20: 1.1.1.7 ! root 651: #line 166 "../gcc-1.37/cexp.y" ! 652: { yyval.integer.unsignedp = 0; ! 653: if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp) ! 654: yyval.integer.value = (unsigned) yyvsp[-2].integer.value < yyvsp[0].integer.value; ! 655: else ! 656: yyval.integer.value = yyvsp[-2].integer.value < yyvsp[0].integer.value; ; 1.1 root 657: break;} 658: case 21: 1.1.1.7 ! root 659: #line 172 "../gcc-1.37/cexp.y" ! 660: { yyval.integer.unsignedp = 0; ! 661: if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp) ! 662: yyval.integer.value = (unsigned) yyvsp[-2].integer.value > yyvsp[0].integer.value; ! 663: else ! 664: yyval.integer.value = yyvsp[-2].integer.value > yyvsp[0].integer.value; ; 1.1 root 665: break;} 666: case 22: 1.1.1.7 ! root 667: #line 178 "../gcc-1.37/cexp.y" ! 668: { yyval.integer.value = yyvsp[-2].integer.value & yyvsp[0].integer.value; ! 669: yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ; 1.1 root 670: break;} 671: case 23: 1.1.1.7 ! root 672: #line 181 "../gcc-1.37/cexp.y" ! 673: { yyval.integer.value = yyvsp[-2].integer.value ^ yyvsp[0].integer.value; ! 674: yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ; 1.1 root 675: break;} 676: case 24: 1.1.1.7 ! root 677: #line 184 "../gcc-1.37/cexp.y" ! 678: { yyval.integer.value = yyvsp[-2].integer.value | yyvsp[0].integer.value; ! 679: yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ; 1.1 root 680: break;} 681: case 25: 1.1.1.7 ! root 682: #line 187 "../gcc-1.37/cexp.y" ! 683: { yyval.integer.value = (yyvsp[-2].integer.value && yyvsp[0].integer.value); ! 684: yyval.integer.unsignedp = 0; ; 1.1 root 685: break;} 686: case 26: 1.1.1.7 ! root 687: #line 190 "../gcc-1.37/cexp.y" ! 688: { yyval.integer.value = (yyvsp[-2].integer.value || yyvsp[0].integer.value); ! 689: yyval.integer.unsignedp = 0; ; 1.1 root 690: break;} 691: case 27: 1.1.1.7 ! root 692: #line 193 "../gcc-1.37/cexp.y" ! 693: { yyval.integer.value = yyvsp[-4].integer.value ? yyvsp[-2].integer.value : yyvsp[0].integer.value; ! 694: yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ; 1.1 root 695: break;} 696: case 28: 1.1.1.7 ! root 697: #line 196 "../gcc-1.37/cexp.y" ! 698: { yyval.integer = yylval.integer; ; 1.1 root 699: break;} 700: case 29: 1.1.1.7 ! root 701: #line 198 "../gcc-1.37/cexp.y" ! 702: { yyval.integer = yylval.integer; ; ! 703: break;} ! 704: case 30: ! 705: #line 200 "../gcc-1.37/cexp.y" ! 706: { yyval.integer.value = 0; ! 707: yyval.integer.unsignedp = 0; ; 1.1 root 708: break;} 709: } 710: /* the action file gets copied in in place of this dollarsign */ 1.1.1.7 ! root 711: #line 327 "bison.simple" 1.1 root 712: 713: yyvsp -= yylen; 714: yyssp -= yylen; 1.1.1.3 root 715: #ifdef YYLSP_NEEDED 1.1.1.2 root 716: yylsp -= yylen; 717: #endif 1.1 root 718: 1.1.1.6 root 719: #if YYDEBUG != 0 1.1 root 720: if (yydebug) 721: { 722: short *ssp1 = yyss - 1; 1.1.1.6 root 723: fprintf (stderr, "state stack now"); 1.1 root 724: while (ssp1 != yyssp) 725: fprintf (stderr, " %d", *++ssp1); 726: fprintf (stderr, "\n"); 727: } 1.1.1.2 root 728: #endif 1.1 root 729: 730: *++yyvsp = yyval; 731: 1.1.1.3 root 732: #ifdef YYLSP_NEEDED 1.1 root 733: yylsp++; 734: if (yylen == 0) 735: { 736: yylsp->first_line = yylloc.first_line; 737: yylsp->first_column = yylloc.first_column; 738: yylsp->last_line = (yylsp-1)->last_line; 739: yylsp->last_column = (yylsp-1)->last_column; 740: yylsp->text = 0; 741: } 742: else 743: { 744: yylsp->last_line = (yylsp+yylen-1)->last_line; 745: yylsp->last_column = (yylsp+yylen-1)->last_column; 746: } 1.1.1.2 root 747: #endif 1.1 root 748: 749: /* Now "shift" the result of the reduction. 750: Determine what state that goes to, 751: based on the state we popped back to 752: and the rule number reduced by. */ 753: 754: yyn = yyr1[yyn]; 755: 756: yystate = yypgoto[yyn - YYNTBASE] + *yyssp; 757: if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) 758: yystate = yytable[yystate]; 759: else 760: yystate = yydefgoto[yyn - YYNTBASE]; 761: 762: goto yynewstate; 763: 764: yyerrlab: /* here on detecting error */ 765: 766: if (! yyerrstatus) 767: /* If not already recovering from an error, report this error. */ 768: { 1.1.1.6 root 769: ++yynerrs; 1.1 root 770: yyerror("parse error"); 771: } 772: 773: if (yyerrstatus == 3) 774: { 775: /* if just tried and failed to reuse lookahead token after an error, discard it. */ 776: 777: /* return failure if at end of input */ 778: if (yychar == YYEOF) 1.1.1.6 root 779: YYABORT; 1.1 root 780: 1.1.1.6 root 781: #if YYDEBUG != 0 1.1 root 782: if (yydebug) 783: fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); 1.1.1.2 root 784: #endif 1.1 root 785: 786: yychar = YYEMPTY; 787: } 788: 789: /* Else will try to reuse lookahead token 790: after shifting the error token. */ 791: 792: yyerrstatus = 3; /* Each real token shifted decrements this */ 793: 794: goto yyerrhandle; 795: 796: yyerrdefault: /* current state does not do anything special for the error token. */ 797: 798: #if 0 799: /* This is wrong; only states that explicitly want error tokens 800: should shift them. */ 801: yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ 802: if (yyn) goto yydefault; 803: #endif 804: 805: yyerrpop: /* pop the current state because it cannot handle the error token */ 806: 1.1.1.6 root 807: if (yyssp == yyss) YYABORT; 1.1 root 808: yyvsp--; 809: yystate = *--yyssp; 1.1.1.3 root 810: #ifdef YYLSP_NEEDED 1.1.1.2 root 811: yylsp--; 812: #endif 1.1 root 813: 1.1.1.6 root 814: #if YYDEBUG != 0 1.1 root 815: if (yydebug) 816: { 817: short *ssp1 = yyss - 1; 1.1.1.6 root 818: fprintf (stderr, "Error: state stack now"); 1.1 root 819: while (ssp1 != yyssp) 820: fprintf (stderr, " %d", *++ssp1); 821: fprintf (stderr, "\n"); 822: } 1.1.1.2 root 823: #endif 1.1 root 824: 825: yyerrhandle: 826: 827: yyn = yypact[yystate]; 828: if (yyn == YYFLAG) 829: goto yyerrdefault; 830: 831: yyn += YYTERROR; 832: if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) 833: goto yyerrdefault; 834: 835: yyn = yytable[yyn]; 836: if (yyn < 0) 837: { 838: if (yyn == YYFLAG) 839: goto yyerrpop; 840: yyn = -yyn; 841: goto yyreduce; 842: } 843: else if (yyn == 0) 844: goto yyerrpop; 845: 846: if (yyn == YYFINAL) 847: YYACCEPT; 848: 1.1.1.6 root 849: #if YYDEBUG != 0 1.1 root 850: if (yydebug) 851: fprintf(stderr, "Shifting error token, "); 1.1.1.2 root 852: #endif 1.1 root 853: 854: *++yyvsp = yylval; 1.1.1.3 root 855: #ifdef YYLSP_NEEDED 1.1 root 856: *++yylsp = yylloc; 1.1.1.2 root 857: #endif 1.1 root 858: 859: yystate = yyn; 860: goto yynewstate; 861: } 1.1.1.7 ! root 862: #line 203 "../gcc-1.37/cexp.y" 1.1 root 863: 864: 865: /* During parsing of a C expression, the pointer to the next character 866: is in this variable. */ 867: 868: static char *lexptr; 869: 870: /* Take care of parsing a number (anything that starts with a digit). 871: Set yylval and return the token type; update lexptr. 872: LEN is the number of characters in it. */ 873: 874: /* maybe needs to actually deal with floating point numbers */ 875: 1.1.1.3 root 876: int 1.1 root 877: parse_number (olen) 878: int olen; 879: { 880: register char *p = lexptr; 881: register long n = 0; 882: register int c; 883: register int base = 10; 1.1.1.7 ! root 884: register int len = olen; 1.1 root 885: 886: for (c = 0; c < len; c++) 887: if (p[c] == '.') { 888: /* It's a float since it contains a point. */ 889: yyerror ("floating point numbers not allowed in #if expressions"); 890: return ERROR; 891: } 1.1.1.7 ! root 892: ! 893: yylval.integer.unsignedp = 0; ! 894: 1.1 root 895: if (len >= 3 && (!strncmp (p, "0x", 2) || !strncmp (p, "0X", 2))) { 896: p += 2; 897: base = 16; 898: len -= 2; 899: } 900: else if (*p == '0') 901: base = 8; 1.1.1.7 ! root 902: ! 903: while (len > 0) { 1.1 root 904: c = *p++; 1.1.1.7 ! root 905: len--; ! 906: if (c >= 'A' && c <= 'Z') c += 'a' - 'A'; ! 907: ! 908: if (c >= '0' && c <= '9') { ! 909: n *= base; 1.1 root 910: n += c - '0'; 1.1.1.7 ! root 911: } else if (base == 16 && c >= 'a' && c <= 'f') { ! 912: n *= base; ! 913: n += c - 'a' + 10; ! 914: } else { ! 915: /* `l' means long, and `u' means unsigned. */ ! 916: while (1) { ! 917: if (c == 'l' || c == 'L') ! 918: ; ! 919: else if (c == 'u' || c == 'U') ! 920: yylval.integer.unsignedp = 1; ! 921: else ! 922: break; ! 923: ! 924: if (len == 0) ! 925: break; ! 926: c = *p++; ! 927: len--; 1.1 root 928: } 1.1.1.7 ! root 929: /* Don't look for any more digits after the suffixes. */ ! 930: break; 1.1 root 931: } 932: } 933: 1.1.1.7 ! root 934: if (len != 0) { ! 935: yyerror ("Invalid number in #if expression"); ! 936: return ERROR; ! 937: } ! 938: ! 939: /* If too big to be signed, consider it unsigned. */ ! 940: if (n < 0) ! 941: yylval.integer.unsignedp = 1; ! 942: 1.1 root 943: lexptr = p; 1.1.1.7 ! root 944: yylval.integer.value = n; 1.1 root 945: return INT; 946: } 947: 948: struct token { 949: char *operator; 950: int token; 951: }; 952: 1.1.1.7 ! root 953: #ifndef NULL 1.1 root 954: #define NULL 0 1.1.1.7 ! root 955: #endif 1.1 root 956: 957: static struct token tokentab2[] = { 958: {"&&", AND}, 959: {"||", OR}, 960: {"<<", LSH}, 961: {">>", RSH}, 962: {"==", EQUAL}, 963: {"!=", NOTEQUAL}, 964: {"<=", LEQ}, 965: {">=", GEQ}, 966: {NULL, ERROR} 967: }; 968: 969: /* Read one token, getting characters through lexptr. */ 970: 1.1.1.3 root 971: int 1.1 root 972: yylex () 973: { 974: register int c; 975: register int namelen; 976: register char *tokstart; 977: register struct token *toktab; 978: 979: retry: 980: 981: tokstart = lexptr; 982: c = *tokstart; 983: /* See if it is a special token of length 2. */ 984: for (toktab = tokentab2; toktab->operator != NULL; toktab++) 985: if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) { 986: lexptr += 2; 987: return toktab->token; 988: } 989: 990: switch (c) { 991: case 0: 992: return 0; 993: 994: case ' ': 995: case '\t': 996: case '\n': 997: lexptr++; 998: goto retry; 999: 1000: case '\'': 1001: lexptr++; 1002: c = *lexptr++; 1003: if (c == '\\') 1004: c = parse_escape (&lexptr); 1.1.1.7 ! root 1005: ! 1006: /* Sign-extend the constant if chars are signed on target machine. */ ! 1007: { ! 1008: if (lookup ("__CHAR_UNSIGNED__", sizeof ("__CHAR_UNSIGNED__")-1, -1) ! 1009: || ((c >> (CHAR_TYPE_SIZE - 1)) & 1) == 0) ! 1010: yylval.integer.value = c & ((1 << CHAR_TYPE_SIZE) - 1); ! 1011: else ! 1012: yylval.integer.value = c | ~((1 << CHAR_TYPE_SIZE) - 1); ! 1013: } ! 1014: ! 1015: yylval.integer.unsignedp = 0; 1.1 root 1016: c = *lexptr++; 1017: if (c != '\'') { 1018: yyerror ("Invalid character constant in #if"); 1019: return ERROR; 1020: } 1021: 1022: return CHAR; 1023: 1024: /* some of these chars are invalid in constant expressions; 1025: maybe do something about them later */ 1026: case '/': 1027: case '+': 1028: case '-': 1029: case '*': 1030: case '%': 1031: case '|': 1032: case '&': 1033: case '^': 1034: case '~': 1035: case '!': 1036: case '@': 1037: case '<': 1038: case '>': 1039: case '(': 1040: case ')': 1041: case '[': 1042: case ']': 1043: case '.': 1044: case '?': 1045: case ':': 1046: case '=': 1047: case '{': 1048: case '}': 1049: case ',': 1050: lexptr++; 1051: return c; 1052: 1053: case '"': 1054: yyerror ("double quoted strings not allowed in #if expressions"); 1055: return ERROR; 1056: } 1057: if (c >= '0' && c <= '9') { 1058: /* It's a number */ 1059: for (namelen = 0; 1060: c = tokstart[namelen], is_idchar[c] || c == '.'; 1061: namelen++) 1062: ; 1063: return parse_number (namelen); 1064: } 1065: 1066: if (!is_idstart[c]) { 1067: yyerror ("Invalid token in expression"); 1068: return ERROR; 1069: } 1070: 1071: /* It is a name. See how long it is. */ 1072: 1073: for (namelen = 0; is_idchar[tokstart[namelen]]; namelen++) 1074: ; 1075: 1076: lexptr += namelen; 1077: return NAME; 1078: } 1079: 1080: 1081: /* Parse a C escape sequence. STRING_PTR points to a variable 1082: containing a pointer to the string to parse. That pointer 1083: is updated past the characters we use. The value of the 1084: escape sequence is returned. 1085: 1086: A negative value means the sequence \ newline was seen, 1087: which is supposed to be equivalent to nothing at all. 1088: 1089: If \ is followed by a null character, we return a negative 1090: value and leave the string pointer pointing at the null character. 1091: 1092: If \ is followed by 000, we return 0 and leave the string pointer 1093: after the zeros. A value of 0 does not mean end of string. */ 1094: 1.1.1.3 root 1095: int 1.1 root 1096: parse_escape (string_ptr) 1097: char **string_ptr; 1098: { 1099: register int c = *(*string_ptr)++; 1100: switch (c) 1101: { 1102: case 'a': 1.1.1.7 ! root 1103: return TARGET_BELL; 1.1 root 1104: case 'b': 1.1.1.7 ! root 1105: return TARGET_BS; 1.1 root 1106: case 'e': 1107: return 033; 1108: case 'f': 1.1.1.7 ! root 1109: return TARGET_FF; 1.1 root 1110: case 'n': 1.1.1.7 ! root 1111: return TARGET_NEWLINE; 1.1 root 1112: case 'r': 1.1.1.7 ! root 1113: return TARGET_CR; 1.1 root 1114: case 't': 1.1.1.7 ! root 1115: return TARGET_TAB; 1.1 root 1116: case 'v': 1.1.1.7 ! root 1117: return TARGET_VT; 1.1 root 1118: case '\n': 1119: return -2; 1120: case 0: 1121: (*string_ptr)--; 1122: return 0; 1123: case '^': 1124: c = *(*string_ptr)++; 1125: if (c == '\\') 1126: c = parse_escape (string_ptr); 1127: if (c == '?') 1128: return 0177; 1129: return (c & 0200) | (c & 037); 1130: 1131: case '0': 1132: case '1': 1133: case '2': 1134: case '3': 1135: case '4': 1136: case '5': 1137: case '6': 1138: case '7': 1139: { 1140: register int i = c - '0'; 1141: register int count = 0; 1142: while (++count < 3) 1143: { 1.1.1.7 ! root 1144: c = *(*string_ptr)++; ! 1145: if (c >= '0' && c <= '7') ! 1146: i = (i << 3) + c - '0'; ! 1147: else 1.1 root 1148: { 1.1.1.7 ! root 1149: (*string_ptr)--; ! 1150: break; 1.1 root 1151: } 1.1.1.7 ! root 1152: } ! 1153: if ((i & ~((1 << CHAR_TYPE_SIZE) - 1)) != 0) ! 1154: { ! 1155: i &= (1 << CHAR_TYPE_SIZE) - 1; ! 1156: warning ("octal character constant does not fit in a byte"); ! 1157: } ! 1158: return i; ! 1159: } ! 1160: case 'x': ! 1161: { ! 1162: register int i = 0; ! 1163: register int count = 0; ! 1164: for (;;) ! 1165: { ! 1166: c = *(*string_ptr)++; ! 1167: if (c >= '0' && c <= '9') ! 1168: i = (i << 4) + c - '0'; ! 1169: else if (c >= 'a' && c <= 'f') ! 1170: i = (i << 4) + c - 'a' + 10; ! 1171: else if (c >= 'A' && c <= 'F') ! 1172: i = (i << 4) + c - 'A' + 10; 1.1 root 1173: else 1174: { 1175: (*string_ptr)--; 1176: break; 1177: } 1178: } 1.1.1.7 ! root 1179: if ((i & ~((1 << BITS_PER_UNIT) - 1)) != 0) ! 1180: { ! 1181: i &= (1 << BITS_PER_UNIT) - 1; ! 1182: warning ("hex character constant does not fit in a byte"); ! 1183: } 1.1 root 1184: return i; 1185: } 1186: default: 1187: return c; 1188: } 1189: } 1190: 1.1.1.3 root 1191: void 1.1 root 1192: yyerror (s) 1193: char *s; 1194: { 1195: error (s); 1196: longjmp (parse_return_error, 1); 1197: } 1198: 1199: /* This page contains the entry point to this file. */ 1200: 1201: /* Parse STRING as an expression, and complain if this fails 1202: to use up all of the contents of STRING. */ 1203: /* We do not support C comments. They should be removed before 1204: this function is called. */ 1205: 1206: int 1207: parse_c_expression (string) 1208: char *string; 1209: { 1210: lexptr = string; 1211: 1212: if (lexptr == 0 || *lexptr == 0) { 1213: error ("empty #if expression"); 1214: return 0; /* don't include the #if group */ 1215: } 1216: 1217: /* if there is some sort of scanning error, just return 0 and assume 1218: the parsing routine has printed an error message somewhere. 1219: there is surely a better thing to do than this. */ 1.1.1.7 ! root 1220: if (setjmp (parse_return_error)) 1.1 root 1221: return 0; 1222: 1223: if (yyparse ()) 1224: return 0; /* actually this is never reached 1225: the way things stand. */ 1226: if (*lexptr) 1227: error ("Junk after end of expression."); 1228: 1.1.1.7 ! root 1229: return expression_value; /* set by yyparse () */ 1.1 root 1230: } 1231: 1232: #ifdef TEST_EXP_READER 1233: /* main program, for testing purposes. */ 1.1.1.7 ! root 1234: main () 1.1 root 1235: { 1.1.1.7 ! root 1236: int n, c; 1.1 root 1237: char buf[1024]; 1238: extern int yydebug; 1239: /* 1240: yydebug = 1; 1241: */ 1242: initialize_random_junk (); 1243: 1244: for (;;) { 1.1.1.7 ! root 1245: printf ("enter expression: "); 1.1 root 1246: n = 0; 1.1.1.7 ! root 1247: while ((buf[n] = getchar ()) != '\n' && buf[n] != EOF) 1.1 root 1248: n++; 1.1.1.7 ! root 1249: if (buf[n] == EOF) ! 1250: break; 1.1 root 1251: buf[n] = '\0'; 1.1.1.7 ! root 1252: printf ("parser returned %d\n", parse_c_expression (buf)); 1.1 root 1253: } 1254: } 1255: 1256: /* table to tell if char can be part of a C identifier. */ 1.1.1.7 ! root 1257: unsigned char is_idchar[256]; 1.1 root 1258: /* table to tell if char can be first char of a c identifier. */ 1.1.1.7 ! root 1259: unsigned char is_idstart[256]; ! 1260: /* table to tell if c is horizontal space. isspace () thinks that 1.1 root 1261: newline is space; this is not a good idea for this program. */ 1262: char is_hor_space[256]; 1263: 1264: /* 1265: * initialize random junk in the hash table and maybe other places 1266: */ 1.1.1.7 ! root 1267: initialize_random_junk () 1.1 root 1268: { 1269: register int i; 1270: 1271: /* 1272: * Set up is_idchar and is_idstart tables. These should be 1.1.1.7 ! root 1273: * faster than saying (is_alpha (c) || c == '_'), etc. 1.1 root 1274: * Must do set up these things before calling any routines tthat 1275: * refer to them. 1276: */ 1277: for (i = 'a'; i <= 'z'; i++) { 1278: ++is_idchar[i - 'a' + 'A']; 1279: ++is_idchar[i]; 1280: ++is_idstart[i - 'a' + 'A']; 1281: ++is_idstart[i]; 1282: } 1283: for (i = '0'; i <= '9'; i++) 1284: ++is_idchar[i]; 1285: ++is_idchar['_']; 1286: ++is_idstart['_']; 1.1.1.7 ! root 1287: #if DOLLARS_IN_IDENTIFIERS 1.1 root 1288: ++is_idchar['$']; 1289: ++is_idstart['$']; 1290: #endif 1291: 1292: /* horizontal space table */ 1293: ++is_hor_space[' ']; 1294: ++is_hor_space['\t']; 1295: } 1296: 1297: error (msg) 1298: { 1.1.1.7 ! root 1299: printf ("error: %s\n", msg); ! 1300: } ! 1301: ! 1302: warning (msg) ! 1303: { ! 1304: printf ("warning: %s\n", msg); ! 1305: } ! 1306: ! 1307: struct hashnode * ! 1308: lookup (name, len, hash) ! 1309: char *name; ! 1310: int len; ! 1311: int hash; ! 1312: { ! 1313: return (DEFAULT_SIGNED_CHAR) ? 0 : ((struct hashnode *) -1); 1.1 root 1314: } 1315: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.