1 /* A Bison parser, made from cccp.y
4 #define YYBISON 1 /* Identify Bison output. */
24 /* #define YYDEBUG 1 */
26 #ifdef MULTIBYTE_CHARS
33 typedef unsigned char U_CHAR
;
35 /* This is used for communicating lists of keywords with cccp.c. */
43 /* Define a generic NULL if one hasn't already been defined. */
50 #if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
51 #define GENERIC_PTR void *
53 #define GENERIC_PTR char *
58 #define NULL_PTR ((GENERIC_PTR)0)
65 static jmp_buf parse_return_error
;
67 /* Nonzero means count most punctuation as part of a name. */
68 static int keyword_parsing
= 0;
70 /* some external tables of character types */
71 extern unsigned char is_idstart
[], is_idchar
[], is_hor_space
[];
73 extern char *xmalloc ();
75 /* Flag for -pedantic. */
78 /* Flag for -traditional. */
79 extern int traditional
;
81 #ifndef CHAR_TYPE_SIZE
82 #define CHAR_TYPE_SIZE BITS_PER_UNIT
86 #define INT_TYPE_SIZE BITS_PER_WORD
89 #ifndef LONG_TYPE_SIZE
90 #define LONG_TYPE_SIZE BITS_PER_WORD
93 #ifndef WCHAR_TYPE_SIZE
94 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
97 /* Yield nonzero if adding two numbers with A's and B's signs can yield a
98 number with SUM's sign, where A, B, and SUM are all C integers. */
99 #define possible_sum_sign(a, b, sum) ((((a) ^ (b)) | ~ ((a) ^ (sum))) < 0)
101 static void integer_overflow ();
102 static long left_shift ();
103 static long right_shift ();
108 struct constant
{long value
; int unsignedp
;} integer
;
109 struct name
{U_CHAR
*address
; int length
;} name
;
110 struct arglist
*keywords
;
114 # define YYSTYPE yystype
123 #define YYFLAG -32768
126 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
127 #define YYTRANSLATE(x) ((unsigned)(x) <= 269 ? yytranslate[x] : 39)
129 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
130 static const char yytranslate
[] =
132 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
133 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
134 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
135 2, 2, 2, 29, 2, 31, 2, 27, 14, 2,
136 32, 33, 25, 23, 9, 24, 2, 26, 2, 2,
137 2, 2, 2, 2, 2, 2, 2, 2, 8, 2,
138 17, 2, 18, 7, 2, 2, 2, 2, 2, 2,
139 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
140 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
141 2, 2, 2, 2, 13, 2, 2, 2, 2, 2,
142 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
143 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
144 2, 2, 2, 2, 12, 2, 30, 2, 2, 2,
145 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
146 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
147 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
148 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
149 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
150 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
151 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
152 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
153 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
154 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
155 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
156 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
157 2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
158 6, 10, 11, 15, 16, 19, 20, 21, 22, 28
162 static const short yyprhs
[] =
164 0, 0, 2, 4, 8, 11, 14, 17, 20, 23,
165 24, 31, 35, 39, 43, 47, 51, 55, 59, 63,
166 67, 71, 75, 79, 83, 87, 91, 95, 99, 103,
167 107, 113, 115, 117, 119, 120, 125
169 static const short yyrhs
[] =
171 35, 0, 36, 0, 35, 9, 36, 0, 24, 36,
172 0, 29, 36, 0, 23, 36, 0, 30, 36, 0,
173 31, 5, 0, 0, 31, 5, 37, 32, 38, 33,
174 0, 32, 35, 33, 0, 36, 25, 36, 0, 36,
175 26, 36, 0, 36, 27, 36, 0, 36, 23, 36,
176 0, 36, 24, 36, 0, 36, 21, 36, 0, 36,
177 22, 36, 0, 36, 15, 36, 0, 36, 16, 36,
178 0, 36, 19, 36, 0, 36, 20, 36, 0, 36,
179 17, 36, 0, 36, 18, 36, 0, 36, 14, 36,
180 0, 36, 13, 36, 0, 36, 12, 36, 0, 36,
181 11, 36, 0, 36, 10, 36, 0, 36, 7, 36,
182 8, 36, 0, 3, 0, 4, 0, 5, 0, 0,
183 32, 38, 33, 38, 0, 5, 38, 0
189 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
190 static const short yyrline
[] =
192 0, 143, 148, 149, 156, 161, 164, 166, 169, 173,
193 173, 180, 185, 197, 212, 223, 230, 237, 243, 249,
194 252, 255, 261, 267, 273, 279, 282, 285, 288, 291,
195 294, 297, 299, 301, 306, 308, 321
200 #if (YYDEBUG) || defined YYERROR_VERBOSE
202 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
203 static const char *const yytname
[] =
205 "$", "error", "$undefined.", "INT", "CHAR", "NAME", "ERROR", "'?'", "':'",
206 "','", "OR", "AND", "'|'", "'^'", "'&'", "EQUAL", "NOTEQUAL", "'<'",
207 "'>'", "LEQ", "GEQ", "LSH", "RSH", "'+'", "'-'", "'*'", "'/'", "'%'",
208 "UNARY", "'!'", "'~'", "'#'", "'('", "')'", "start", "exp1", "exp",
209 "@1", "keywords", NULL
213 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
214 static const short yyr1
[] =
216 0, 34, 35, 35, 36, 36, 36, 36, 36, 37,
217 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
218 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
219 36, 36, 36, 36, 38, 38, 38
222 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
223 static const short yyr2
[] =
225 0, 1, 1, 3, 2, 2, 2, 2, 2, 0,
226 6, 3, 3, 3, 3, 3, 3, 3, 3, 3,
227 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
231 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
232 doesn't specify something else to do. Zero means the default is an
234 static const short yydefact
[] =
236 0, 31, 32, 33, 0, 0, 0, 0, 0, 0,
237 1, 2, 6, 4, 5, 7, 8, 0, 0, 0,
238 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
239 0, 0, 0, 0, 0, 0, 0, 0, 0, 11,
240 3, 0, 29, 28, 27, 26, 25, 19, 20, 23,
241 24, 21, 22, 17, 18, 15, 16, 12, 13, 14,
242 34, 0, 34, 34, 0, 30, 36, 0, 10, 34,
246 static const short yydefgoto
[] =
251 static const short yypact
[] =
253 31,-32768,-32768,-32768, 31, 31, 31, 31, 4, 31,
254 3, 80,-32768,-32768,-32768,-32768, 6, 32, 31, 31,
255 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
256 31, 31, 31, 31, 31, 31, 31, 31, 7,-32768,
257 80, 59, 97, 113, 128, 142, 155, 25, 25, 162,
258 162, 162, 162, 167, 167, -19, -19,-32768,-32768,-32768,
259 5, 31, 5, 5, -20, 80,-32768, 20,-32768, 5,
260 -32768, 40, 56,-32768
263 static const short yypgoto
[] =
265 -32768, 49, -4,-32768, -58
272 static const short yytable
[] =
274 12, 13, 14, 15, 66, 67, 35, 36, 37, 16,
275 62, 70, 18, 68, 40, 41, 42, 43, 44, 45,
276 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
277 56, 57, 58, 59, 1, 2, 3, 63, -9, 60,
278 72, 18, 27, 28, 29, 30, 31, 32, 33, 34,
279 35, 36, 37, 69, 4, 5, 73, 65, 17, 0,
280 6, 7, 8, 9, 0, 39, 19, 61, 0, 20,
281 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
282 31, 32, 33, 34, 35, 36, 37, 19, 0, 0,
283 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
284 30, 31, 32, 33, 34, 35, 36, 37, 21, 22,
285 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
286 33, 34, 35, 36, 37, 22, 23, 24, 25, 26,
287 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
288 37, 23, 24, 25, 26, 27, 28, 29, 30, 31,
289 32, 33, 34, 35, 36, 37, 24, 25, 26, 27,
290 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
291 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
292 35, 36, 37, 31, 32, 33, 34, 35, 36, 37,
296 static const short yycheck
[] =
298 4, 5, 6, 7, 62, 63, 25, 26, 27, 5,
299 5, 69, 9, 33, 18, 19, 20, 21, 22, 23,
300 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
301 34, 35, 36, 37, 3, 4, 5, 32, 32, 32,
302 0, 9, 17, 18, 19, 20, 21, 22, 23, 24,
303 25, 26, 27, 33, 23, 24, 0, 61, 9, -1,
304 29, 30, 31, 32, -1, 33, 7, 8, -1, 10,
305 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
306 21, 22, 23, 24, 25, 26, 27, 7, -1, -1,
307 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
308 20, 21, 22, 23, 24, 25, 26, 27, 11, 12,
309 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
310 23, 24, 25, 26, 27, 12, 13, 14, 15, 16,
311 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
312 27, 13, 14, 15, 16, 17, 18, 19, 20, 21,
313 22, 23, 24, 25, 26, 27, 14, 15, 16, 17,
314 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
315 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
316 25, 26, 27, 21, 22, 23, 24, 25, 26, 27,
319 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
320 #line 3 "/usr/share/bison/bison.simple"
322 /* Skeleton output parser for bison,
323 Copyright (C) 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc.
325 This program is free software; you can redistribute it and/or modify
326 it under the terms of the GNU General Public License as published by
327 the Free Software Foundation; either version 2, or (at your option)
330 This program is distributed in the hope that it will be useful,
331 but WITHOUT ANY WARRANTY; without even the implied warranty of
332 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
333 GNU General Public License for more details.
335 You should have received a copy of the GNU General Public License
336 along with this program; if not, write to the Free Software
337 Foundation, Inc., 59 Temple Place - Suite 330,
338 Boston, MA 02111-1307, USA. */
340 /* As a special exception, when this file is copied by Bison into a
341 Bison output file, you may use that output file without restriction.
342 This special exception was added by the Free Software Foundation
343 in version 1.24 of Bison. */
345 /* This is the parser code that is written into each bison parser when
346 the %semantic_parser declaration is not specified in the grammar.
347 It was written by Richard Stallman by simplifying the hairy parser
348 used when %semantic_parser is specified. */
350 /* All symbols defined below should begin with yy or YY, to avoid
351 infringing on user name space. This should be done even for local
352 variables, as they might otherwise be expanded by user macros.
353 There are some unavoidable exceptions within include files to
354 define necessary library symbols; they are noted "INFRINGES ON
355 USER NAME SPACE" below. */
358 # define YYSTD(x) std::x
363 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
365 /* The parser invokes alloca or malloc; define the necessary symbols. */
367 # if YYSTACK_USE_ALLOCA
368 # define YYSTACK_ALLOC alloca
369 # define YYSIZE_T YYSTD (size_t)
371 # ifndef YYSTACK_USE_ALLOCA
372 # if defined (alloca) || defined (_ALLOCA_H)
373 # define YYSTACK_ALLOC alloca
374 # define YYSIZE_T YYSTD (size_t)
377 # define YYSTACK_ALLOC __builtin_alloca
383 # ifdef YYSTACK_ALLOC
384 /* Pacify GCC's `empty if-body' warning. */
385 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
388 # include <cstdlib> /* INFRINGES ON USER NAME SPACE */
389 # define YYSIZE_T std::size_t
392 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
393 # define YYSIZE_T size_t
396 # define YYSTACK_ALLOC YYSTD (malloc)
397 # define YYSTACK_FREE YYSTD (free)
400 /* A type that is properly aligned for any stack member. */
410 /* The size of the maximum gap between one aligned stack and the next. */
411 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
413 /* The size of an array large to enough to hold all stacks, each with
416 # define YYSTACK_BYTES(N) \
417 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
418 + 2 * YYSTACK_GAP_MAX)
420 # define YYSTACK_BYTES(N) \
421 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
425 /* Relocate the TYPE STACK from its old location to the new one. The
426 local variables YYSIZE and YYSTACKSIZE give the old and new number of
427 elements in the stack, and YYPTR gives the new location of the
428 stack. Advance YYPTR to a properly aligned location for the next
430 # define YYSTACK_RELOCATE(Type, Stack) \
433 YYSIZE_T yynewbytes; \
434 yymemcpy ((char *) yyptr, (char *) (Stack), \
435 yysize * (YYSIZE_T) sizeof (Type)); \
436 Stack = &yyptr->Stack; \
437 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
438 yyptr += yynewbytes / sizeof (*yyptr); \
442 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
445 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
446 # define YYSIZE_T __SIZE_TYPE__
448 #if ! defined (YYSIZE_T) && defined (size_t)
449 # define YYSIZE_T size_t
451 #if ! defined (YYSIZE_T)
453 # include <cstddef> /* INFRINGES ON USER NAME SPACE */
454 # define YYSIZE_T std::size_t
457 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
458 # define YYSIZE_T size_t
462 #if ! defined (YYSIZE_T)
463 # define YYSIZE_T unsigned int
466 #define yyerrok (yyerrstatus = 0)
467 #define yyclearin (yychar = YYEMPTY)
470 #define YYACCEPT goto yyacceptlab
471 #define YYABORT goto yyabortlab
472 #define YYERROR goto yyerrlab1
473 /* Like YYERROR except do call yyerror. This remains here temporarily
474 to ease the transition to the new meaning of YYERROR, for GCC.
475 Once GCC version 2 has supplanted version 1, this can go. */
476 #define YYFAIL goto yyerrlab
477 #define YYRECOVERING() (!!yyerrstatus)
478 #define YYBACKUP(Token, Value) \
480 if (yychar == YYEMPTY && yylen == 1) \
484 yychar1 = YYTRANSLATE (yychar); \
490 yyerror ("syntax error: cannot back up"); \
496 #define YYERRCODE 256
499 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
502 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
503 first token. By default, to implement support for ranges, extend
504 its range to the last symbol. */
506 #ifndef YYLLOC_DEFAULT
507 # define YYLLOC_DEFAULT(Current, Rhs, N) \
508 Current.last_line = Rhs[N].last_line; \
509 Current.last_column = Rhs[N].last_column;
513 /* YYLEX -- calling `yylex' with the right arguments. */
518 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
520 # define YYLEX yylex (&yylval, &yylloc)
522 # else /* !YYLSP_NEEDED */
524 # define YYLEX yylex (&yylval, YYLEX_PARAM)
526 # define YYLEX yylex (&yylval)
528 # endif /* !YYLSP_NEEDED */
530 # define YYLEX yylex ()
534 /* Enable debugging if requested. */
539 # include <cstdio> /* INFRINGES ON USER NAME SPACE */
541 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
543 # define YYFPRINTF YYSTD (fprintf)
546 # define YYDPRINTF(Args) \
551 /* Nonzero means print parse trace. [The following comment makes no
552 sense to me. Could someone clarify it? --akim] Since this is
553 uninitialized, it does not stop multiple parsers from coexisting.
557 # define YYDPRINTF(Args)
558 #endif /* !YYDEBUG */
560 /* YYINITDEPTH -- initial size of the parser's stacks. */
562 # define YYINITDEPTH 200
565 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
566 if the built-in stack extension method is used).
568 Do not make this value too large; the results are undefined if
569 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
570 evaluated with infinite-precision integer arithmetic. */
577 # define YYMAXDEPTH 10000
580 #if ! defined (yyoverflow) && ! defined (yymemcpy)
581 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
582 # define yymemcpy __builtin_memcpy
583 # else /* not GNU C or C++ */
585 /* This is the most reliable way to avoid incompatibilities
586 in available built-in functions on various systems. */
588 # if defined (__STDC__) || defined (__cplusplus)
589 yymemcpy (char *yyto
, const char *yyfrom
, YYSIZE_T yycount
)
591 yymemcpy (yyto
, yyfrom
, yycount
)
597 register const char *yyf
= yyfrom
;
598 register char *yyt
= yyto
;
599 register YYSIZE_T yyi
= yycount
;
607 #ifdef YYERROR_VERBOSE
610 # if defined (__GLIBC__) && defined (_STRING_H)
611 # define yystrlen strlen
613 /* Return the length of YYSTR. */
615 # if defined (__STDC__) || defined (__cplusplus)
616 yystrlen (const char *yystr
)
622 register const char *yys
= yystr
;
624 while (*yys
++ != '\0')
627 return yys
- yystr
- 1;
633 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
634 # define yystpcpy stpcpy
636 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
639 # if defined (__STDC__) || defined (__cplusplus)
640 yystpcpy (char *yydest
, const char *yysrc
)
642 yystpcpy (yydest
, yysrc
)
647 register char *yyd
= yydest
;
648 register const char *yys
= yysrc
;
650 while ((*yyd
++ = *yys
++) != '\0')
659 #line 341 "/usr/share/bison/bison.simple"
662 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
663 into yyparse. The argument should have type void *.
664 It should actually point to an object.
665 Grammar actions can access the variable by casting it
666 to the proper pointer type. */
670 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
671 # define YYPARSE_PARAM_DECL
672 # else /* !__cplusplus */
673 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
674 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
675 # endif /* !__cplusplus */
676 #else /* !YYPARSE_PARAM */
677 # define YYPARSE_PARAM_ARG
678 # define YYPARSE_PARAM_DECL
679 #endif /* !YYPARSE_PARAM */
681 /* Prevent warning if -Wstrict-prototypes. */
683 # ifdef YYPARSE_PARAM
684 int yyparse (void *);
690 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
691 variables are global, or local to YYPARSE. */
693 #define YY_DECL_NON_LSP_VARIABLES \
694 /* The lookahead symbol. */ \
697 /* The semantic value of the lookahead symbol. */ \
700 /* Number of parse errors so far. */ \
704 # define YY_DECL_VARIABLES \
705 YY_DECL_NON_LSP_VARIABLES \
707 /* Location data for the lookahead symbol. */ \
710 # define YY_DECL_VARIABLES \
711 YY_DECL_NON_LSP_VARIABLES
715 /* If nonreentrant, generate the variables here. */
722 yyparse (YYPARSE_PARAM_ARG
)
725 /* If reentrant, generate the variables here. */
730 register int yystate
;
733 /* Number of tokens to shift before error messages enabled. */
735 /* Lookahead token as an internal (translated) token number. */
738 /* Three stacks and their tools:
739 `yyss': related to states,
740 `yyvs': related to semantic values,
741 `yyls': related to locations.
743 Refer to the stacks thru separate pointers, to allow yyoverflow
744 to reallocate them elsewhere. */
746 /* The state stack. */
747 short yyssa
[YYINITDEPTH
];
749 register short *yyssp
;
751 /* The semantic value stack. */
752 YYSTYPE yyvsa
[YYINITDEPTH
];
753 YYSTYPE
*yyvs
= yyvsa
;
754 register YYSTYPE
*yyvsp
;
757 /* The location stack. */
758 YYLTYPE yylsa
[YYINITDEPTH
];
759 YYLTYPE
*yyls
= yylsa
;
764 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
766 # define YYPOPSTACK (yyvsp--, yyssp--)
769 YYSIZE_T yystacksize
= YYINITDEPTH
;
772 /* The variables used to return semantic value and location from the
779 /* When reducing, the number of symbols on the RHS of the reduced
783 YYDPRINTF ((stderr
, "Starting parse\n"));
788 yychar
= YYEMPTY
; /* Cause a token to be read. */
790 /* Initialize stack pointers.
791 Waste one element of value and location stack
792 so that they stay on the same level as the state stack.
793 The wasted elements are never initialized. */
802 /*------------------------------------------------------------.
803 | yynewstate -- Push a new state, which is found in yystate. |
804 `------------------------------------------------------------*/
806 /* In all cases, when you get here, the value and location stacks
807 have just been pushed. so pushing a state here evens the stacks.
814 if (yyssp
>= yyss
+ yystacksize
- 1)
816 /* Get the current used size of the three stacks, in elements. */
817 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
821 /* Give user a chance to reallocate the stack. Use copies of
822 these so that the &'s don't force the real ones into
824 YYSTYPE
*yyvs1
= yyvs
;
827 /* Each stack pointer address is followed by the size of the
828 data in use in that stack, in bytes. */
830 YYLTYPE
*yyls1
= yyls
;
831 /* This used to be a conditional around just the two extra args,
832 but that might be undefined if yyoverflow is a macro. */
833 yyoverflow ("parser stack overflow",
834 &yyss1
, yysize
* sizeof (*yyssp
),
835 &yyvs1
, yysize
* sizeof (*yyvsp
),
836 &yyls1
, yysize
* sizeof (*yylsp
),
840 yyoverflow ("parser stack overflow",
841 &yyss1
, yysize
* sizeof (*yyssp
),
842 &yyvs1
, yysize
* sizeof (*yyvsp
),
848 #else /* no yyoverflow */
849 /* Extend the stack our own way. */
850 if (yystacksize
>= YYMAXDEPTH
)
853 if (yystacksize
> YYMAXDEPTH
)
854 yystacksize
= YYMAXDEPTH
;
858 union yyalloc
*yyptr
=
859 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
862 YYSTACK_RELOCATE (short, yyss
);
863 YYSTACK_RELOCATE (YYSTYPE
, yyvs
);
865 YYSTACK_RELOCATE (YYLTYPE
, yyls
);
867 # undef YYSTACK_RELOCATE
869 YYSTACK_FREE (yyss1
);
871 #endif /* no yyoverflow */
873 yyssp
= yyss
+ yysize
- 1;
874 yyvsp
= yyvs
+ yysize
- 1;
876 yylsp
= yyls
+ yysize
- 1;
879 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
880 (unsigned long int) yystacksize
));
882 if (yyssp
>= yyss
+ yystacksize
- 1)
886 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
896 /* Do appropriate processing given the current state. */
897 /* Read a lookahead token if we need one and don't already have one. */
900 /* First try to decide what to do without reference to lookahead token. */
902 yyn
= yypact
[yystate
];
906 /* Not known => get a lookahead token if don't already have one. */
908 /* yychar is either YYEMPTY or YYEOF
909 or a valid token in external form. */
911 if (yychar
== YYEMPTY
)
913 YYDPRINTF ((stderr
, "Reading a token: "));
917 /* Convert token to internal form (in yychar1) for indexing tables with */
919 if (yychar
<= 0) /* This means end of input. */
922 yychar
= YYEOF
; /* Don't call YYLEX any more */
924 YYDPRINTF ((stderr
, "Now at end of input.\n"));
928 yychar1
= YYTRANSLATE (yychar
);
931 /* We have to keep this `#if YYDEBUG', since we use variables
932 which are defined only if `YYDEBUG' is set. */
935 YYFPRINTF (stderr
, "Next token is %d (%s",
936 yychar
, yytname
[yychar1
]);
937 /* Give the individual parser a way to print the precise
938 meaning of a token, for further debugging info. */
940 YYPRINT (stderr
, yychar
, yylval
);
942 YYFPRINTF (stderr
, ")\n");
948 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
953 /* yyn is what to do for this token type in this state.
954 Negative => reduce, -yyn is rule number.
955 Positive => shift, yyn is new state.
956 New state is final state => don't bother to shift,
958 0, or most negative number => error. */
973 /* Shift the lookahead token. */
974 YYDPRINTF ((stderr
, "Shifting token %d (%s), ",
975 yychar
, yytname
[yychar1
]));
977 /* Discard the token being shifted unless it is eof. */
986 /* Count tokens shifted since error; after three, turn off error
995 /*-----------------------------------------------------------.
996 | yydefault -- do the default action for the current state. |
997 `-----------------------------------------------------------*/
999 yyn
= yydefact
[yystate
];
1005 /*-----------------------------.
1006 | yyreduce -- Do a reduction. |
1007 `-----------------------------*/
1009 /* yyn is the number of a rule to reduce with. */
1012 /* If YYLEN is nonzero, implement the default value of the action:
1015 Otherwise, the following line sets YYVAL to the semantic value of
1016 the lookahead token. This behavior is undocumented and Bison
1017 users should not rely upon it. Assigning to YYVAL
1018 unconditionally makes the parser a bit smaller, and it avoids a
1019 GCC warning that YYVAL may be used uninitialized. */
1020 yyval
= yyvsp
[1-yylen
];
1023 /* Similarly for the default location. Let the user run additional
1024 commands if for instance locations are ranges. */
1025 yyloc
= yylsp
[1-yylen
];
1026 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);
1030 /* We have to keep this `#if YYDEBUG', since we use variables which
1031 are defined only if `YYDEBUG' is set. */
1036 YYFPRINTF (stderr
, "Reducing via rule %d (line %d), ",
1039 /* Print the symbols being reduced, and their result. */
1040 for (yyi
= yyprhs
[yyn
]; yyrhs
[yyi
] > 0; yyi
++)
1041 YYFPRINTF (stderr
, "%s ", yytname
[yyrhs
[yyi
]]);
1042 YYFPRINTF (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
1050 { expression_value
= yyvsp
[0].integer
.value
; }
1055 pedwarn ("comma operator in operand of `#if'");
1056 yyval
.integer
= yyvsp
[0].integer
; }
1060 { yyval
.integer
.value
= - yyvsp
[0].integer
.value
;
1061 if ((yyval
.integer
.value
& yyvsp
[0].integer
.value
) < 0 && ! yyvsp
[0].integer
.unsignedp
)
1062 integer_overflow ();
1063 yyval
.integer
.unsignedp
= yyvsp
[0].integer
.unsignedp
; }
1067 { yyval
.integer
.value
= ! yyvsp
[0].integer
.value
;
1068 yyval
.integer
.unsignedp
= 0; }
1072 { yyval
.integer
= yyvsp
[0].integer
; }
1076 { yyval
.integer
.value
= ~ yyvsp
[0].integer
.value
;
1077 yyval
.integer
.unsignedp
= yyvsp
[0].integer
.unsignedp
; }
1081 { yyval
.integer
.value
= check_assertion (yyvsp
[0].name
.address
, yyvsp
[0].name
.length
,
1083 yyval
.integer
.unsignedp
= 0; }
1087 { keyword_parsing
= 1; }
1091 { yyval
.integer
.value
= check_assertion (yyvsp
[-4].name
.address
, yyvsp
[-4].name
.length
,
1092 1, yyvsp
[-1].keywords
);
1093 keyword_parsing
= 0;
1094 yyval
.integer
.unsignedp
= 0; }
1098 { yyval
.integer
= yyvsp
[-1].integer
; }
1102 { yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
1103 if (yyval
.integer
.unsignedp
)
1104 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
* yyvsp
[0].integer
.value
;
1107 yyval
.integer
.value
= yyvsp
[-2].integer
.value
* yyvsp
[0].integer
.value
;
1108 if (yyvsp
[-2].integer
.value
1109 && (yyval
.integer
.value
/ yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
1110 || (yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0))
1111 integer_overflow ();
1116 { if (yyvsp
[0].integer
.value
== 0)
1118 error ("division by zero in #if");
1119 yyvsp
[0].integer
.value
= 1;
1121 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
1122 if (yyval
.integer
.unsignedp
)
1123 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
/ yyvsp
[0].integer
.value
;
1126 yyval
.integer
.value
= yyvsp
[-2].integer
.value
/ yyvsp
[0].integer
.value
;
1127 if ((yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0)
1128 integer_overflow ();
1133 { if (yyvsp
[0].integer
.value
== 0)
1135 error ("division by zero in #if");
1136 yyvsp
[0].integer
.value
= 1;
1138 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
1139 if (yyval
.integer
.unsignedp
)
1140 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
% yyvsp
[0].integer
.value
;
1142 yyval
.integer
.value
= yyvsp
[-2].integer
.value
% yyvsp
[0].integer
.value
; }
1146 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
+ yyvsp
[0].integer
.value
;
1147 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
1148 if (! yyval
.integer
.unsignedp
1149 && ! possible_sum_sign (yyvsp
[-2].integer
.value
, yyvsp
[0].integer
.value
,
1150 yyval
.integer
.value
))
1151 integer_overflow (); }
1155 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
- yyvsp
[0].integer
.value
;
1156 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
1157 if (! yyval
.integer
.unsignedp
1158 && ! possible_sum_sign (yyval
.integer
.value
, yyvsp
[0].integer
.value
,
1159 yyvsp
[-2].integer
.value
))
1160 integer_overflow (); }
1164 { yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
;
1165 if (yyvsp
[0].integer
.value
< 0 && ! yyvsp
[0].integer
.unsignedp
)
1166 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
1168 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); }
1172 { yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
;
1173 if (yyvsp
[0].integer
.value
< 0 && ! yyvsp
[0].integer
.unsignedp
)
1174 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
1176 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); }
1180 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
== yyvsp
[0].integer
.value
);
1181 yyval
.integer
.unsignedp
= 0; }
1185 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
);
1186 yyval
.integer
.unsignedp
= 0; }
1190 { yyval
.integer
.unsignedp
= 0;
1191 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
1192 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
<= yyvsp
[0].integer
.value
;
1194 yyval
.integer
.value
= yyvsp
[-2].integer
.value
<= yyvsp
[0].integer
.value
; }
1198 { yyval
.integer
.unsignedp
= 0;
1199 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
1200 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
>= yyvsp
[0].integer
.value
;
1202 yyval
.integer
.value
= yyvsp
[-2].integer
.value
>= yyvsp
[0].integer
.value
; }
1206 { yyval
.integer
.unsignedp
= 0;
1207 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
1208 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
< yyvsp
[0].integer
.value
;
1210 yyval
.integer
.value
= yyvsp
[-2].integer
.value
< yyvsp
[0].integer
.value
; }
1214 { yyval
.integer
.unsignedp
= 0;
1215 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
1216 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
> yyvsp
[0].integer
.value
;
1218 yyval
.integer
.value
= yyvsp
[-2].integer
.value
> yyvsp
[0].integer
.value
; }
1222 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
;
1223 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; }
1227 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
^ yyvsp
[0].integer
.value
;
1228 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; }
1232 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
| yyvsp
[0].integer
.value
;
1233 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; }
1237 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
&& yyvsp
[0].integer
.value
);
1238 yyval
.integer
.unsignedp
= 0; }
1242 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
|| yyvsp
[0].integer
.value
);
1243 yyval
.integer
.unsignedp
= 0; }
1247 { yyval
.integer
.value
= yyvsp
[-4].integer
.value
? yyvsp
[-2].integer
.value
: yyvsp
[0].integer
.value
;
1248 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; }
1252 { yyval
.integer
= yylval
.integer
; }
1256 { yyval
.integer
= yylval
.integer
; }
1260 { yyval
.integer
.value
= 0;
1261 yyval
.integer
.unsignedp
= 0; }
1265 { yyval
.keywords
= 0; }
1269 { struct arglist
*temp
;
1270 yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1271 yyval
.keywords
->next
= yyvsp
[-2].keywords
;
1272 yyval
.keywords
->name
= (U_CHAR
*) "(";
1273 yyval
.keywords
->length
= 1;
1274 temp
= yyval
.keywords
;
1275 while (temp
!= 0 && temp
->next
!= 0)
1277 temp
->next
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1278 temp
->next
->next
= yyvsp
[0].keywords
;
1279 temp
->next
->name
= (U_CHAR
*) ")";
1280 temp
->next
->length
= 1; }
1284 { yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1285 yyval
.keywords
->name
= yyvsp
[-1].name
.address
;
1286 yyval
.keywords
->length
= yyvsp
[-1].name
.length
;
1287 yyval
.keywords
->next
= yyvsp
[0].keywords
; }
1291 #line 727 "/usr/share/bison/bison.simple"
1303 short *yyssp1
= yyss
- 1;
1304 YYFPRINTF (stderr
, "state stack now");
1305 while (yyssp1
!= yyssp
)
1306 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1307 YYFPRINTF (stderr
, "\n");
1316 /* Now `shift' the result of the reduction. Determine what state
1317 that goes to, based on the state we popped back to and the rule
1318 number reduced by. */
1322 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1323 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1324 yystate
= yytable
[yystate
];
1326 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1331 /*------------------------------------.
1332 | yyerrlab -- here on detecting error |
1333 `------------------------------------*/
1335 /* If not already recovering from an error, report this error. */
1340 #ifdef YYERROR_VERBOSE
1341 yyn
= yypact
[yystate
];
1343 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1345 YYSIZE_T yysize
= 0;
1350 /* Start YYX at -YYN if negative to avoid negative indexes in
1352 for (yyx
= yyn
< 0 ? -yyn
: 0;
1353 yyx
< (int) (sizeof (yytname
) / sizeof (char *)); yyx
++)
1354 if (yycheck
[yyx
+ yyn
] == yyx
)
1355 yysize
+= yystrlen (yytname
[yyx
]) + 15, yycount
++;
1356 yysize
+= yystrlen ("parse error, unexpected ") + 1;
1357 yysize
+= yystrlen (yytname
[YYTRANSLATE (yychar
)]);
1358 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
1361 char *yyp
= yystpcpy (yymsg
, "parse error, unexpected ");
1362 yyp
= yystpcpy (yyp
, yytname
[YYTRANSLATE (yychar
)]);
1367 for (yyx
= yyn
< 0 ? -yyn
: 0;
1368 yyx
< (int) (sizeof (yytname
) / sizeof (char *));
1370 if (yycheck
[yyx
+ yyn
] == yyx
)
1372 const char *yyq
= ! yycount
? ", expecting " : " or ";
1373 yyp
= yystpcpy (yyp
, yyq
);
1374 yyp
= yystpcpy (yyp
, yytname
[yyx
]);
1379 YYSTACK_FREE (yymsg
);
1382 yyerror ("parse error; also virtual memory exhausted");
1385 #endif /* defined (YYERROR_VERBOSE) */
1386 yyerror ("parse error");
1391 /*--------------------------------------------------.
1392 | yyerrlab1 -- error raised explicitly by an action |
1393 `--------------------------------------------------*/
1395 if (yyerrstatus
== 3)
1397 /* If just tried and failed to reuse lookahead token after an
1398 error, discard it. */
1400 /* return failure if at end of input */
1401 if (yychar
== YYEOF
)
1403 YYDPRINTF ((stderr
, "Discarding token %d (%s).\n",
1404 yychar
, yytname
[yychar1
]));
1408 /* Else will try to reuse lookahead token after shifting the error
1411 yyerrstatus
= 3; /* Each real token shifted decrements this */
1416 /*-------------------------------------------------------------------.
1417 | yyerrdefault -- current state does not do anything special for the |
1419 `-------------------------------------------------------------------*/
1422 /* This is wrong; only states that explicitly want error tokens
1423 should shift them. */
1425 /* If its default is to accept any token, ok. Otherwise pop it. */
1426 yyn
= yydefact
[yystate
];
1432 /*---------------------------------------------------------------.
1433 | yyerrpop -- pop the current state because it cannot handle the |
1435 `---------------------------------------------------------------*/
1448 short *yyssp1
= yyss
- 1;
1449 YYFPRINTF (stderr
, "Error: state stack now");
1450 while (yyssp1
!= yyssp
)
1451 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1452 YYFPRINTF (stderr
, "\n");
1460 yyn
= yypact
[yystate
];
1465 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1482 YYDPRINTF ((stderr
, "Shifting error token, "));
1493 /*-------------------------------------.
1494 | yyacceptlab -- YYACCEPT comes here. |
1495 `-------------------------------------*/
1500 /*-----------------------------------.
1501 | yyabortlab -- YYABORT comes here. |
1502 `-----------------------------------*/
1507 /*---------------------------------------------.
1508 | yyoverflowab -- parser overflow comes here. |
1509 `---------------------------------------------*/
1511 yyerror ("parser stack overflow");
1518 YYSTACK_FREE (yyss
);
1525 /* During parsing of a C expression, the pointer to the next character
1526 is in this variable. */
1528 static char *lexptr
;
1530 /* Take care of parsing a number (anything that starts with a digit).
1531 Set yylval and return the token type; update lexptr.
1532 LEN is the number of characters in it. */
1534 /* maybe needs to actually deal with floating point numbers */
1540 register char *p
= lexptr
;
1542 register unsigned long n
= 0, nd
, ULONG_MAX_over_base
;
1543 register int base
= 10;
1544 register int len
= olen
;
1545 register int overflow
= 0;
1546 register int digit
, largest_digit
= 0;
1549 for (c
= 0; c
< len
; c
++)
1551 /* It's a float since it contains a point. */
1552 yyerror ("floating point numbers not allowed in #if expressions");
1556 yylval
.integer
.unsignedp
= 0;
1558 if (len
>= 3 && (!strncmp (p
, "0x", 2) || !strncmp (p
, "0X", 2))) {
1566 ULONG_MAX_over_base
= (unsigned long) -1 / base
;
1568 for (; len
> 0; len
--) {
1571 if (c
>= '0' && c
<= '9')
1573 else if (base
== 16 && c
>= 'a' && c
<= 'f')
1574 digit
= c
- 'a' + 10;
1575 else if (base
== 16 && c
>= 'A' && c
<= 'F')
1576 digit
= c
- 'A' + 10;
1578 /* `l' means long, and `u' means unsigned. */
1580 if (c
== 'l' || c
== 'L')
1583 yyerror ("two `l's in integer constant");
1586 else if (c
== 'u' || c
== 'U')
1588 if (yylval
.integer
.unsignedp
)
1589 yyerror ("two `u's in integer constant");
1590 yylval
.integer
.unsignedp
= 1;
1599 /* Don't look for any more digits after the suffixes. */
1602 if (largest_digit
< digit
)
1603 largest_digit
= digit
;
1604 nd
= n
* base
+ digit
;
1605 overflow
|= ULONG_MAX_over_base
< n
| nd
< n
;
1610 yyerror ("Invalid number in #if expression");
1614 if (base
<= largest_digit
)
1615 warning ("integer constant contains digits beyond the radix");
1618 warning ("integer constant out of range");
1620 /* If too big to be signed, consider it unsigned. */
1621 if ((long) n
< 0 && ! yylval
.integer
.unsignedp
)
1624 warning ("integer constant is so large that it is unsigned");
1625 yylval
.integer
.unsignedp
= 1;
1629 yylval
.integer
.value
= n
;
1638 static struct token tokentab2
[] = {
1652 /* Read one token, getting characters through lexptr. */
1658 register int namelen
;
1659 register unsigned char *tokstart
;
1660 register struct token
*toktab
;
1665 tokstart
= (unsigned char *) lexptr
;
1667 /* See if it is a special token of length 2. */
1668 if (! keyword_parsing
)
1669 for (toktab
= tokentab2
; toktab
->operator != NULL
; toktab
++)
1670 if (c
== *toktab
->operator && tokstart
[1] == toktab
->operator[1]) {
1672 if (toktab
->token
== ERROR
)
1674 char *buf
= (char *) alloca (40);
1675 sprintf (buf
, "`%s' not allowed in operand of `#if'", toktab
->operator);
1678 return toktab
->token
;
1693 /* Capital L may start a wide-string or wide-character constant. */
1694 if (lexptr
[1] == '\'')
1700 if (lexptr
[1] == '"')
1704 goto string_constant
;
1712 if (keyword_parsing
) {
1713 char *start_ptr
= lexptr
- 1;
1717 c
= parse_escape (&lexptr
);
1721 yylval
.name
.address
= tokstart
;
1722 yylval
.name
.length
= lexptr
- start_ptr
;
1726 /* This code for reading a character constant
1727 handles multicharacter constants and wide characters.
1728 It is mostly copied from c-lex.c. */
1730 register int result
= 0;
1731 register num_chars
= 0;
1732 unsigned width
= CHAR_TYPE_SIZE
;
1738 width
= WCHAR_TYPE_SIZE
;
1739 #ifdef MULTIBYTE_CHARS
1740 max_chars
= MB_CUR_MAX
;
1746 max_chars
= LONG_TYPE_SIZE
/ width
;
1748 token_buffer
= (char *) alloca (max_chars
+ 1);
1754 if (c
== '\'' || c
== EOF
)
1759 c
= parse_escape (&lexptr
);
1760 if (width
< HOST_BITS_PER_INT
1761 && (unsigned) c
>= (1 << width
))
1762 pedwarn ("escape sequence out of range for character");
1767 /* Merge character into result; ignore excess chars. */
1768 if (num_chars
< max_chars
+ 1)
1770 if (width
< HOST_BITS_PER_INT
)
1771 result
= (result
<< width
) | (c
& ((1 << width
) - 1));
1774 token_buffer
[num_chars
- 1] = c
;
1778 token_buffer
[num_chars
] = 0;
1781 error ("malformatted character constant");
1782 else if (num_chars
== 0)
1783 error ("empty character constant");
1784 else if (num_chars
> max_chars
)
1786 num_chars
= max_chars
;
1787 error ("character constant too long");
1789 else if (num_chars
!= 1 && ! traditional
)
1790 warning ("multi-character character constant");
1792 /* If char type is signed, sign-extend the constant. */
1795 int num_bits
= num_chars
* width
;
1797 if (lookup ("__CHAR_UNSIGNED__", sizeof ("__CHAR_UNSIGNED__")-1, -1)
1798 || ((result
>> (num_bits
- 1)) & 1) == 0)
1799 yylval
.integer
.value
1800 = result
& ((unsigned long) ~0 >> (HOST_BITS_PER_LONG
- num_bits
));
1802 yylval
.integer
.value
1803 = result
| ~((unsigned long) ~0 >> (HOST_BITS_PER_LONG
- num_bits
));
1807 #ifdef MULTIBYTE_CHARS
1808 /* Set the initial shift state and convert the next sequence. */
1810 /* In all locales L'\0' is zero and mbtowc will return zero,
1813 || (num_chars
== 1 && token_buffer
[0] != '\0'))
1816 (void) mbtowc (NULL_PTR
, NULL_PTR
, 0);
1817 if (mbtowc (& wc
, token_buffer
, num_chars
) == num_chars
)
1820 warning ("Ignoring invalid multibyte character");
1823 yylval
.integer
.value
= result
;
1827 /* This is always a signed type. */
1828 yylval
.integer
.unsignedp
= 0;
1832 /* some of these chars are invalid in constant expressions;
1833 maybe do something about them later */
1857 if (keyword_parsing
)
1866 if (keyword_parsing
) {
1867 char *start_ptr
= lexptr
;
1872 c
= parse_escape (&lexptr
);
1876 yylval
.name
.address
= tokstart
;
1877 yylval
.name
.length
= lexptr
- start_ptr
;
1880 yyerror ("string constants not allowed in #if expressions");
1884 if (c
>= '0' && c
<= '9' && !keyword_parsing
) {
1887 c
= tokstart
[namelen
], is_idchar
[c
] || c
== '.';
1890 return parse_number (namelen
);
1893 /* It is a name. See how long it is. */
1895 if (keyword_parsing
) {
1896 for (namelen
= 0;; namelen
++) {
1897 if (is_hor_space
[tokstart
[namelen
]])
1899 if (tokstart
[namelen
] == '(' || tokstart
[namelen
] == ')')
1901 if (tokstart
[namelen
] == '"' || tokstart
[namelen
] == '\'')
1905 if (!is_idstart
[c
]) {
1906 yyerror ("Invalid token in expression");
1910 for (namelen
= 0; is_idchar
[tokstart
[namelen
]]; namelen
++)
1915 yylval
.name
.address
= tokstart
;
1916 yylval
.name
.length
= namelen
;
1921 /* Parse a C escape sequence. STRING_PTR points to a variable
1922 containing a pointer to the string to parse. That pointer
1923 is updated past the characters we use. The value of the
1924 escape sequence is returned.
1926 A negative value means the sequence \ newline was seen,
1927 which is supposed to be equivalent to nothing at all.
1929 If \ is followed by a null character, we return a negative
1930 value and leave the string pointer pointing at the null character.
1932 If \ is followed by 000, we return 0 and leave the string pointer
1933 after the zeros. A value of 0 does not mean end of string. */
1936 parse_escape (string_ptr
)
1939 register int c
= *(*string_ptr
)++;
1949 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c
);
1954 return TARGET_NEWLINE
;
1976 register int i
= c
- '0';
1977 register int count
= 0;
1980 c
= *(*string_ptr
)++;
1981 if (c
>= '0' && c
<= '7')
1982 i
= (i
<< 3) + c
- '0';
1989 if ((i
& ~((1 << CHAR_TYPE_SIZE
) - 1)) != 0)
1991 i
&= (1 << CHAR_TYPE_SIZE
) - 1;
1992 warning ("octal character constant does not fit in a byte");
1998 register unsigned i
= 0, overflow
= 0, digits_found
= 0, digit
;
2001 c
= *(*string_ptr
)++;
2002 if (c
>= '0' && c
<= '9')
2004 else if (c
>= 'a' && c
<= 'f')
2005 digit
= c
- 'a' + 10;
2006 else if (c
>= 'A' && c
<= 'F')
2007 digit
= c
- 'A' + 10;
2013 overflow
|= i
^ (i
<< 4 >> 4);
2014 i
= (i
<< 4) + digit
;
2018 yyerror ("\\x used with no following hex digits");
2019 if (overflow
| (i
& ~((1 << BITS_PER_UNIT
) - 1)))
2021 i
&= (1 << BITS_PER_UNIT
) - 1;
2022 warning ("hex character constant does not fit in a byte");
2036 longjmp (parse_return_error
, 1);
2043 pedwarn ("integer overflow in preprocessor expression");
2051 if (b
>= HOST_BITS_PER_LONG
)
2053 if (! a
->unsignedp
&& a
->value
!= 0)
2054 integer_overflow ();
2057 else if (a
->unsignedp
)
2058 return (unsigned long) a
->value
<< b
;
2061 long l
= a
->value
<< b
;
2062 if (l
>> b
!= a
->value
)
2063 integer_overflow ();
2073 if (b
>= HOST_BITS_PER_LONG
)
2074 return a
->unsignedp
? 0 : a
->value
>> (HOST_BITS_PER_LONG
- 1);
2075 else if (a
->unsignedp
)
2076 return (unsigned long) a
->value
>> b
;
2078 return a
->value
>> b
;
2081 /* This page contains the entry point to this file. */
2083 /* Parse STRING as an expression, and complain if this fails
2084 to use up all of the contents of STRING. */
2085 /* We do not support C comments. They should be removed before
2086 this function is called. */
2089 parse_c_expression (string
)
2094 if (lexptr
== 0 || *lexptr
== 0) {
2095 error ("empty #if expression");
2096 return 0; /* don't include the #if group */
2099 /* if there is some sort of scanning error, just return 0 and assume
2100 the parsing routine has printed an error message somewhere.
2101 there is surely a better thing to do than this. */
2102 if (setjmp (parse_return_error
))
2106 return 0; /* actually this is never reached
2107 the way things stand. */
2109 error ("Junk after end of expression.");
2111 return expression_value
; /* set by yyparse () */
2114 #ifdef TEST_EXP_READER
2117 /* Main program for testing purposes. */
2127 initialize_random_junk ();
2130 printf ("enter expression: ");
2132 while ((buf
[n
] = getchar ()) != '\n' && buf
[n
] != EOF
)
2137 printf ("parser returned %d\n", parse_c_expression (buf
));
2143 /* table to tell if char can be part of a C identifier. */
2144 unsigned char is_idchar
[256];
2145 /* table to tell if char can be first char of a c identifier. */
2146 unsigned char is_idstart
[256];
2147 /* table to tell if c is horizontal space. isspace () thinks that
2148 newline is space; this is not a good idea for this program. */
2149 char is_hor_space
[256];
2152 * initialize random junk in the hash table and maybe other places
2154 initialize_random_junk ()
2159 * Set up is_idchar and is_idstart tables. These should be
2160 * faster than saying (is_alpha (c) || c == '_'), etc.
2161 * Must do set up these things before calling any routines tthat
2164 for (i
= 'a'; i
<= 'z'; i
++) {
2165 ++is_idchar
[i
- 'a' + 'A'];
2167 ++is_idstart
[i
- 'a' + 'A'];
2170 for (i
= '0'; i
<= '9'; i
++)
2174 #if DOLLARS_IN_IDENTIFIERS
2179 /* horizontal space table */
2180 ++is_hor_space
[' '];
2181 ++is_hor_space
['\t'];
2186 printf ("error: %s\n", msg
);
2191 printf ("warning: %s\n", msg
);
2195 lookup (name
, len
, hash
)
2200 return (DEFAULT_SIGNED_CHAR
) ? 0 : ((struct hashnode
*) -1);