1 2/* A Bison parser, made from cexp.y 3 by GNU Bison version 1.25 4 */ 5 6#define YYBISON 1 /* Identify Bison output. */ 7 8#define INT 258 9#define CHAR 259 10#define NAME 260 11#define ERROR 261 12#define OR 262 13#define AND 263 14#define EQUAL 264 15#define NOTEQUAL 265 16#define LEQ 266 17#define GEQ 267 18#define LSH 268 19#define RSH 269 20#define UNARY 270 21 22#line 27 "cexp.y" 23 24#include "config.h" 25 26#include "system.h" 27#include "intl.h" 28#include <setjmp.h> 29/* #define YYDEBUG 1 */ 30 31#ifdef MULTIBYTE_CHARS 32#include "mbchar.h" 33#include <locale.h> 34#endif /* MULTIBYTE_CHARS */ 35 36typedef unsigned char U_CHAR; 37 38/* This is used for communicating lists of keywords with cccp.c. */ 39struct arglist { 40 struct arglist *next; 41 U_CHAR *name; 42 int length; 43 int argno; 44}; 45 46HOST_WIDEST_INT parse_c_expression PROTO((char *, int)); 47 48static int yylex PROTO((void)); 49static void yyerror PVPROTO((const char *, ...)) 50 ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; 51static HOST_WIDEST_INT expression_value; 52#ifdef TEST_EXP_READER 53static int expression_signedp; 54#endif 55 56static jmp_buf parse_return_error; 57 58/* Nonzero means count most punctuation as part of a name. */ 59static int keyword_parsing = 0; 60 61/* Nonzero means do not evaluate this expression. 62 This is a count, since unevaluated expressions can nest. */ 63static int skip_evaluation; 64 65/* Nonzero means warn if undefined identifiers are evaluated. */ 66static int warn_undef; 67 68/* some external tables of character types */ 69extern unsigned char is_idstart[], is_idchar[], is_space[]; 70 71/* Flag for -pedantic. */ 72extern int pedantic; 73 74/* Flag for -traditional. */ 75extern int traditional; 76 77/* Flag for -lang-c89. */ 78extern int c89; 79 80#ifndef CHAR_TYPE_SIZE 81#define CHAR_TYPE_SIZE BITS_PER_UNIT 82#endif 83 84#ifndef INT_TYPE_SIZE 85#define INT_TYPE_SIZE BITS_PER_WORD 86#endif 87 88#ifndef LONG_TYPE_SIZE 89#define LONG_TYPE_SIZE BITS_PER_WORD 90#endif 91 92#ifndef WCHAR_TYPE_SIZE 93#define WCHAR_TYPE_SIZE INT_TYPE_SIZE 94#endif 95 96#ifndef MAX_CHAR_TYPE_SIZE 97#define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE 98#endif 99 100#ifndef MAX_INT_TYPE_SIZE 101#define MAX_INT_TYPE_SIZE INT_TYPE_SIZE 102#endif 103 104#ifndef MAX_LONG_TYPE_SIZE 105#define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE 106#endif 107 108#ifndef MAX_WCHAR_TYPE_SIZE 109#define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE 110#endif 111 112#define MAX_CHAR_TYPE_MASK (MAX_CHAR_TYPE_SIZE < HOST_BITS_PER_WIDEST_INT \ 113 ? (~ (~ (HOST_WIDEST_INT) 0 << MAX_CHAR_TYPE_SIZE)) \ 114 : ~ (HOST_WIDEST_INT) 0) 115 116#define MAX_WCHAR_TYPE_MASK (MAX_WCHAR_TYPE_SIZE < HOST_BITS_PER_WIDEST_INT \ 117 ? ~ (~ (HOST_WIDEST_INT) 0 << MAX_WCHAR_TYPE_SIZE) \ 118 : ~ (HOST_WIDEST_INT) 0) 119 120/* Suppose A1 + B1 = SUM1, using 2's complement arithmetic ignoring overflow. 121 Suppose A, B and SUM have the same respective signs as A1, B1, and SUM1. 122 Suppose SIGNEDP is negative if the result is signed, zero if unsigned. 123 Then this yields nonzero if overflow occurred during the addition. 124 Overflow occurs if A and B have the same sign, but A and SUM differ in sign, 125 and SIGNEDP is negative. 126 Use `^' to test whether signs differ, and `< 0' to isolate the sign. */ 127#define overflow_sum_sign(a, b, sum, signedp) \ 128 ((~((a) ^ (b)) & ((a) ^ (sum)) & (signedp)) < 0) 129 130struct constant; 131 132HOST_WIDEST_INT parse_escape PROTO((char **, HOST_WIDEST_INT)); 133int check_assertion PROTO((U_CHAR *, int, int, struct arglist *)); 134struct hashnode *lookup PROTO((U_CHAR *, int, int)); 135void error PVPROTO((const char *, ...)) ATTRIBUTE_PRINTF_1; 136void verror PROTO((const char *, va_list)); 137void pedwarn PVPROTO((const char *, ...)) ATTRIBUTE_PRINTF_1; 138void warning PVPROTO((const char *, ...)) ATTRIBUTE_PRINTF_1; 139 140static int parse_number PROTO((int)); 141static HOST_WIDEST_INT left_shift PROTO((struct constant *, unsigned HOST_WIDEST_INT)); 142static HOST_WIDEST_INT right_shift PROTO((struct constant *, unsigned HOST_WIDEST_INT)); 143static void integer_overflow PROTO((void)); 144 145/* `signedp' values */ 146#define SIGNED (~0) 147#define UNSIGNED 0 148 149#line 154 "cexp.y" 150typedef union { 151 struct constant {HOST_WIDEST_INT value; int signedp;} integer; 152 struct name {U_CHAR *address; int length;} name; 153 struct arglist *keywords; 154} YYSTYPE; 155#include <stdio.h> 156 157#ifndef __cplusplus 158#ifndef __STDC__ 159#define const 160#endif 161#endif 162 163 164 165#define YYFINAL 77 166#define YYFLAG -32768 167#define YYNTBASE 34 168 169#define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 43) 170 171static const char yytranslate[] = { 0, 172 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 173 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 174 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 175 2, 2, 29, 2, 31, 2, 27, 14, 2, 32, 176 33, 25, 23, 9, 24, 2, 26, 2, 2, 2, 177 2, 2, 2, 2, 2, 2, 2, 8, 2, 17, 178 2, 18, 7, 2, 2, 2, 2, 2, 2, 2, 179 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 180 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 181 2, 2, 2, 13, 2, 2, 2, 2, 2, 2, 182 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 183 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 184 2, 2, 2, 12, 2, 30, 2, 2, 2, 2, 185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 190 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 191 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 192 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 193 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 194 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 195 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 196 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 197 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 198 6, 10, 11, 15, 16, 19, 20, 21, 22, 28 199}; 200 201#if YYDEBUG != 0 202static const short yyprhs[] = { 0, 203 0, 2, 4, 8, 11, 14, 17, 20, 23, 24, 204 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 205 71, 75, 79, 83, 87, 91, 95, 99, 100, 105, 206 106, 111, 112, 113, 121, 123, 125, 127, 128, 133 207}; 208 209static const short yyrhs[] = { 35, 210 0, 36, 0, 35, 9, 36, 0, 24, 36, 0, 211 29, 36, 0, 23, 36, 0, 30, 36, 0, 31, 212 5, 0, 0, 31, 5, 37, 32, 42, 33, 0, 213 32, 35, 33, 0, 36, 25, 36, 0, 36, 26, 214 36, 0, 36, 27, 36, 0, 36, 23, 36, 0, 215 36, 24, 36, 0, 36, 21, 36, 0, 36, 22, 216 36, 0, 36, 15, 36, 0, 36, 16, 36, 0, 217 36, 19, 36, 0, 36, 20, 36, 0, 36, 17, 218 36, 0, 36, 18, 36, 0, 36, 14, 36, 0, 219 36, 13, 36, 0, 36, 12, 36, 0, 0, 36, 220 11, 38, 36, 0, 0, 36, 10, 39, 36, 0, 221 0, 0, 36, 7, 40, 36, 8, 41, 36, 0, 222 3, 0, 4, 0, 5, 0, 0, 32, 42, 33, 223 42, 0, 5, 42, 0 224}; 225 226#endif 227 228#if YYDEBUG != 0 229static const short yyrline[] = { 0, 230 184, 194, 195, 202, 207, 210, 212, 215, 219, 221, 231 226, 231, 244, 261, 274, 280, 286, 292, 298, 301, 232 304, 311, 318, 325, 332, 335, 338, 341, 344, 347, 233 350, 353, 355, 358, 361, 363, 365, 373, 375, 388 234}; 235#endif 236 237 238#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) 239 240static const char * const yytname[] = { "$","error","$undefined.","INT","CHAR", 241"NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL", 242"'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'", 243"'~'","'#'","'('","')'","start","exp1","exp","@1","@2","@3","@4","@5","keywords", NULL 244}; 245#endif 246 247static const short yyr1[] = { 0, 248 34, 35, 35, 36, 36, 36, 36, 36, 37, 36, 249 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 250 36, 36, 36, 36, 36, 36, 36, 38, 36, 39, 251 36, 40, 41, 36, 36, 36, 36, 42, 42, 42 252}; 253 254static const short yyr2[] = { 0, 255 1, 1, 3, 2, 2, 2, 2, 2, 0, 6, 256 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 257 3, 3, 3, 3, 3, 3, 3, 0, 4, 0, 258 4, 0, 0, 7, 1, 1, 1, 0, 4, 2 259}; 260 261static const short yydefact[] = { 0, 262 35, 36, 37, 0, 0, 0, 0, 0, 0, 1, 263 2, 6, 4, 5, 7, 8, 0, 0, 32, 30, 264 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 265 0, 0, 0, 0, 0, 0, 0, 0, 11, 3, 266 0, 0, 0, 27, 26, 25, 19, 20, 23, 24, 267 21, 22, 17, 18, 15, 16, 12, 13, 14, 38, 268 0, 31, 29, 38, 38, 0, 33, 40, 0, 10, 269 0, 38, 34, 39, 0, 0, 0 270}; 271 272static const short yydefgoto[] = { 75, 273 10, 11, 38, 43, 42, 41, 71, 66 274}; 275 276static const short yypact[] = { 12, 277-32768,-32768,-32768, 12, 12, 12, 12, 1, 12, 4, 278 79,-32768,-32768,-32768,-32768, -21, 31, 12,-32768,-32768, 279-32768, 12, 12, 12, 12, 12, 12, 12, 12, 12, 280 12, 12, 12, 12, 12, 12, 12, 30,-32768, 79, 281 12, 12, 12, 110, 124, 137, 148, 148, 155, 155, 282 155, 155, 160, 160, -17, -17,-32768,-32768,-32768, 2, 283 58, 34, 95, 2, 2, 54,-32768,-32768, 55,-32768, 284 12, 2, 79,-32768, 63, 188,-32768 285}; 286 287static const short yypgoto[] = {-32768, 288 180, -4,-32768,-32768,-32768,-32768,-32768, -60 289}; 290 291 292#define YYLAST 189 293 294 295static const short yytable[] = { 12, 296 13, 14, 15, 68, 69, 16, 64, 35, 36, 37, 297 -9, 74, 18, 40, 1, 2, 3, 44, 45, 46, 298 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 299 57, 58, 59, 65, 4, 5, 61, 62, 63, 18, 300 6, 7, 8, 9, 21, 22, 23, 24, 25, 26, 301 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 302 37, 60, 76, 39, 19, 67, 73, 20, 21, 22, 303 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 304 33, 34, 35, 36, 37, 19, 70, 72, 20, 21, 305 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 306 32, 33, 34, 35, 36, 37, 22, 23, 24, 25, 307 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 308 36, 37, 23, 24, 25, 26, 27, 28, 29, 30, 309 31, 32, 33, 34, 35, 36, 37, 24, 25, 26, 310 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 311 37, 25, 26, 27, 28, 29, 30, 31, 32, 33, 312 34, 35, 36, 37, 27, 28, 29, 30, 31, 32, 313 33, 34, 35, 36, 37, 31, 32, 33, 34, 35, 314 36, 37, 33, 34, 35, 36, 37, 77, 17 315}; 316 317static const short yycheck[] = { 4, 318 5, 6, 7, 64, 65, 5, 5, 25, 26, 27, 319 32, 72, 9, 18, 3, 4, 5, 22, 23, 24, 320 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 321 35, 36, 37, 32, 23, 24, 41, 42, 43, 9, 322 29, 30, 31, 32, 11, 12, 13, 14, 15, 16, 323 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 324 27, 32, 0, 33, 7, 8, 71, 10, 11, 12, 325 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 326 23, 24, 25, 26, 27, 7, 33, 33, 10, 11, 327 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 328 22, 23, 24, 25, 26, 27, 12, 13, 14, 15, 329 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 330 26, 27, 13, 14, 15, 16, 17, 18, 19, 20, 331 21, 22, 23, 24, 25, 26, 27, 14, 15, 16, 332 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 333 27, 15, 16, 17, 18, 19, 20, 21, 22, 23, 334 24, 25, 26, 27, 17, 18, 19, 20, 21, 22, 335 23, 24, 25, 26, 27, 21, 22, 23, 24, 25, 336 26, 27, 23, 24, 25, 26, 27, 0, 9 337}; 338/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ 339#line 3 "/tmp/sky/share/bison.simple" 340 341/* Skeleton output parser for bison, 342 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. 343 344 This program is free software; you can redistribute it and/or modify 345 it under the terms of the GNU General Public License as published by 346 the Free Software Foundation; either version 2, or (at your option) 347 any later version. 348 349 This program is distributed in the hope that it will be useful, 350 but WITHOUT ANY WARRANTY; without even the implied warranty of 351 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 352 GNU General Public License for more details. 353 354 You should have received a copy of the GNU General Public License 355 along with this program; if not, write to the Free Software 356 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 357 358/* As a special exception, when this file is copied by Bison into a 359 Bison output file, you may use that output file without restriction. 360 This special exception was added by the Free Software Foundation 361 in version 1.24 of Bison. */ 362 363#ifndef alloca 364#ifdef __GNUC__ 365#define alloca __builtin_alloca 366#else /* not GNU C. */ 367#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) 368#include <alloca.h> 369#else /* not sparc */ 370#if defined (MSDOS) && !defined (__TURBOC__) 371#include <malloc.h> 372#else /* not MSDOS, or __TURBOC__ */ 373#if defined(_AIX) 374#include <malloc.h> 375 #pragma alloca 376#else /* not MSDOS, __TURBOC__, or _AIX */ 377#ifdef __hpux 378#ifdef __cplusplus 379extern "C" { 380void *alloca (unsigned int); 381}; 382#else /* not __cplusplus */ 383void *alloca (); 384#endif /* not __cplusplus */ 385#endif /* __hpux */ 386#endif /* not _AIX */ 387#endif /* not MSDOS, or __TURBOC__ */ 388#endif /* not sparc. */ 389#endif /* not GNU C. */ 390#endif /* alloca not defined. */ 391 392/* This is the parser code that is written into each bison parser 393 when the %semantic_parser declaration is not specified in the grammar. 394 It was written by Richard Stallman by simplifying the hairy parser 395 used when %semantic_parser is specified. */ 396 397/* Note: there must be only one dollar sign in this file. 398 It is replaced by the list of actions, each action 399 as one case of the switch. */ 400 401#define yyerrok (yyerrstatus = 0) 402#define yyclearin (yychar = YYEMPTY) 403#define YYEMPTY -2 404#define YYEOF 0 405#define YYACCEPT return(0) 406#define YYABORT return(1) 407#define YYERROR goto yyerrlab1 408/* Like YYERROR except do call yyerror. 409 This remains here temporarily to ease the 410 transition to the new meaning of YYERROR, for GCC. 411 Once GCC version 2 has supplanted version 1, this can go. */ 412#define YYFAIL goto yyerrlab 413#define YYRECOVERING() (!!yyerrstatus) 414#define YYBACKUP(token, value) \ 415do \ 416 if (yychar == YYEMPTY && yylen == 1) \ 417 { yychar = (token), yylval = (value); \ 418 yychar1 = YYTRANSLATE (yychar); \ 419 YYPOPSTACK; \ 420 goto yybackup; \ 421 } \ 422 else \ 423 { yyerror ("syntax error: cannot back up"); YYERROR; } \ 424while (0) 425 426#define YYTERROR 1 427#define YYERRCODE 256 428 429#ifndef YYPURE 430#define YYLEX yylex() 431#endif 432 433#ifdef YYPURE 434#ifdef YYLSP_NEEDED 435#ifdef YYLEX_PARAM 436#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) 437#else 438#define YYLEX yylex(&yylval, &yylloc) 439#endif 440#else /* not YYLSP_NEEDED */ 441#ifdef YYLEX_PARAM 442#define YYLEX yylex(&yylval, YYLEX_PARAM) 443#else 444#define YYLEX yylex(&yylval) 445#endif 446#endif /* not YYLSP_NEEDED */ 447#endif 448 449/* If nonreentrant, generate the variables here */ 450 451#ifndef YYPURE 452 453int yychar; /* the lookahead symbol */ 454YYSTYPE yylval; /* the semantic value of the */ 455 /* lookahead symbol */ 456 457#ifdef YYLSP_NEEDED 458YYLTYPE yylloc; /* location data for the lookahead */ 459 /* symbol */ 460#endif 461 462int yynerrs; /* number of parse errors so far */ 463#endif /* not YYPURE */ 464 465#if YYDEBUG != 0 466int yydebug; /* nonzero means print parse trace */ 467/* Since this is uninitialized, it does not stop multiple parsers 468 from coexisting. */ 469#endif 470 471/* YYINITDEPTH indicates the initial size of the parser's stacks */ 472 473#ifndef YYINITDEPTH 474#define YYINITDEPTH 200 475#endif 476 477/* YYMAXDEPTH is the maximum size the stacks can grow to 478 (effective only if the built-in stack extension method is used). */ 479 480#if YYMAXDEPTH == 0 481#undef YYMAXDEPTH 482#endif 483 484#ifndef YYMAXDEPTH 485#define YYMAXDEPTH 10000 486#endif 487 488/* Prevent warning if -Wstrict-prototypes. */ 489#ifdef __GNUC__ 490int yyparse (void); 491#endif 492 493#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ 494#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) 495#else /* not GNU C or C++ */ 496#ifndef __cplusplus 497 498/* This is the most reliable way to avoid incompatibilities 499 in available built-in functions on various systems. */ 500static void 501__yy_memcpy (to, from, count) 502 char *to; 503 char *from; 504 int count; 505{ 506 register char *f = from; 507 register char *t = to; 508 register int i = count; 509 510 while (i-- > 0) 511 *t++ = *f++; 512} 513 514#else /* __cplusplus */ 515 516/* This is the most reliable way to avoid incompatibilities 517 in available built-in functions on various systems. */ 518static void 519__yy_memcpy (char *to, char *from, int count) 520{ 521 register char *f = from; 522 register char *t = to; 523 register int i = count; 524 525 while (i-- > 0) 526 *t++ = *f++; 527} 528 529#endif 530#endif 531 532#line 196 "/tmp/sky/share/bison.simple" 533 534/* The user can define YYPARSE_PARAM as the name of an argument to be passed 535 into yyparse. The argument should have type void *. 536 It should actually point to an object. 537 Grammar actions can access the variable by casting it 538 to the proper pointer type. */ 539 540#ifdef YYPARSE_PARAM 541#ifdef __cplusplus 542#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM 543#define YYPARSE_PARAM_DECL 544#else /* not __cplusplus */ 545#define YYPARSE_PARAM_ARG YYPARSE_PARAM 546#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; 547#endif /* not __cplusplus */ 548#else /* not YYPARSE_PARAM */ 549#define YYPARSE_PARAM_ARG 550#define YYPARSE_PARAM_DECL 551#endif /* not YYPARSE_PARAM */ 552 553int 554yyparse(YYPARSE_PARAM_ARG) 555 YYPARSE_PARAM_DECL 556{ 557 register int yystate; 558 register int yyn; 559 register short *yyssp; 560 register YYSTYPE *yyvsp; 561 int yyerrstatus; /* number of tokens to shift before error messages enabled */ 562 int yychar1 = 0; /* lookahead token as an internal (translated) token number */ 563 564 short yyssa[YYINITDEPTH]; /* the state stack */ 565 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ 566 567 short *yyss = yyssa; /* refer to the stacks thru separate pointers */ 568 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ 569 570#ifdef YYLSP_NEEDED 571 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ 572 YYLTYPE *yyls = yylsa; 573 YYLTYPE *yylsp; 574 575#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) 576#else 577#define YYPOPSTACK (yyvsp--, yyssp--) 578#endif 579 580 int yystacksize = YYINITDEPTH; 581 582#ifdef YYPURE 583 int yychar; 584 YYSTYPE yylval; 585 int yynerrs; 586#ifdef YYLSP_NEEDED 587 YYLTYPE yylloc; 588#endif 589#endif 590 591 YYSTYPE yyval; /* the variable used to return */ 592 /* semantic values from the action */ 593 /* routines */ 594 595 int yylen; 596 597#if YYDEBUG != 0 598 if (yydebug) 599 fprintf(stderr, "Starting parse\n"); 600#endif 601 602 yystate = 0; 603 yyerrstatus = 0; 604 yynerrs = 0; 605 yychar = YYEMPTY; /* Cause a token to be read. */ 606 607 /* Initialize stack pointers. 608 Waste one element of value and location stack 609 so that they stay on the same level as the state stack. 610 The wasted elements are never initialized. */ 611 612 yyssp = yyss - 1; 613 yyvsp = yyvs; 614#ifdef YYLSP_NEEDED 615 yylsp = yyls; 616#endif 617 618/* Push a new state, which is found in yystate . */ 619/* In all cases, when you get here, the value and location stacks 620 have just been pushed. so pushing a state here evens the stacks. */ 621yynewstate: 622 623 *++yyssp = yystate; 624 625 if (yyssp >= yyss + yystacksize - 1) 626 { 627 /* Give user a chance to reallocate the stack */ 628 /* Use copies of these so that the &'s don't force the real ones into memory. */ 629 YYSTYPE *yyvs1 = yyvs; 630 short *yyss1 = yyss; 631#ifdef YYLSP_NEEDED 632 YYLTYPE *yyls1 = yyls; 633#endif 634 635 /* Get the current used size of the three stacks, in elements. */ 636 int size = yyssp - yyss + 1; 637 638#ifdef yyoverflow 639 /* Each stack pointer address is followed by the size of 640 the data in use in that stack, in bytes. */ 641#ifdef YYLSP_NEEDED 642 /* This used to be a conditional around just the two extra args, 643 but that might be undefined if yyoverflow is a macro. */ 644 yyoverflow("parser stack overflow", 645 &yyss1, size * sizeof (*yyssp), 646 &yyvs1, size * sizeof (*yyvsp), 647 &yyls1, size * sizeof (*yylsp), 648 &yystacksize); 649#else 650 yyoverflow("parser stack overflow", 651 &yyss1, size * sizeof (*yyssp), 652 &yyvs1, size * sizeof (*yyvsp), 653 &yystacksize); 654#endif 655 656 yyss = yyss1; yyvs = yyvs1; 657#ifdef YYLSP_NEEDED 658 yyls = yyls1; 659#endif 660#else /* no yyoverflow */ 661 /* Extend the stack our own way. */ 662 if (yystacksize >= YYMAXDEPTH) 663 { 664 yyerror("parser stack overflow"); 665 return 2; 666 } 667 yystacksize *= 2; 668 if (yystacksize > YYMAXDEPTH) 669 yystacksize = YYMAXDEPTH; 670 yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); 671 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp)); 672 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); 673 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp)); 674#ifdef YYLSP_NEEDED 675 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); 676 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp)); 677#endif 678#endif /* no yyoverflow */ 679 680 yyssp = yyss + size - 1; 681 yyvsp = yyvs + size - 1; 682#ifdef YYLSP_NEEDED 683 yylsp = yyls + size - 1; 684#endif 685 686#if YYDEBUG != 0 687 if (yydebug) 688 fprintf(stderr, "Stack size increased to %d\n", yystacksize); 689#endif 690 691 if (yyssp >= yyss + yystacksize - 1) 692 YYABORT; 693 } 694 695#if YYDEBUG != 0 696 if (yydebug) 697 fprintf(stderr, "Entering state %d\n", yystate); 698#endif 699 700 goto yybackup; 701 yybackup: 702 703/* Do appropriate processing given the current state. */ 704/* Read a lookahead token if we need one and don't already have one. */ 705/* yyresume: */ 706 707 /* First try to decide what to do without reference to lookahead token. */ 708 709 yyn = yypact[yystate]; 710 if (yyn == YYFLAG) 711 goto yydefault; 712 713 /* Not known => get a lookahead token if don't already have one. */ 714 715 /* yychar is either YYEMPTY or YYEOF 716 or a valid token in external form. */ 717 718 if (yychar == YYEMPTY) 719 { 720#if YYDEBUG != 0 721 if (yydebug) 722 fprintf(stderr, "Reading a token: "); 723#endif 724 yychar = YYLEX; 725 } 726 727 /* Convert token to internal form (in yychar1) for indexing tables with */ 728 729 if (yychar <= 0) /* This means end of input. */ 730 { 731 yychar1 = 0; 732 yychar = YYEOF; /* Don't call YYLEX any more */ 733 734#if YYDEBUG != 0 735 if (yydebug) 736 fprintf(stderr, "Now at end of input.\n"); 737#endif 738 } 739 else 740 { 741 yychar1 = YYTRANSLATE(yychar); 742 743#if YYDEBUG != 0 744 if (yydebug) 745 { 746 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); 747 /* Give the individual parser a way to print the precise meaning 748 of a token, for further debugging info. */ 749#ifdef YYPRINT 750 YYPRINT (stderr, yychar, yylval); 751#endif 752 fprintf (stderr, ")\n"); 753 } 754#endif 755 } 756 757 yyn += yychar1; 758 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) 759 goto yydefault; 760 761 yyn = yytable[yyn]; 762 763 /* yyn is what to do for this token type in this state. 764 Negative => reduce, -yyn is rule number. 765 Positive => shift, yyn is new state. 766 New state is final state => don't bother to shift, 767 just return success. 768 0, or most negative number => error. */ 769 770 if (yyn < 0) 771 { 772 if (yyn == YYFLAG) 773 goto yyerrlab; 774 yyn = -yyn; 775 goto yyreduce; 776 } 777 else if (yyn == 0) 778 goto yyerrlab; 779 780 if (yyn == YYFINAL) 781 YYACCEPT; 782 783 /* Shift the lookahead token. */ 784 785#if YYDEBUG != 0 786 if (yydebug) 787 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); 788#endif 789 790 /* Discard the token being shifted unless it is eof. */ 791 if (yychar != YYEOF) 792 yychar = YYEMPTY; 793 794 *++yyvsp = yylval; 795#ifdef YYLSP_NEEDED 796 *++yylsp = yylloc; 797#endif 798 799 /* count tokens shifted since error; after three, turn off error status. */ 800 if (yyerrstatus) yyerrstatus--; 801 802 yystate = yyn; 803 goto yynewstate; 804 805/* Do the default action for the current state. */ 806yydefault: 807 808 yyn = yydefact[yystate]; 809 if (yyn == 0) 810 goto yyerrlab; 811 812/* Do a reduction. yyn is the number of a rule to reduce with. */ 813yyreduce: 814 yylen = yyr2[yyn]; 815 if (yylen > 0) 816 yyval = yyvsp[1-yylen]; /* implement default value of the action */ 817 818#if YYDEBUG != 0 819 if (yydebug) 820 { 821 int i; 822 823 fprintf (stderr, "Reducing via rule %d (line %d), ", 824 yyn, yyrline[yyn]); 825 826 /* Print the symbols being reduced, and their result. */ 827 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) 828 fprintf (stderr, "%s ", yytname[yyrhs[i]]); 829 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); 830 } 831#endif 832 833 834 switch (yyn) { 835 836case 1: 837#line 185 "cexp.y" 838{ 839 expression_value = yyvsp[0].integer.value; 840#ifdef TEST_EXP_READER 841 expression_signedp = yyvsp[0].integer.signedp; 842#endif 843 ; 844 break;} 845case 3: 846#line 196 "cexp.y" 847{ if (pedantic) 848 pedwarn ("comma operator in operand of `#if'"); 849 yyval.integer = yyvsp[0].integer; ; 850 break;} 851case 4: 852#line 203 "cexp.y" 853{ yyval.integer.value = - yyvsp[0].integer.value; 854 yyval.integer.signedp = yyvsp[0].integer.signedp; 855 if ((yyval.integer.value & yyvsp[0].integer.value & yyval.integer.signedp) < 0) 856 integer_overflow (); ; 857 break;} 858case 5: 859#line 208 "cexp.y" 860{ yyval.integer.value = ! yyvsp[0].integer.value; 861 yyval.integer.signedp = SIGNED; ; 862 break;} 863case 6: 864#line 211 "cexp.y" 865{ yyval.integer = yyvsp[0].integer; ; 866 break;} 867case 7: 868#line 213 "cexp.y" 869{ yyval.integer.value = ~ yyvsp[0].integer.value; 870 yyval.integer.signedp = yyvsp[0].integer.signedp; ; 871 break;} 872case 8: 873#line 216 "cexp.y" 874{ yyval.integer.value = check_assertion (yyvsp[0].name.address, yyvsp[0].name.length, 875 0, NULL_PTR); 876 yyval.integer.signedp = SIGNED; ; 877 break;} 878case 9: 879#line 220 "cexp.y" 880{ keyword_parsing = 1; ; 881 break;} 882case 10: 883#line 222 "cexp.y" 884{ yyval.integer.value = check_assertion (yyvsp[-4].name.address, yyvsp[-4].name.length, 885 1, yyvsp[-1].keywords); 886 keyword_parsing = 0; 887 yyval.integer.signedp = SIGNED; ; 888 break;} 889case 11: 890#line 227 "cexp.y" 891{ yyval.integer = yyvsp[-1].integer; ; 892 break;} 893case 12: 894#line 232 "cexp.y" 895{ yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; 896 if (yyval.integer.signedp) 897 { 898 yyval.integer.value = yyvsp[-2].integer.value * yyvsp[0].integer.value; 899 if (yyvsp[-2].integer.value 900 && (yyval.integer.value / yyvsp[-2].integer.value != yyvsp[0].integer.value 901 || (yyval.integer.value & yyvsp[-2].integer.value & yyvsp[0].integer.value) < 0)) 902 integer_overflow (); 903 } 904 else 905 yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value 906 * yyvsp[0].integer.value); ; 907 break;} 908case 13: 909#line 245 "cexp.y" 910{ if (yyvsp[0].integer.value == 0) 911 { 912 if (!skip_evaluation) 913 error ("division by zero in #if"); 914 yyvsp[0].integer.value = 1; 915 } 916 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; 917 if (yyval.integer.signedp) 918 { 919 yyval.integer.value = yyvsp[-2].integer.value / yyvsp[0].integer.value; 920 if ((yyval.integer.value & yyvsp[-2].integer.value & yyvsp[0].integer.value) < 0) 921 integer_overflow (); 922 } 923 else 924 yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value 925 / yyvsp[0].integer.value); ; 926 break;} 927case 14: 928#line 262 "cexp.y" 929{ if (yyvsp[0].integer.value == 0) 930 { 931 if (!skip_evaluation) 932 error ("division by zero in #if"); 933 yyvsp[0].integer.value = 1; 934 } 935 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; 936 if (yyval.integer.signedp) 937 yyval.integer.value = yyvsp[-2].integer.value % yyvsp[0].integer.value; 938 else 939 yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value 940 % yyvsp[0].integer.value); ; 941 break;} 942case 15: 943#line 275 "cexp.y" 944{ yyval.integer.value = yyvsp[-2].integer.value + yyvsp[0].integer.value; 945 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; 946 if (overflow_sum_sign (yyvsp[-2].integer.value, yyvsp[0].integer.value, 947 yyval.integer.value, yyval.integer.signedp)) 948 integer_overflow (); ; 949 break;} 950case 16: 951#line 281 "cexp.y" 952{ yyval.integer.value = yyvsp[-2].integer.value - yyvsp[0].integer.value; 953 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; 954 if (overflow_sum_sign (yyval.integer.value, yyvsp[0].integer.value, 955 yyvsp[-2].integer.value, yyval.integer.signedp)) 956 integer_overflow (); ; 957 break;} 958case 17: 959#line 287 "cexp.y" 960{ yyval.integer.signedp = yyvsp[-2].integer.signedp; 961 if ((yyvsp[0].integer.value & yyvsp[0].integer.signedp) < 0) 962 yyval.integer.value = right_shift (&yyvsp[-2].integer, -yyvsp[0].integer.value); 963 else 964 yyval.integer.value = left_shift (&yyvsp[-2].integer, yyvsp[0].integer.value); ; 965 break;} 966case 18: 967#line 293 "cexp.y" 968{ yyval.integer.signedp = yyvsp[-2].integer.signedp; 969 if ((yyvsp[0].integer.value & yyvsp[0].integer.signedp) < 0) 970 yyval.integer.value = left_shift (&yyvsp[-2].integer, -yyvsp[0].integer.value); 971 else 972 yyval.integer.value = right_shift (&yyvsp[-2].integer, yyvsp[0].integer.value); ; 973 break;} 974case 19: 975#line 299 "cexp.y" 976{ yyval.integer.value = (yyvsp[-2].integer.value == yyvsp[0].integer.value); 977 yyval.integer.signedp = SIGNED; ; 978 break;} 979case 20: 980#line 302 "cexp.y" 981{ yyval.integer.value = (yyvsp[-2].integer.value != yyvsp[0].integer.value); 982 yyval.integer.signedp = SIGNED; ; 983 break;} 984case 21: 985#line 305 "cexp.y" 986{ yyval.integer.signedp = SIGNED; 987 if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) 988 yyval.integer.value = yyvsp[-2].integer.value <= yyvsp[0].integer.value; 989 else 990 yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value 991 <= yyvsp[0].integer.value); ; 992 break;} 993case 22: 994#line 312 "cexp.y" 995{ yyval.integer.signedp = SIGNED; 996 if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) 997 yyval.integer.value = yyvsp[-2].integer.value >= yyvsp[0].integer.value; 998 else 999 yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value 1000 >= yyvsp[0].integer.value); ; 1001 break;} 1002case 23: 1003#line 319 "cexp.y" 1004{ yyval.integer.signedp = SIGNED; 1005 if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) 1006 yyval.integer.value = yyvsp[-2].integer.value < yyvsp[0].integer.value; 1007 else 1008 yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value 1009 < yyvsp[0].integer.value); ; 1010 break;} 1011case 24: 1012#line 326 "cexp.y" 1013{ yyval.integer.signedp = SIGNED; 1014 if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) 1015 yyval.integer.value = yyvsp[-2].integer.value > yyvsp[0].integer.value; 1016 else 1017 yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value 1018 > yyvsp[0].integer.value); ; 1019 break;} 1020case 25: 1021#line 333 "cexp.y" 1022{ yyval.integer.value = yyvsp[-2].integer.value & yyvsp[0].integer.value; 1023 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ; 1024 break;} 1025case 26: 1026#line 336 "cexp.y" 1027{ yyval.integer.value = yyvsp[-2].integer.value ^ yyvsp[0].integer.value; 1028 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ; 1029 break;} 1030case 27: 1031#line 339 "cexp.y" 1032{ yyval.integer.value = yyvsp[-2].integer.value | yyvsp[0].integer.value; 1033 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ; 1034 break;} 1035case 28: 1036#line 342 "cexp.y" 1037{ skip_evaluation += !yyvsp[-1].integer.value; ; 1038 break;} 1039case 29: 1040#line 344 "cexp.y" 1041{ skip_evaluation -= !yyvsp[-3].integer.value; 1042 yyval.integer.value = (yyvsp[-3].integer.value && yyvsp[0].integer.value); 1043 yyval.integer.signedp = SIGNED; ; 1044 break;} 1045case 30: 1046#line 348 "cexp.y" 1047{ skip_evaluation += !!yyvsp[-1].integer.value; ; 1048 break;} 1049case 31: 1050#line 350 "cexp.y" 1051{ skip_evaluation -= !!yyvsp[-3].integer.value; 1052 yyval.integer.value = (yyvsp[-3].integer.value || yyvsp[0].integer.value); 1053 yyval.integer.signedp = SIGNED; ; 1054 break;} 1055case 32: 1056#line 354 "cexp.y" 1057{ skip_evaluation += !yyvsp[-1].integer.value; ; 1058 break;} 1059case 33: 1060#line 356 "cexp.y" 1061{ skip_evaluation += !!yyvsp[-4].integer.value - !yyvsp[-4].integer.value; ; 1062 break;} 1063case 34: 1064#line 358 "cexp.y" 1065{ skip_evaluation -= !!yyvsp[-6].integer.value; 1066 yyval.integer.value = yyvsp[-6].integer.value ? yyvsp[-3].integer.value : yyvsp[0].integer.value; 1067 yyval.integer.signedp = yyvsp[-3].integer.signedp & yyvsp[0].integer.signedp; ; 1068 break;} 1069case 35: 1070#line 362 "cexp.y" 1071{ yyval.integer = yylval.integer; ; 1072 break;} 1073case 36: 1074#line 364 "cexp.y" 1075{ yyval.integer = yylval.integer; ; 1076 break;} 1077case 37: 1078#line 366 "cexp.y" 1079{ if (warn_undef && !skip_evaluation) 1080 warning ("`%.*s' is not defined", 1081 yyvsp[0].name.length, yyvsp[0].name.address); 1082 yyval.integer.value = 0; 1083 yyval.integer.signedp = SIGNED; ; 1084 break;} 1085case 38: 1086#line 374 "cexp.y" 1087{ yyval.keywords = 0; ; 1088 break;} 1089case 39: 1090#line 376 "cexp.y" 1091{ struct arglist *temp; 1092 yyval.keywords = (struct arglist *) xmalloc (sizeof (struct arglist)); 1093 yyval.keywords->next = yyvsp[-2].keywords; 1094 yyval.keywords->name = (U_CHAR *) "("; 1095 yyval.keywords->length = 1; 1096 temp = yyval.keywords; 1097 while (temp != 0 && temp->next != 0) 1098 temp = temp->next; 1099 temp->next = (struct arglist *) xmalloc (sizeof (struct arglist)); 1100 temp->next->next = yyvsp[0].keywords; 1101 temp->next->name = (U_CHAR *) ")"; 1102 temp->next->length = 1; ; 1103 break;} 1104case 40: 1105#line 389 "cexp.y" 1106{ yyval.keywords = (struct arglist *) xmalloc (sizeof (struct arglist)); 1107 yyval.keywords->name = yyvsp[-1].name.address; 1108 yyval.keywords->length = yyvsp[-1].name.length; 1109 yyval.keywords->next = yyvsp[0].keywords; ; 1110 break;} 1111} 1112 /* the action file gets copied in in place of this dollarsign */ 1113#line 498 "/tmp/sky/share/bison.simple" 1114 1115 yyvsp -= yylen; 1116 yyssp -= yylen; 1117#ifdef YYLSP_NEEDED 1118 yylsp -= yylen; 1119#endif 1120 1121#if YYDEBUG != 0 1122 if (yydebug) 1123 { 1124 short *ssp1 = yyss - 1; 1125 fprintf (stderr, "state stack now"); 1126 while (ssp1 != yyssp) 1127 fprintf (stderr, " %d", *++ssp1); 1128 fprintf (stderr, "\n"); 1129 } 1130#endif 1131 1132 *++yyvsp = yyval; 1133 1134#ifdef YYLSP_NEEDED 1135 yylsp++; 1136 if (yylen == 0) 1137 { 1138 yylsp->first_line = yylloc.first_line; 1139 yylsp->first_column = yylloc.first_column; 1140 yylsp->last_line = (yylsp-1)->last_line; 1141 yylsp->last_column = (yylsp-1)->last_column; 1142 yylsp->text = 0; 1143 } 1144 else 1145 { 1146 yylsp->last_line = (yylsp+yylen-1)->last_line; 1147 yylsp->last_column = (yylsp+yylen-1)->last_column; 1148 } 1149#endif 1150 1151 /* Now "shift" the result of the reduction. 1152 Determine what state that goes to, 1153 based on the state we popped back to 1154 and the rule number reduced by. */ 1155 1156 yyn = yyr1[yyn]; 1157 1158 yystate = yypgoto[yyn - YYNTBASE] + *yyssp; 1159 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) 1160 yystate = yytable[yystate]; 1161 else 1162 yystate = yydefgoto[yyn - YYNTBASE]; 1163 1164 goto yynewstate; 1165 1166yyerrlab: /* here on detecting error */ 1167 1168 if (! yyerrstatus) 1169 /* If not already recovering from an error, report this error. */ 1170 { 1171 ++yynerrs; 1172 1173#ifdef YYERROR_VERBOSE 1174 yyn = yypact[yystate]; 1175 1176 if (yyn > YYFLAG && yyn < YYLAST) 1177 { 1178 int size = 0; 1179 char *msg; 1180 int x, count; 1181 1182 count = 0; 1183 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ 1184 for (x = (yyn < 0 ? -yyn : 0); 1185 x < (sizeof(yytname) / sizeof(char *)); x++) 1186 if (yycheck[x + yyn] == x) 1187 size += strlen(yytname[x]) + 15, count++; 1188 msg = (char *) malloc(size + 15); 1189 if (msg != 0) 1190 { 1191 strcpy(msg, "parse error"); 1192 1193 if (count < 5) 1194 { 1195 count = 0; 1196 for (x = (yyn < 0 ? -yyn : 0); 1197 x < (sizeof(yytname) / sizeof(char *)); x++) 1198 if (yycheck[x + yyn] == x) 1199 { 1200 strcat(msg, count == 0 ? ", expecting `" : " or `"); 1201 strcat(msg, yytname[x]); 1202 strcat(msg, "'"); 1203 count++; 1204 } 1205 } 1206 yyerror(msg); 1207 free(msg); 1208 } 1209 else 1210 yyerror ("parse error; also virtual memory exceeded"); 1211 } 1212 else 1213#endif /* YYERROR_VERBOSE */ 1214 yyerror("parse error"); 1215 } 1216 1217 goto yyerrlab1; 1218yyerrlab1: /* here on error raised explicitly by an action */ 1219 1220 if (yyerrstatus == 3) 1221 { 1222 /* if just tried and failed to reuse lookahead token after an error, discard it. */ 1223 1224 /* return failure if at end of input */ 1225 if (yychar == YYEOF) 1226 YYABORT; 1227 1228#if YYDEBUG != 0 1229 if (yydebug) 1230 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); 1231#endif 1232 1233 yychar = YYEMPTY; 1234 } 1235 1236 /* Else will try to reuse lookahead token 1237 after shifting the error token. */ 1238 1239 yyerrstatus = 3; /* Each real token shifted decrements this */ 1240 1241 goto yyerrhandle; 1242 1243yyerrdefault: /* current state does not do anything special for the error token. */ 1244 1245#if 0 1246 /* This is wrong; only states that explicitly want error tokens 1247 should shift them. */ 1248 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ 1249 if (yyn) goto yydefault; 1250#endif 1251 1252yyerrpop: /* pop the current state because it cannot handle the error token */ 1253 1254 if (yyssp == yyss) YYABORT; 1255 yyvsp--; 1256 yystate = *--yyssp; 1257#ifdef YYLSP_NEEDED 1258 yylsp--; 1259#endif 1260 1261#if YYDEBUG != 0 1262 if (yydebug) 1263 { 1264 short *ssp1 = yyss - 1; 1265 fprintf (stderr, "Error: state stack now"); 1266 while (ssp1 != yyssp) 1267 fprintf (stderr, " %d", *++ssp1); 1268 fprintf (stderr, "\n"); 1269 } 1270#endif 1271 1272yyerrhandle: 1273 1274 yyn = yypact[yystate]; 1275 if (yyn == YYFLAG) 1276 goto yyerrdefault; 1277 1278 yyn += YYTERROR; 1279 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) 1280 goto yyerrdefault; 1281 1282 yyn = yytable[yyn]; 1283 if (yyn < 0) 1284 { 1285 if (yyn == YYFLAG) 1286 goto yyerrpop; 1287 yyn = -yyn; 1288 goto yyreduce; 1289 } 1290 else if (yyn == 0) 1291 goto yyerrpop; 1292 1293 if (yyn == YYFINAL) 1294 YYACCEPT; 1295 1296#if YYDEBUG != 0 1297 if (yydebug) 1298 fprintf(stderr, "Shifting error token, "); 1299#endif 1300 1301 *++yyvsp = yylval; 1302#ifdef YYLSP_NEEDED 1303 *++yylsp = yylloc; 1304#endif 1305 1306 yystate = yyn; 1307 goto yynewstate; 1308} 1309#line 394 "cexp.y" 1310 1311 1312/* During parsing of a C expression, the pointer to the next character 1313 is in this variable. */ 1314 1315static char *lexptr; 1316 1317/* Take care of parsing a number (anything that starts with a digit). 1318 Set yylval and return the token type; update lexptr. 1319 LEN is the number of characters in it. */ 1320 1321/* maybe needs to actually deal with floating point numbers */ 1322 1323static int 1324parse_number (olen) 1325 int olen; 1326{ 1327 register char *p = lexptr; 1328 register int c; 1329 register unsigned HOST_WIDEST_INT n = 0, nd, max_over_base; 1330 register int base = 10; 1331 register int len = olen; 1332 register int overflow = 0; 1333 register int digit, largest_digit = 0; 1334 int spec_long = 0; 1335 1336 yylval.integer.signedp = SIGNED; 1337 1338 if (*p == '0') { 1339 base = 8; 1340 if (len >= 3 && (p[1] == 'x' || p[1] == 'X')) { 1341 p += 2; 1342 base = 16; 1343 len -= 2; 1344 } 1345 } 1346 1347 max_over_base = (unsigned HOST_WIDEST_INT) -1 / base; 1348 1349 for (; len > 0; len--) { 1350 c = *p++; 1351 1352 if (c >= '0' && c <= '9') 1353 digit = c - '0'; 1354 else if (base == 16 && c >= 'a' && c <= 'f') 1355 digit = c - 'a' + 10; 1356 else if (base == 16 && c >= 'A' && c <= 'F') 1357 digit = c - 'A' + 10; 1358 else { 1359 /* `l' means long, and `u' means unsigned. */ 1360 while (1) { 1361 if (c == 'l' || c == 'L') 1362 { 1363 if (!pedantic < spec_long) 1364 yyerror ("too many `l's in integer constant"); 1365 spec_long++; 1366 } 1367 else if (c == 'u' || c == 'U') 1368 { 1369 if (! yylval.integer.signedp) 1370 yyerror ("two `u's in integer constant"); 1371 yylval.integer.signedp = UNSIGNED; 1372 } 1373 else { 1374 if (c == '.' || c == 'e' || c == 'E' || c == 'p' || c == 'P') 1375 yyerror ("Floating point numbers not allowed in #if expressions"); 1376 else 1377 yyerror ("missing white space after number `%.*s'", 1378 (int) (p - lexptr - 1), lexptr); 1379 } 1380 1381 if (--len == 0) 1382 break; 1383 c = *p++; 1384 } 1385 /* Don't look for any more digits after the suffixes. */ 1386 break; 1387 } 1388 if (largest_digit < digit) 1389 largest_digit = digit; 1390 nd = n * base + digit; 1391 overflow |= (max_over_base < n) | (nd < n); 1392 n = nd; 1393 } 1394 1395 if (base <= largest_digit) 1396 pedwarn ("integer constant contains digits beyond the radix"); 1397 1398 if (overflow) 1399 pedwarn ("integer constant out of range"); 1400 1401 /* If too big to be signed, consider it unsigned. */ 1402 if (((HOST_WIDEST_INT) n & yylval.integer.signedp) < 0) 1403 { 1404 if (base == 10) 1405 warning ("integer constant is so large that it is unsigned"); 1406 yylval.integer.signedp = UNSIGNED; 1407 } 1408 1409 lexptr = p; 1410 yylval.integer.value = n; 1411 return INT; 1412} 1413 1414struct token { 1415 const char *operator; 1416 int token; 1417}; 1418 1419static struct token tokentab2[] = { 1420 {"&&", AND}, 1421 {"||", OR}, 1422 {"<<", LSH}, 1423 {">>", RSH}, 1424 {"==", EQUAL}, 1425 {"!=", NOTEQUAL}, 1426 {"<=", LEQ}, 1427 {">=", GEQ}, 1428 {"++", ERROR}, 1429 {"--", ERROR}, 1430 {NULL, ERROR} 1431}; 1432 1433/* Read one token, getting characters through lexptr. */ 1434 1435static int 1436yylex () 1437{ 1438 register int c; 1439 register int namelen; 1440 register unsigned char *tokstart; 1441 register struct token *toktab; 1442 int wide_flag; 1443 HOST_WIDEST_INT mask; 1444 1445 retry: 1446 1447 tokstart = (unsigned char *) lexptr; 1448 c = *tokstart; 1449 /* See if it is a special token of length 2. */ 1450 if (! keyword_parsing) 1451 for (toktab = tokentab2; toktab->operator != NULL; toktab++) 1452 if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) { 1453 lexptr += 2; 1454 if (toktab->token == ERROR) 1455 yyerror ("`%s' not allowed in operand of `#if'", toktab->operator); 1456 return toktab->token; 1457 } 1458 1459 switch (c) { 1460 case '\n': 1461 return 0; 1462 1463 case ' ': 1464 case '\t': 1465 case '\r': 1466 lexptr++; 1467 goto retry; 1468 1469 case 'L': 1470 /* Capital L may start a wide-string or wide-character constant. */ 1471 if (lexptr[1] == '\'') 1472 { 1473 lexptr++; 1474 wide_flag = 1; 1475 mask = MAX_WCHAR_TYPE_MASK; 1476 goto char_constant; 1477 } 1478 if (lexptr[1] == '"') 1479 { 1480 lexptr++; 1481 wide_flag = 1; 1482 mask = MAX_WCHAR_TYPE_MASK; 1483 goto string_constant; 1484 } 1485 break; 1486 1487 case '\'': 1488 wide_flag = 0; 1489 mask = MAX_CHAR_TYPE_MASK; 1490 char_constant: 1491 lexptr++; 1492 if (keyword_parsing) { 1493 char *start_ptr = lexptr - 1; 1494 while (1) { 1495 c = *lexptr++; 1496 if (c == '\\') 1497 c = parse_escape (&lexptr, mask); 1498 else if (c == '\'') 1499 break; 1500 } 1501 yylval.name.address = tokstart; 1502 yylval.name.length = lexptr - start_ptr; 1503 return NAME; 1504 } 1505 1506 /* This code for reading a character constant 1507 handles multicharacter constants and wide characters. 1508 It is mostly copied from c-lex.c. */ 1509 { 1510 register HOST_WIDEST_INT result = 0; 1511 register int num_chars = 0; 1512 int chars_seen = 0; 1513 unsigned width = MAX_CHAR_TYPE_SIZE; 1514 int max_chars; 1515#ifdef MULTIBYTE_CHARS 1516 int longest_char = local_mb_cur_max (); 1517 char *token_buffer = (char *) alloca (longest_char); 1518 (void) local_mbtowc (NULL_PTR, NULL_PTR, 0); 1519#endif 1520 1521 max_chars = MAX_LONG_TYPE_SIZE / width; 1522 if (wide_flag) 1523 width = MAX_WCHAR_TYPE_SIZE; 1524 1525 while (1) 1526 { 1527 c = *lexptr++; 1528 1529 if (c == '\'' || c == EOF) 1530 break; 1531 1532 ++chars_seen; 1533 if (c == '\\') 1534 { 1535 c = parse_escape (&lexptr, mask); 1536 } 1537 else 1538 { 1539#ifdef MULTIBYTE_CHARS 1540 wchar_t wc; 1541 int i; 1542 int char_len = -1; 1543 for (i = 1; i <= longest_char; ++i) 1544 { 1545 token_buffer[i - 1] = c; 1546 char_len = local_mbtowc (& wc, token_buffer, i); 1547 if (char_len != -1) 1548 break; 1549 c = *lexptr++; 1550 } 1551 if (char_len > 1) 1552 { 1553 /* mbtowc sometimes needs an extra char before accepting */ 1554 if (char_len < i) 1555 lexptr--; 1556 if (! wide_flag) 1557 { 1558 /* Merge character into result; ignore excess chars. */ 1559 for (i = 1; i <= char_len; ++i) 1560 { 1561 if (i > max_chars) 1562 break; 1563 if (width < HOST_BITS_PER_INT) 1564 result = (result << width) 1565 | (token_buffer[i - 1] 1566 & ((1 << width) - 1)); 1567 else 1568 result = token_buffer[i - 1]; 1569 } 1570 num_chars += char_len; 1571 continue; 1572 } 1573 } 1574 else 1575 { 1576 if (char_len == -1) 1577 warning ("Ignoring invalid multibyte character"); 1578 } 1579 if (wide_flag) 1580 c = wc; 1581#endif /* ! MULTIBYTE_CHARS */ 1582 } 1583 1584 if (wide_flag) 1585 { 1586 if (chars_seen == 1) /* only keep the first one */ 1587 result = c; 1588 continue; 1589 } 1590 1591 /* Merge character into result; ignore excess chars. */ 1592 num_chars++; 1593 if (num_chars <= max_chars) 1594 { 1595 if (width < HOST_BITS_PER_INT) 1596 result = (result << width) | (c & ((1 << width) - 1)); 1597 else 1598 result = c; 1599 } 1600 } 1601 1602 if (c != '\'') 1603 error ("malformatted character constant"); 1604 else if (chars_seen == 0) 1605 error ("empty character constant"); 1606 else if (num_chars > max_chars) 1607 { 1608 num_chars = max_chars; 1609 error ("character constant too long"); 1610 } 1611 else if (chars_seen != 1 && ! traditional) 1612 warning ("multi-character character constant"); 1613 1614 /* If char type is signed, sign-extend the constant. */ 1615 if (! wide_flag) 1616 { 1617 int num_bits = num_chars * width; 1618 if (num_bits == 0) 1619 /* We already got an error; avoid invalid shift. */ 1620 yylval.integer.value = 0; 1621 else if (lookup ((U_CHAR *) "__CHAR_UNSIGNED__", 1622 sizeof ("__CHAR_UNSIGNED__") - 1, -1) 1623 || ((result >> (num_bits - 1)) & 1) == 0) 1624 yylval.integer.value 1625 = result & (~ (unsigned HOST_WIDEST_INT) 0 1626 >> (HOST_BITS_PER_WIDEST_INT - num_bits)); 1627 else 1628 yylval.integer.value 1629 = result | ~(~ (unsigned HOST_WIDEST_INT) 0 1630 >> (HOST_BITS_PER_WIDEST_INT - num_bits)); 1631 } 1632 else 1633 { 1634 yylval.integer.value = result; 1635 } 1636 } 1637 1638 /* This is always a signed type. */ 1639 yylval.integer.signedp = SIGNED; 1640 1641 return CHAR; 1642 1643 /* some of these chars are invalid in constant expressions; 1644 maybe do something about them later */ 1645 case '/': 1646 case '+': 1647 case '-': 1648 case '*': 1649 case '%': 1650 case '|': 1651 case '&': 1652 case '^': 1653 case '~': 1654 case '!': 1655 case '@': 1656 case '<': 1657 case '>': 1658 case '[': 1659 case ']': 1660 case '.': 1661 case '?': 1662 case ':': 1663 case '=': 1664 case '{': 1665 case '}': 1666 case ',': 1667 case '#': 1668 if (keyword_parsing) 1669 break; 1670 case '(': 1671 case ')': 1672 lexptr++; 1673 return c; 1674 1675 case '"': 1676 mask = MAX_CHAR_TYPE_MASK; 1677 string_constant: 1678 if (keyword_parsing) { 1679 char *start_ptr = lexptr; 1680 lexptr++; 1681 while (1) { 1682 c = *lexptr++; 1683 if (c == '\\') 1684 c = parse_escape (&lexptr, mask); 1685 else if (c == '"') 1686 break; 1687 } 1688 yylval.name.address = tokstart; 1689 yylval.name.length = lexptr - start_ptr; 1690 return NAME; 1691 } 1692 yyerror ("string constants not allowed in #if expressions"); 1693 return ERROR; 1694 } 1695 1696 if (c >= '0' && c <= '9' && !keyword_parsing) { 1697 /* It's a number */ 1698 for (namelen = 1; ; namelen++) { 1699 int d = tokstart[namelen]; 1700 if (! ((is_idchar[d] || d == '.') 1701 || ((d == '-' || d == '+') 1702 && (c == 'e' || c == 'E' 1703 || ((c == 'p' || c == 'P') && ! c89)) 1704 && ! traditional))) 1705 break; 1706 c = d; 1707 } 1708 return parse_number (namelen); 1709 } 1710 1711 /* It is a name. See how long it is. */ 1712 1713 if (keyword_parsing) { 1714 for (namelen = 0;; namelen++) { 1715 if (is_space[tokstart[namelen]]) 1716 break; 1717 if (tokstart[namelen] == '(' || tokstart[namelen] == ')') 1718 break; 1719 if (tokstart[namelen] == '"' || tokstart[namelen] == '\'') 1720 break; 1721 } 1722 } else { 1723 if (!is_idstart[c]) { 1724 yyerror ("Invalid token in expression"); 1725 return ERROR; 1726 } 1727 1728 for (namelen = 0; is_idchar[tokstart[namelen]]; namelen++) 1729 ; 1730 } 1731 1732 lexptr += namelen; 1733 yylval.name.address = tokstart; 1734 yylval.name.length = namelen; 1735 return NAME; 1736} 1737 1738 1739/* Parse a C escape sequence. STRING_PTR points to a variable 1740 containing a pointer to the string to parse. That pointer 1741 is updated past the characters we use. The value of the 1742 escape sequence is returned. 1743 1744 RESULT_MASK is used to mask out the result; 1745 an error is reported if bits are lost thereby. 1746 1747 A negative value means the sequence \ newline was seen, 1748 which is supposed to be equivalent to nothing at all. 1749 1750 If \ is followed by a null character, we return a negative 1751 value and leave the string pointer pointing at the null character. 1752 1753 If \ is followed by 000, we return 0 and leave the string pointer 1754 after the zeros. A value of 0 does not mean end of string. */ 1755 1756HOST_WIDEST_INT 1757parse_escape (string_ptr, result_mask) 1758 char **string_ptr; 1759 HOST_WIDEST_INT result_mask; 1760{ 1761 register int c = *(*string_ptr)++; 1762 switch (c) 1763 { 1764 case 'a': 1765 return TARGET_BELL; 1766 case 'b': 1767 return TARGET_BS; 1768 case 'e': 1769 case 'E': 1770 if (pedantic) 1771 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c); 1772 return 033; 1773 case 'f': 1774 return TARGET_FF; 1775 case 'n': 1776 return TARGET_NEWLINE; 1777 case 'r': 1778 return TARGET_CR; 1779 case 't': 1780 return TARGET_TAB; 1781 case 'v': 1782 return TARGET_VT; 1783 case '\n': 1784 return -2; 1785 case 0: 1786 (*string_ptr)--; 1787 return 0; 1788 1789 case '0': 1790 case '1': 1791 case '2': 1792 case '3': 1793 case '4': 1794 case '5': 1795 case '6': 1796 case '7': 1797 { 1798 register HOST_WIDEST_INT i = c - '0'; 1799 register int count = 0; 1800 while (++count < 3) 1801 { 1802 c = *(*string_ptr)++; 1803 if (c >= '0' && c <= '7') 1804 i = (i << 3) + c - '0'; 1805 else 1806 { 1807 (*string_ptr)--; 1808 break; 1809 } 1810 } 1811 if (i != (i & result_mask)) 1812 { 1813 i &= result_mask; 1814 pedwarn ("octal escape sequence out of range"); 1815 } 1816 return i; 1817 } 1818 case 'x': 1819 { 1820 register unsigned HOST_WIDEST_INT i = 0, overflow = 0; 1821 register int digits_found = 0, digit; 1822 for (;;) 1823 { 1824 c = *(*string_ptr)++; 1825 if (c >= '0' && c <= '9') 1826 digit = c - '0'; 1827 else if (c >= 'a' && c <= 'f') 1828 digit = c - 'a' + 10; 1829 else if (c >= 'A' && c <= 'F') 1830 digit = c - 'A' + 10; 1831 else 1832 { 1833 (*string_ptr)--; 1834 break; 1835 } 1836 overflow |= i ^ (i << 4 >> 4); 1837 i = (i << 4) + digit; 1838 digits_found = 1; 1839 } 1840 if (!digits_found) 1841 yyerror ("\\x used with no following hex digits"); 1842 if (overflow | (i != (i & result_mask))) 1843 { 1844 i &= result_mask; 1845 pedwarn ("hex escape sequence out of range"); 1846 } 1847 return i; 1848 } 1849 default: 1850 return c; 1851 } 1852} 1853 1854static void 1855integer_overflow () 1856{ 1857 if (!skip_evaluation && pedantic) 1858 pedwarn ("integer overflow in preprocessor expression"); 1859} 1860 1861static HOST_WIDEST_INT 1862left_shift (a, b) 1863 struct constant *a; 1864 unsigned HOST_WIDEST_INT b; 1865{ 1866 /* It's unclear from the C standard whether shifts can overflow. 1867 The following code ignores overflow; perhaps a C standard 1868 interpretation ruling is needed. */ 1869 if (b >= HOST_BITS_PER_WIDEST_INT) 1870 return 0; 1871 else 1872 return (unsigned HOST_WIDEST_INT) a->value << b; 1873} 1874 1875static HOST_WIDEST_INT 1876right_shift (a, b) 1877 struct constant *a; 1878 unsigned HOST_WIDEST_INT b; 1879{ 1880 if (b >= HOST_BITS_PER_WIDEST_INT) 1881 return a->signedp ? a->value >> (HOST_BITS_PER_WIDEST_INT - 1) : 0; 1882 else if (a->signedp) 1883 return a->value >> b; 1884 else 1885 return (unsigned HOST_WIDEST_INT) a->value >> b; 1886} 1887 1888/* This page contains the entry point to this file. */ 1889 1890/* Parse STRING as an expression, and complain if this fails 1891 to use up all of the contents of STRING. 1892 STRING may contain '\0' bytes; it is terminated by the first '\n' 1893 outside a string constant, so that we can diagnose '\0' properly. 1894 If WARN_UNDEFINED is nonzero, warn if undefined identifiers are evaluated. 1895 We do not support C comments. They should be removed before 1896 this function is called. */ 1897 1898HOST_WIDEST_INT 1899parse_c_expression (string, warn_undefined) 1900 char *string; 1901 int warn_undefined; 1902{ 1903 lexptr = string; 1904 warn_undef = warn_undefined; 1905 1906 /* if there is some sort of scanning error, just return 0 and assume 1907 the parsing routine has printed an error message somewhere. 1908 there is surely a better thing to do than this. */ 1909 if (setjmp (parse_return_error)) 1910 return 0; 1911 1912 if (yyparse () != 0) 1913 abort (); 1914 1915 if (*lexptr != '\n') 1916 error ("Junk after end of expression."); 1917 1918 return expression_value; /* set by yyparse () */ 1919} 1920 1921static void 1922yyerror VPROTO ((const char * msgid, ...)) 1923{ 1924#ifndef ANSI_PROTOTYPES 1925 const char * msgid; 1926#endif 1927 va_list args; 1928 1929 VA_START (args, msgid); 1930 1931#ifndef ANSI_PROTOTYPES 1932 msgid = va_arg (args, const char *); 1933#endif 1934 1935 verror (msgid, args); 1936 va_end (args); 1937 skip_evaluation = 0; 1938 longjmp (parse_return_error, 1); 1939} 1940 1941 1942#ifdef TEST_EXP_READER 1943 1944#if YYDEBUG 1945extern int yydebug; 1946#endif 1947 1948int pedantic; 1949int traditional; 1950int c89; 1951 1952int main PROTO((int, char **)); 1953static void initialize_random_junk PROTO((void)); 1954static void print_unsigned_host_widest_int PROTO((unsigned HOST_WIDEST_INT)); 1955 1956/* Main program for testing purposes. */ 1957int 1958main (argc, argv) 1959 int argc; 1960 char **argv; 1961{ 1962 int n, c; 1963 char buf[1024]; 1964 unsigned HOST_WIDEST_INT u; 1965 1966 pedantic = 1 < argc; 1967 traditional = 2 < argc; 1968 c89 = 3 < argc; 1969#if YYDEBUG 1970 yydebug = 4 < argc; 1971#endif 1972 initialize_random_junk (); 1973 1974 for (;;) { 1975 printf ("enter expression: "); 1976 n = 0; 1977 while ((buf[n] = c = getchar ()) != '\n' && c != EOF) 1978 n++; 1979 if (c == EOF) 1980 break; 1981 parse_c_expression (buf, 1); 1982 printf ("parser returned "); 1983 u = (unsigned HOST_WIDEST_INT) expression_value; 1984 if (expression_value < 0 && expression_signedp) { 1985 u = -u; 1986 printf ("-"); 1987 } 1988 if (u == 0) 1989 printf ("0"); 1990 else 1991 print_unsigned_host_widest_int (u); 1992 if (! expression_signedp) 1993 printf("u"); 1994 printf ("\n"); 1995 } 1996 1997 return 0; 1998} 1999 2000static void 2001print_unsigned_host_widest_int (u) 2002 unsigned HOST_WIDEST_INT u; 2003{ 2004 if (u) { 2005 print_unsigned_host_widest_int (u / 10); 2006 putchar ('0' + (int) (u % 10)); 2007 } 2008} 2009 2010/* table to tell if char can be part of a C identifier. */ 2011unsigned char is_idchar[256]; 2012/* table to tell if char can be first char of a c identifier. */ 2013unsigned char is_idstart[256]; 2014/* table to tell if c is horizontal or vertical space. */ 2015unsigned char is_space[256]; 2016 2017/* 2018 * initialize random junk in the hash table and maybe other places 2019 */ 2020static void 2021initialize_random_junk () 2022{ 2023 register int i; 2024 2025 /* 2026 * Set up is_idchar and is_idstart tables. These should be 2027 * faster than saying (is_alpha (c) || c == '_'), etc. 2028 * Must do set up these things before calling any routines tthat 2029 * refer to them. 2030 */ 2031 for (i = 'a'; i <= 'z'; i++) { 2032 ++is_idchar[i - 'a' + 'A']; 2033 ++is_idchar[i]; 2034 ++is_idstart[i - 'a' + 'A']; 2035 ++is_idstart[i]; 2036 } 2037 for (i = '0'; i <= '9'; i++) 2038 ++is_idchar[i]; 2039 ++is_idchar['_']; 2040 ++is_idstart['_']; 2041 ++is_idchar['$']; 2042 ++is_idstart['$']; 2043 2044 ++is_space[' ']; 2045 ++is_space['\t']; 2046 ++is_space['\v']; 2047 ++is_space['\f']; 2048 ++is_space['\n']; 2049 ++is_space['\r']; 2050} 2051 2052void 2053error VPROTO ((char * msgid, ...)) 2054{ 2055#ifndef ANSI_PROTOTYPES 2056 char * msgid; 2057#endif 2058 va_list args; 2059 2060 VA_START (args, msgid); 2061 2062#ifndef ANSI_PROTOTYPES 2063 msgid = va_arg (args, char *); 2064#endif 2065 2066 fprintf (stderr, "error: "); 2067 vfprintf (stderr, _(msgid), args); 2068 fprintf (stderr, "\n"); 2069 va_end (args); 2070} 2071 2072void 2073pedwarn VPROTO ((char * msgid, ...)) 2074{ 2075#ifndef ANSI_PROTOTYPES 2076 char * msgid; 2077#endif 2078 va_list args; 2079 2080 VA_START (args, msgid); 2081 2082#ifndef ANSI_PROTOTYPES 2083 msgid = va_arg (args, char *); 2084#endif 2085 2086 fprintf (stderr, "pedwarn: "); 2087 vfprintf (stderr, _(msgid), args); 2088 fprintf (stderr, "\n"); 2089 va_end (args); 2090} 2091 2092void 2093warning VPROTO ((char * msgid, ...)) 2094{ 2095#ifndef ANSI_PROTOTYPES 2096 char * msgid; 2097#endif 2098 va_list args; 2099 2100 VA_START (args, msgid); 2101 2102#ifndef ANSI_PROTOTYPES 2103 msgid = va_arg (args, char *); 2104#endif 2105 2106 fprintf (stderr, "warning: "); 2107 vfprintf (stderr, _(msgid), args); 2108 fprintf (stderr, "\n"); 2109 va_end (args); 2110} 2111 2112 2113int 2114check_assertion (name, sym_length, tokens_specified, tokens) 2115 U_CHAR *name; 2116 int sym_length; 2117 int tokens_specified; 2118 struct arglist *tokens; 2119{ 2120 return 0; 2121} 2122 2123struct hashnode * 2124lookup (name, len, hash) 2125 U_CHAR *name; 2126 int len; 2127 int hash; 2128{ 2129 return (DEFAULT_SIGNED_CHAR) ? 0 : ((struct hashnode *) -1); 2130} 2131 2132PTR 2133xmalloc (size) 2134 size_t size; 2135{ 2136 return (PTR) malloc (size); 2137} 2138#endif 2139