]>
code.delx.au - gnu-emacs/blob - test/etags/y-src/cccp.c
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, 2016 Free Software
326 This program is free software; you can redistribute it and/or modify
327 it under the terms of the GNU General Public License as published by
328 the Free Software Foundation; either version 2, or (at your option)
331 This program is distributed in the hope that it will be useful,
332 but WITHOUT ANY WARRANTY; without even the implied warranty of
333 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
334 GNU General Public License for more details.
336 You should have received a copy of the GNU General Public License
337 along with this program; if not, write to the Free Software
338 Foundation, Inc., 59 Temple Place - Suite 330,
339 Boston, MA 02111-1307, USA. */
341 /* As a special exception, when this file is copied by Bison into a
342 Bison output file, you may use that output file without restriction.
343 This special exception was added by the Free Software Foundation
344 in version 1.24 of Bison. */
346 /* This is the parser code that is written into each bison parser when
347 the %semantic_parser declaration is not specified in the grammar.
348 It was written by Richard Stallman by simplifying the hairy parser
349 used when %semantic_parser is specified. */
351 /* All symbols defined below should begin with yy or YY, to avoid
352 infringing on user name space. This should be done even for local
353 variables, as they might otherwise be expanded by user macros.
354 There are some unavoidable exceptions within include files to
355 define necessary library symbols; they are noted "INFRINGES ON
356 USER NAME SPACE" below. */
359 # define YYSTD(x) std::x
364 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
366 /* The parser invokes alloca or malloc; define the necessary symbols. */
368 # if YYSTACK_USE_ALLOCA
369 # define YYSTACK_ALLOC alloca
370 # define YYSIZE_T YYSTD (size_t)
372 # ifndef YYSTACK_USE_ALLOCA
373 # if defined (alloca) || defined (_ALLOCA_H)
374 # define YYSTACK_ALLOC alloca
375 # define YYSIZE_T YYSTD (size_t)
378 # define YYSTACK_ALLOC __builtin_alloca
384 # ifdef YYSTACK_ALLOC
385 /* Pacify GCC's `empty if-body' warning. */
386 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
389 # include <cstdlib> /* INFRINGES ON USER NAME SPACE */
390 # define YYSIZE_T std::size_t
393 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
394 # define YYSIZE_T size_t
397 # define YYSTACK_ALLOC YYSTD (malloc)
398 # define YYSTACK_FREE YYSTD (free)
401 /* A type that is properly aligned for any stack member. */
411 /* The size of the maximum gap between one aligned stack and the next. */
412 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
414 /* The size of an array large to enough to hold all stacks, each with
417 # define YYSTACK_BYTES(N) \
418 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
419 + 2 * YYSTACK_GAP_MAX)
421 # define YYSTACK_BYTES(N) \
422 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
426 /* Relocate the TYPE STACK from its old location to the new one. The
427 local variables YYSIZE and YYSTACKSIZE give the old and new number of
428 elements in the stack, and YYPTR gives the new location of the
429 stack. Advance YYPTR to a properly aligned location for the next
431 # define YYSTACK_RELOCATE(Type, Stack) \
434 YYSIZE_T yynewbytes; \
435 yymemcpy ((char *) yyptr, (char *) (Stack), \
436 yysize * (YYSIZE_T) sizeof (Type)); \
437 Stack = &yyptr->Stack; \
438 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
439 yyptr += yynewbytes / sizeof (*yyptr); \
443 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
446 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
447 # define YYSIZE_T __SIZE_TYPE__
449 #if ! defined (YYSIZE_T) && defined (size_t)
450 # define YYSIZE_T size_t
452 #if ! defined (YYSIZE_T)
454 # include <cstddef> /* INFRINGES ON USER NAME SPACE */
455 # define YYSIZE_T std::size_t
458 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
459 # define YYSIZE_T size_t
463 #if ! defined (YYSIZE_T)
464 # define YYSIZE_T unsigned int
467 #define yyerrok (yyerrstatus = 0)
468 #define yyclearin (yychar = YYEMPTY)
471 #define YYACCEPT goto yyacceptlab
472 #define YYABORT goto yyabortlab
473 #define YYERROR goto yyerrlab1
474 /* Like YYERROR except do call yyerror. This remains here temporarily
475 to ease the transition to the new meaning of YYERROR, for GCC.
476 Once GCC version 2 has supplanted version 1, this can go. */
477 #define YYFAIL goto yyerrlab
478 #define YYRECOVERING() (!!yyerrstatus)
479 #define YYBACKUP(Token, Value) \
481 if (yychar == YYEMPTY && yylen == 1) \
485 yychar1 = YYTRANSLATE (yychar); \
491 yyerror ("syntax error: cannot back up"); \
497 #define YYERRCODE 256
500 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
503 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
504 first token. By default, to implement support for ranges, extend
505 its range to the last symbol. */
507 #ifndef YYLLOC_DEFAULT
508 # define YYLLOC_DEFAULT(Current, Rhs, N) \
509 Current.last_line = Rhs[N].last_line; \
510 Current.last_column = Rhs[N].last_column;
514 /* YYLEX -- calling `yylex' with the right arguments. */
519 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
521 # define YYLEX yylex (&yylval, &yylloc)
523 # else /* !YYLSP_NEEDED */
525 # define YYLEX yylex (&yylval, YYLEX_PARAM)
527 # define YYLEX yylex (&yylval)
529 # endif /* !YYLSP_NEEDED */
531 # define YYLEX yylex ()
535 /* Enable debugging if requested. */
540 # include <cstdio> /* INFRINGES ON USER NAME SPACE */
542 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
544 # define YYFPRINTF YYSTD (fprintf)
547 # define YYDPRINTF(Args) \
552 /* Nonzero means print parse trace. [The following comment makes no
553 sense to me. Could someone clarify it? --akim] Since this is
554 uninitialized, it does not stop multiple parsers from coexisting.
558 # define YYDPRINTF(Args)
559 #endif /* !YYDEBUG */
561 /* YYINITDEPTH -- initial size of the parser's stacks. */
563 # define YYINITDEPTH 200
566 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
567 if the built-in stack extension method is used).
569 Do not make this value too large; the results are undefined if
570 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
571 evaluated with infinite-precision integer arithmetic. */
578 # define YYMAXDEPTH 10000
581 #if ! defined (yyoverflow) && ! defined (yymemcpy)
582 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
583 # define yymemcpy __builtin_memcpy
584 # else /* not GNU C or C++ */
586 /* This is the most reliable way to avoid incompatibilities
587 in available built-in functions on various systems. */
589 # if defined (__STDC__) || defined (__cplusplus)
590 yymemcpy (char *yyto
, const char *yyfrom
, YYSIZE_T yycount
)
592 yymemcpy (yyto
, yyfrom
, yycount
)
598 register const char *yyf
= yyfrom
;
599 register char *yyt
= yyto
;
600 register YYSIZE_T yyi
= yycount
;
608 #ifdef YYERROR_VERBOSE
611 # if defined (__GLIBC__) && defined (_STRING_H)
612 # define yystrlen strlen
614 /* Return the length of YYSTR. */
616 # if defined (__STDC__) || defined (__cplusplus)
617 yystrlen (const char *yystr
)
623 register const char *yys
= yystr
;
625 while (*yys
++ != '\0')
628 return yys
- yystr
- 1;
634 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
635 # define yystpcpy stpcpy
637 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
640 # if defined (__STDC__) || defined (__cplusplus)
641 yystpcpy (char *yydest
, const char *yysrc
)
643 yystpcpy (yydest
, yysrc
)
648 register char *yyd
= yydest
;
649 register const char *yys
= yysrc
;
651 while ((*yyd
++ = *yys
++) != '\0')
660 #line 341 "/usr/share/bison/bison.simple"
663 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
664 into yyparse. The argument should have type void *.
665 It should actually point to an object.
666 Grammar actions can access the variable by casting it
667 to the proper pointer type. */
671 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
672 # define YYPARSE_PARAM_DECL
673 # else /* !__cplusplus */
674 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
675 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
676 # endif /* !__cplusplus */
677 #else /* !YYPARSE_PARAM */
678 # define YYPARSE_PARAM_ARG
679 # define YYPARSE_PARAM_DECL
680 #endif /* !YYPARSE_PARAM */
682 /* Prevent warning if -Wstrict-prototypes. */
684 # ifdef YYPARSE_PARAM
685 int yyparse (void *);
691 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
692 variables are global, or local to YYPARSE. */
694 #define YY_DECL_NON_LSP_VARIABLES \
695 /* The lookahead symbol. */ \
698 /* The semantic value of the lookahead symbol. */ \
701 /* Number of parse errors so far. */ \
705 # define YY_DECL_VARIABLES \
706 YY_DECL_NON_LSP_VARIABLES \
708 /* Location data for the lookahead symbol. */ \
711 # define YY_DECL_VARIABLES \
712 YY_DECL_NON_LSP_VARIABLES
716 /* If nonreentrant, generate the variables here. */
723 yyparse (YYPARSE_PARAM_ARG
)
726 /* If reentrant, generate the variables here. */
731 register int yystate
;
734 /* Number of tokens to shift before error messages enabled. */
736 /* Lookahead token as an internal (translated) token number. */
739 /* Three stacks and their tools:
740 `yyss': related to states,
741 `yyvs': related to semantic values,
742 `yyls': related to locations.
744 Refer to the stacks thru separate pointers, to allow yyoverflow
745 to reallocate them elsewhere. */
747 /* The state stack. */
748 short yyssa
[YYINITDEPTH
];
750 register short *yyssp
;
752 /* The semantic value stack. */
753 YYSTYPE yyvsa
[YYINITDEPTH
];
754 YYSTYPE
*yyvs
= yyvsa
;
755 register YYSTYPE
*yyvsp
;
758 /* The location stack. */
759 YYLTYPE yylsa
[YYINITDEPTH
];
760 YYLTYPE
*yyls
= yylsa
;
765 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
767 # define YYPOPSTACK (yyvsp--, yyssp--)
770 YYSIZE_T yystacksize
= YYINITDEPTH
;
773 /* The variables used to return semantic value and location from the
780 /* When reducing, the number of symbols on the RHS of the reduced
784 YYDPRINTF ((stderr
, "Starting parse\n"));
789 yychar
= YYEMPTY
; /* Cause a token to be read. */
791 /* Initialize stack pointers.
792 Waste one element of value and location stack
793 so that they stay on the same level as the state stack.
794 The wasted elements are never initialized. */
803 /*------------------------------------------------------------.
804 | yynewstate -- Push a new state, which is found in yystate. |
805 `------------------------------------------------------------*/
807 /* In all cases, when you get here, the value and location stacks
808 have just been pushed. so pushing a state here evens the stacks.
815 if (yyssp
>= yyss
+ yystacksize
- 1)
817 /* Get the current used size of the three stacks, in elements. */
818 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
822 /* Give user a chance to reallocate the stack. Use copies of
823 these so that the &'s don't force the real ones into
825 YYSTYPE
*yyvs1
= yyvs
;
828 /* Each stack pointer address is followed by the size of the
829 data in use in that stack, in bytes. */
831 YYLTYPE
*yyls1
= yyls
;
832 /* This used to be a conditional around just the two extra args,
833 but that might be undefined if yyoverflow is a macro. */
834 yyoverflow ("parser stack overflow",
835 &yyss1
, yysize
* sizeof (*yyssp
),
836 &yyvs1
, yysize
* sizeof (*yyvsp
),
837 &yyls1
, yysize
* sizeof (*yylsp
),
841 yyoverflow ("parser stack overflow",
842 &yyss1
, yysize
* sizeof (*yyssp
),
843 &yyvs1
, yysize
* sizeof (*yyvsp
),
849 #else /* no yyoverflow */
850 /* Extend the stack our own way. */
851 if (yystacksize
>= YYMAXDEPTH
)
854 if (yystacksize
> YYMAXDEPTH
)
855 yystacksize
= YYMAXDEPTH
;
859 union yyalloc
*yyptr
=
860 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
863 YYSTACK_RELOCATE (short, yyss
);
864 YYSTACK_RELOCATE (YYSTYPE
, yyvs
);
866 YYSTACK_RELOCATE (YYLTYPE
, yyls
);
868 # undef YYSTACK_RELOCATE
870 YYSTACK_FREE (yyss1
);
872 #endif /* no yyoverflow */
874 yyssp
= yyss
+ yysize
- 1;
875 yyvsp
= yyvs
+ yysize
- 1;
877 yylsp
= yyls
+ yysize
- 1;
880 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
881 (unsigned long int) yystacksize
));
883 if (yyssp
>= yyss
+ yystacksize
- 1)
887 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
897 /* Do appropriate processing given the current state. */
898 /* Read a lookahead token if we need one and don't already have one. */
901 /* First try to decide what to do without reference to lookahead token. */
903 yyn
= yypact
[yystate
];
907 /* Not known => get a lookahead token if don't already have one. */
909 /* yychar is either YYEMPTY or YYEOF
910 or a valid token in external form. */
912 if (yychar
== YYEMPTY
)
914 YYDPRINTF ((stderr
, "Reading a token: "));
918 /* Convert token to internal form (in yychar1) for indexing tables with */
920 if (yychar
<= 0) /* This means end of input. */
923 yychar
= YYEOF
; /* Don't call YYLEX any more */
925 YYDPRINTF ((stderr
, "Now at end of input.\n"));
929 yychar1
= YYTRANSLATE (yychar
);
932 /* We have to keep this `#if YYDEBUG', since we use variables
933 which are defined only if `YYDEBUG' is set. */
936 YYFPRINTF (stderr
, "Next token is %d (%s",
937 yychar
, yytname
[yychar1
]);
938 /* Give the individual parser a way to print the precise
939 meaning of a token, for further debugging info. */
941 YYPRINT (stderr
, yychar
, yylval
);
943 YYFPRINTF (stderr
, ")\n");
949 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
954 /* yyn is what to do for this token type in this state.
955 Negative => reduce, -yyn is rule number.
956 Positive => shift, yyn is new state.
957 New state is final state => don't bother to shift,
959 0, or most negative number => error. */
974 /* Shift the lookahead token. */
975 YYDPRINTF ((stderr
, "Shifting token %d (%s), ",
976 yychar
, yytname
[yychar1
]));
978 /* Discard the token being shifted unless it is eof. */
987 /* Count tokens shifted since error; after three, turn off error
996 /*-----------------------------------------------------------.
997 | yydefault -- do the default action for the current state. |
998 `-----------------------------------------------------------*/
1000 yyn
= yydefact
[yystate
];
1006 /*-----------------------------.
1007 | yyreduce -- Do a reduction. |
1008 `-----------------------------*/
1010 /* yyn is the number of a rule to reduce with. */
1013 /* If YYLEN is nonzero, implement the default value of the action:
1016 Otherwise, the following line sets YYVAL to the semantic value of
1017 the lookahead token. This behavior is undocumented and Bison
1018 users should not rely upon it. Assigning to YYVAL
1019 unconditionally makes the parser a bit smaller, and it avoids a
1020 GCC warning that YYVAL may be used uninitialized. */
1021 yyval
= yyvsp
[1-yylen
];
1024 /* Similarly for the default location. Let the user run additional
1025 commands if for instance locations are ranges. */
1026 yyloc
= yylsp
[1-yylen
];
1027 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);
1031 /* We have to keep this `#if YYDEBUG', since we use variables which
1032 are defined only if `YYDEBUG' is set. */
1037 YYFPRINTF (stderr
, "Reducing via rule %d (line %d), ",
1040 /* Print the symbols being reduced, and their result. */
1041 for (yyi
= yyprhs
[yyn
]; yyrhs
[yyi
] > 0; yyi
++)
1042 YYFPRINTF (stderr
, "%s ", yytname
[yyrhs
[yyi
]]);
1043 YYFPRINTF (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
1051 { expression_value
= yyvsp
[0].integer
.value
; }
1056 pedwarn ("comma operator in operand of `#if'");
1057 yyval
.integer
= yyvsp
[0].integer
; }
1061 { yyval
.integer
.value
= - yyvsp
[0].integer
.value
;
1062 if ((yyval
.integer
.value
& yyvsp
[0].integer
.value
) < 0 && ! yyvsp
[0].integer
.unsignedp
)
1063 integer_overflow ();
1064 yyval
.integer
.unsignedp
= yyvsp
[0].integer
.unsignedp
; }
1068 { yyval
.integer
.value
= ! yyvsp
[0].integer
.value
;
1069 yyval
.integer
.unsignedp
= 0; }
1073 { yyval
.integer
= yyvsp
[0].integer
; }
1077 { yyval
.integer
.value
= ~ yyvsp
[0].integer
.value
;
1078 yyval
.integer
.unsignedp
= yyvsp
[0].integer
.unsignedp
; }
1082 { yyval
.integer
.value
= check_assertion (yyvsp
[0].name
.address
, yyvsp
[0].name
.length
,
1084 yyval
.integer
.unsignedp
= 0; }
1088 { keyword_parsing
= 1; }
1092 { yyval
.integer
.value
= check_assertion (yyvsp
[-4].name
.address
, yyvsp
[-4].name
.length
,
1093 1, yyvsp
[-1].keywords
);
1094 keyword_parsing
= 0;
1095 yyval
.integer
.unsignedp
= 0; }
1099 { yyval
.integer
= yyvsp
[-1].integer
; }
1103 { yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
1104 if (yyval
.integer
.unsignedp
)
1105 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
* yyvsp
[0].integer
.value
;
1108 yyval
.integer
.value
= yyvsp
[-2].integer
.value
* yyvsp
[0].integer
.value
;
1109 if (yyvsp
[-2].integer
.value
1110 && (yyval
.integer
.value
/ yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
1111 || (yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0))
1112 integer_overflow ();
1117 { if (yyvsp
[0].integer
.value
== 0)
1119 error ("division by zero in #if");
1120 yyvsp
[0].integer
.value
= 1;
1122 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
1123 if (yyval
.integer
.unsignedp
)
1124 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
/ yyvsp
[0].integer
.value
;
1127 yyval
.integer
.value
= yyvsp
[-2].integer
.value
/ yyvsp
[0].integer
.value
;
1128 if ((yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0)
1129 integer_overflow ();
1134 { if (yyvsp
[0].integer
.value
== 0)
1136 error ("division by zero in #if");
1137 yyvsp
[0].integer
.value
= 1;
1139 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
1140 if (yyval
.integer
.unsignedp
)
1141 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
% yyvsp
[0].integer
.value
;
1143 yyval
.integer
.value
= yyvsp
[-2].integer
.value
% yyvsp
[0].integer
.value
; }
1147 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
+ yyvsp
[0].integer
.value
;
1148 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
1149 if (! yyval
.integer
.unsignedp
1150 && ! possible_sum_sign (yyvsp
[-2].integer
.value
, yyvsp
[0].integer
.value
,
1151 yyval
.integer
.value
))
1152 integer_overflow (); }
1156 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
- yyvsp
[0].integer
.value
;
1157 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
1158 if (! yyval
.integer
.unsignedp
1159 && ! possible_sum_sign (yyval
.integer
.value
, yyvsp
[0].integer
.value
,
1160 yyvsp
[-2].integer
.value
))
1161 integer_overflow (); }
1165 { yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
;
1166 if (yyvsp
[0].integer
.value
< 0 && ! yyvsp
[0].integer
.unsignedp
)
1167 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
1169 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); }
1173 { yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
;
1174 if (yyvsp
[0].integer
.value
< 0 && ! yyvsp
[0].integer
.unsignedp
)
1175 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
1177 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); }
1181 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
== yyvsp
[0].integer
.value
);
1182 yyval
.integer
.unsignedp
= 0; }
1186 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
);
1187 yyval
.integer
.unsignedp
= 0; }
1191 { yyval
.integer
.unsignedp
= 0;
1192 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
1193 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
<= yyvsp
[0].integer
.value
;
1195 yyval
.integer
.value
= yyvsp
[-2].integer
.value
<= yyvsp
[0].integer
.value
; }
1199 { yyval
.integer
.unsignedp
= 0;
1200 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
1201 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
>= yyvsp
[0].integer
.value
;
1203 yyval
.integer
.value
= yyvsp
[-2].integer
.value
>= yyvsp
[0].integer
.value
; }
1207 { yyval
.integer
.unsignedp
= 0;
1208 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
1209 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
< yyvsp
[0].integer
.value
;
1211 yyval
.integer
.value
= yyvsp
[-2].integer
.value
< yyvsp
[0].integer
.value
; }
1215 { yyval
.integer
.unsignedp
= 0;
1216 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
1217 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
> yyvsp
[0].integer
.value
;
1219 yyval
.integer
.value
= yyvsp
[-2].integer
.value
> yyvsp
[0].integer
.value
; }
1223 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
;
1224 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; }
1228 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
^ yyvsp
[0].integer
.value
;
1229 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; }
1233 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
| yyvsp
[0].integer
.value
;
1234 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; }
1238 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
&& yyvsp
[0].integer
.value
);
1239 yyval
.integer
.unsignedp
= 0; }
1243 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
|| yyvsp
[0].integer
.value
);
1244 yyval
.integer
.unsignedp
= 0; }
1248 { yyval
.integer
.value
= yyvsp
[-4].integer
.value
? yyvsp
[-2].integer
.value
: yyvsp
[0].integer
.value
;
1249 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; }
1253 { yyval
.integer
= yylval
.integer
; }
1257 { yyval
.integer
= yylval
.integer
; }
1261 { yyval
.integer
.value
= 0;
1262 yyval
.integer
.unsignedp
= 0; }
1266 { yyval
.keywords
= 0; }
1270 { struct arglist
*temp
;
1271 yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1272 yyval
.keywords
->next
= yyvsp
[-2].keywords
;
1273 yyval
.keywords
->name
= (U_CHAR
*) "(";
1274 yyval
.keywords
->length
= 1;
1275 temp
= yyval
.keywords
;
1276 while (temp
!= 0 && temp
->next
!= 0)
1278 temp
->next
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1279 temp
->next
->next
= yyvsp
[0].keywords
;
1280 temp
->next
->name
= (U_CHAR
*) ")";
1281 temp
->next
->length
= 1; }
1285 { yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1286 yyval
.keywords
->name
= yyvsp
[-1].name
.address
;
1287 yyval
.keywords
->length
= yyvsp
[-1].name
.length
;
1288 yyval
.keywords
->next
= yyvsp
[0].keywords
; }
1292 #line 727 "/usr/share/bison/bison.simple"
1304 short *yyssp1
= yyss
- 1;
1305 YYFPRINTF (stderr
, "state stack now");
1306 while (yyssp1
!= yyssp
)
1307 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1308 YYFPRINTF (stderr
, "\n");
1317 /* Now `shift' the result of the reduction. Determine what state
1318 that goes to, based on the state we popped back to and the rule
1319 number reduced by. */
1323 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1324 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1325 yystate
= yytable
[yystate
];
1327 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1332 /*------------------------------------.
1333 | yyerrlab -- here on detecting error |
1334 `------------------------------------*/
1336 /* If not already recovering from an error, report this error. */
1341 #ifdef YYERROR_VERBOSE
1342 yyn
= yypact
[yystate
];
1344 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1346 YYSIZE_T yysize
= 0;
1351 /* Start YYX at -YYN if negative to avoid negative indexes in
1353 for (yyx
= yyn
< 0 ? -yyn
: 0;
1354 yyx
< (int) (sizeof (yytname
) / sizeof (char *)); yyx
++)
1355 if (yycheck
[yyx
+ yyn
] == yyx
)
1356 yysize
+= yystrlen (yytname
[yyx
]) + 15, yycount
++;
1357 yysize
+= yystrlen ("parse error, unexpected ") + 1;
1358 yysize
+= yystrlen (yytname
[YYTRANSLATE (yychar
)]);
1359 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
1362 char *yyp
= yystpcpy (yymsg
, "parse error, unexpected ");
1363 yyp
= yystpcpy (yyp
, yytname
[YYTRANSLATE (yychar
)]);
1368 for (yyx
= yyn
< 0 ? -yyn
: 0;
1369 yyx
< (int) (sizeof (yytname
) / sizeof (char *));
1371 if (yycheck
[yyx
+ yyn
] == yyx
)
1373 const char *yyq
= ! yycount
? ", expecting " : " or ";
1374 yyp
= yystpcpy (yyp
, yyq
);
1375 yyp
= yystpcpy (yyp
, yytname
[yyx
]);
1380 YYSTACK_FREE (yymsg
);
1383 yyerror ("parse error; also virtual memory exhausted");
1386 #endif /* defined (YYERROR_VERBOSE) */
1387 yyerror ("parse error");
1392 /*--------------------------------------------------.
1393 | yyerrlab1 -- error raised explicitly by an action |
1394 `--------------------------------------------------*/
1396 if (yyerrstatus
== 3)
1398 /* If just tried and failed to reuse lookahead token after an
1399 error, discard it. */
1401 /* return failure if at end of input */
1402 if (yychar
== YYEOF
)
1404 YYDPRINTF ((stderr
, "Discarding token %d (%s).\n",
1405 yychar
, yytname
[yychar1
]));
1409 /* Else will try to reuse lookahead token after shifting the error
1412 yyerrstatus
= 3; /* Each real token shifted decrements this */
1417 /*-------------------------------------------------------------------.
1418 | yyerrdefault -- current state does not do anything special for the |
1420 `-------------------------------------------------------------------*/
1423 /* This is wrong; only states that explicitly want error tokens
1424 should shift them. */
1426 /* If its default is to accept any token, ok. Otherwise pop it. */
1427 yyn
= yydefact
[yystate
];
1433 /*---------------------------------------------------------------.
1434 | yyerrpop -- pop the current state because it cannot handle the |
1436 `---------------------------------------------------------------*/
1449 short *yyssp1
= yyss
- 1;
1450 YYFPRINTF (stderr
, "Error: state stack now");
1451 while (yyssp1
!= yyssp
)
1452 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1453 YYFPRINTF (stderr
, "\n");
1461 yyn
= yypact
[yystate
];
1466 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1483 YYDPRINTF ((stderr
, "Shifting error token, "));
1494 /*-------------------------------------.
1495 | yyacceptlab -- YYACCEPT comes here. |
1496 `-------------------------------------*/
1501 /*-----------------------------------.
1502 | yyabortlab -- YYABORT comes here. |
1503 `-----------------------------------*/
1508 /*---------------------------------------------.
1509 | yyoverflowab -- parser overflow comes here. |
1510 `---------------------------------------------*/
1512 yyerror ("parser stack overflow");
1519 YYSTACK_FREE (yyss
);
1526 /* During parsing of a C expression, the pointer to the next character
1527 is in this variable. */
1529 static char *lexptr
;
1531 /* Take care of parsing a number (anything that starts with a digit).
1532 Set yylval and return the token type; update lexptr.
1533 LEN is the number of characters in it. */
1535 /* maybe needs to actually deal with floating point numbers */
1541 register char *p
= lexptr
;
1543 register unsigned long n
= 0, nd
, ULONG_MAX_over_base
;
1544 register int base
= 10;
1545 register int len
= olen
;
1546 register int overflow
= 0;
1547 register int digit
, largest_digit
= 0;
1550 for (c
= 0; c
< len
; c
++)
1552 /* It's a float since it contains a point. */
1553 yyerror ("floating point numbers not allowed in #if expressions");
1557 yylval
.integer
.unsignedp
= 0;
1559 if (len
>= 3 && (!strncmp (p
, "0x", 2) || !strncmp (p
, "0X", 2))) {
1567 ULONG_MAX_over_base
= (unsigned long) -1 / base
;
1569 for (; len
> 0; len
--) {
1572 if (c
>= '0' && c
<= '9')
1574 else if (base
== 16 && c
>= 'a' && c
<= 'f')
1575 digit
= c
- 'a' + 10;
1576 else if (base
== 16 && c
>= 'A' && c
<= 'F')
1577 digit
= c
- 'A' + 10;
1579 /* `l' means long, and `u' means unsigned. */
1581 if (c
== 'l' || c
== 'L')
1584 yyerror ("two `l's in integer constant");
1587 else if (c
== 'u' || c
== 'U')
1589 if (yylval
.integer
.unsignedp
)
1590 yyerror ("two `u's in integer constant");
1591 yylval
.integer
.unsignedp
= 1;
1600 /* Don't look for any more digits after the suffixes. */
1603 if (largest_digit
< digit
)
1604 largest_digit
= digit
;
1605 nd
= n
* base
+ digit
;
1606 overflow
|= ULONG_MAX_over_base
< n
| nd
< n
;
1611 yyerror ("Invalid number in #if expression");
1615 if (base
<= largest_digit
)
1616 warning ("integer constant contains digits beyond the radix");
1619 warning ("integer constant out of range");
1621 /* If too big to be signed, consider it unsigned. */
1622 if ((long) n
< 0 && ! yylval
.integer
.unsignedp
)
1625 warning ("integer constant is so large that it is unsigned");
1626 yylval
.integer
.unsignedp
= 1;
1630 yylval
.integer
.value
= n
;
1639 static struct token tokentab2
[] = {
1653 /* Read one token, getting characters through lexptr. */
1659 register int namelen
;
1660 register unsigned char *tokstart
;
1661 register struct token
*toktab
;
1666 tokstart
= (unsigned char *) lexptr
;
1668 /* See if it is a special token of length 2. */
1669 if (! keyword_parsing
)
1670 for (toktab
= tokentab2
; toktab
->operator != NULL
; toktab
++)
1671 if (c
== *toktab
->operator && tokstart
[1] == toktab
->operator[1]) {
1673 if (toktab
->token
== ERROR
)
1675 char *buf
= (char *) alloca (40);
1676 sprintf (buf
, "`%s' not allowed in operand of `#if'", toktab
->operator);
1679 return toktab
->token
;
1694 /* Capital L may start a wide-string or wide-character constant. */
1695 if (lexptr
[1] == '\'')
1701 if (lexptr
[1] == '"')
1705 goto string_constant
;
1713 if (keyword_parsing
) {
1714 char *start_ptr
= lexptr
- 1;
1718 c
= parse_escape (&lexptr
);
1722 yylval
.name
.address
= tokstart
;
1723 yylval
.name
.length
= lexptr
- start_ptr
;
1727 /* This code for reading a character constant
1728 handles multicharacter constants and wide characters.
1729 It is mostly copied from c-lex.c. */
1731 register int result
= 0;
1732 register num_chars
= 0;
1733 unsigned width
= CHAR_TYPE_SIZE
;
1739 width
= WCHAR_TYPE_SIZE
;
1740 #ifdef MULTIBYTE_CHARS
1741 max_chars
= MB_CUR_MAX
;
1747 max_chars
= LONG_TYPE_SIZE
/ width
;
1749 token_buffer
= (char *) alloca (max_chars
+ 1);
1755 if (c
== '\'' || c
== EOF
)
1760 c
= parse_escape (&lexptr
);
1761 if (width
< HOST_BITS_PER_INT
1762 && (unsigned) c
>= (1 << width
))
1763 pedwarn ("escape sequence out of range for character");
1768 /* Merge character into result; ignore excess chars. */
1769 if (num_chars
< max_chars
+ 1)
1771 if (width
< HOST_BITS_PER_INT
)
1772 result
= (result
<< width
) | (c
& ((1 << width
) - 1));
1775 token_buffer
[num_chars
- 1] = c
;
1779 token_buffer
[num_chars
] = 0;
1782 error ("malformatted character constant");
1783 else if (num_chars
== 0)
1784 error ("empty character constant");
1785 else if (num_chars
> max_chars
)
1787 num_chars
= max_chars
;
1788 error ("character constant too long");
1790 else if (num_chars
!= 1 && ! traditional
)
1791 warning ("multi-character character constant");
1793 /* If char type is signed, sign-extend the constant. */
1796 int num_bits
= num_chars
* width
;
1798 if (lookup ("__CHAR_UNSIGNED__", sizeof ("__CHAR_UNSIGNED__")-1, -1)
1799 || ((result
>> (num_bits
- 1)) & 1) == 0)
1800 yylval
.integer
.value
1801 = result
& ((unsigned long) ~0 >> (HOST_BITS_PER_LONG
- num_bits
));
1803 yylval
.integer
.value
1804 = result
| ~((unsigned long) ~0 >> (HOST_BITS_PER_LONG
- num_bits
));
1808 #ifdef MULTIBYTE_CHARS
1809 /* Set the initial shift state and convert the next sequence. */
1811 /* In all locales L'\0' is zero and mbtowc will return zero,
1814 || (num_chars
== 1 && token_buffer
[0] != '\0'))
1817 (void) mbtowc (NULL_PTR
, NULL_PTR
, 0);
1818 if (mbtowc (& wc
, token_buffer
, num_chars
) == num_chars
)
1821 warning ("Ignoring invalid multibyte character");
1824 yylval
.integer
.value
= result
;
1828 /* This is always a signed type. */
1829 yylval
.integer
.unsignedp
= 0;
1833 /* some of these chars are invalid in constant expressions;
1834 maybe do something about them later */
1858 if (keyword_parsing
)
1867 if (keyword_parsing
) {
1868 char *start_ptr
= lexptr
;
1873 c
= parse_escape (&lexptr
);
1877 yylval
.name
.address
= tokstart
;
1878 yylval
.name
.length
= lexptr
- start_ptr
;
1881 yyerror ("string constants not allowed in #if expressions");
1885 if (c
>= '0' && c
<= '9' && !keyword_parsing
) {
1888 c
= tokstart
[namelen
], is_idchar
[c
] || c
== '.';
1891 return parse_number (namelen
);
1894 /* It is a name. See how long it is. */
1896 if (keyword_parsing
) {
1897 for (namelen
= 0;; namelen
++) {
1898 if (is_hor_space
[tokstart
[namelen
]])
1900 if (tokstart
[namelen
] == '(' || tokstart
[namelen
] == ')')
1902 if (tokstart
[namelen
] == '"' || tokstart
[namelen
] == '\'')
1906 if (!is_idstart
[c
]) {
1907 yyerror ("Invalid token in expression");
1911 for (namelen
= 0; is_idchar
[tokstart
[namelen
]]; namelen
++)
1916 yylval
.name
.address
= tokstart
;
1917 yylval
.name
.length
= namelen
;
1922 /* Parse a C escape sequence. STRING_PTR points to a variable
1923 containing a pointer to the string to parse. That pointer
1924 is updated past the characters we use. The value of the
1925 escape sequence is returned.
1927 A negative value means the sequence \ newline was seen,
1928 which is supposed to be equivalent to nothing at all.
1930 If \ is followed by a null character, we return a negative
1931 value and leave the string pointer pointing at the null character.
1933 If \ is followed by 000, we return 0 and leave the string pointer
1934 after the zeros. A value of 0 does not mean end of string. */
1937 parse_escape (string_ptr
)
1940 register int c
= *(*string_ptr
)++;
1950 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c
);
1955 return TARGET_NEWLINE
;
1977 register int i
= c
- '0';
1978 register int count
= 0;
1981 c
= *(*string_ptr
)++;
1982 if (c
>= '0' && c
<= '7')
1983 i
= (i
<< 3) + c
- '0';
1990 if ((i
& ~((1 << CHAR_TYPE_SIZE
) - 1)) != 0)
1992 i
&= (1 << CHAR_TYPE_SIZE
) - 1;
1993 warning ("octal character constant does not fit in a byte");
1999 register unsigned i
= 0, overflow
= 0, digits_found
= 0, digit
;
2002 c
= *(*string_ptr
)++;
2003 if (c
>= '0' && c
<= '9')
2005 else if (c
>= 'a' && c
<= 'f')
2006 digit
= c
- 'a' + 10;
2007 else if (c
>= 'A' && c
<= 'F')
2008 digit
= c
- 'A' + 10;
2014 overflow
|= i
^ (i
<< 4 >> 4);
2015 i
= (i
<< 4) + digit
;
2019 yyerror ("\\x used with no following hex digits");
2020 if (overflow
| (i
& ~((1 << BITS_PER_UNIT
) - 1)))
2022 i
&= (1 << BITS_PER_UNIT
) - 1;
2023 warning ("hex character constant does not fit in a byte");
2037 longjmp (parse_return_error
, 1);
2044 pedwarn ("integer overflow in preprocessor expression");
2052 if (b
>= HOST_BITS_PER_LONG
)
2054 if (! a
->unsignedp
&& a
->value
!= 0)
2055 integer_overflow ();
2058 else if (a
->unsignedp
)
2059 return (unsigned long) a
->value
<< b
;
2062 long l
= a
->value
<< b
;
2063 if (l
>> b
!= a
->value
)
2064 integer_overflow ();
2074 if (b
>= HOST_BITS_PER_LONG
)
2075 return a
->unsignedp
? 0 : a
->value
>> (HOST_BITS_PER_LONG
- 1);
2076 else if (a
->unsignedp
)
2077 return (unsigned long) a
->value
>> b
;
2079 return a
->value
>> b
;
2082 /* This page contains the entry point to this file. */
2084 /* Parse STRING as an expression, and complain if this fails
2085 to use up all of the contents of STRING. */
2086 /* We do not support C comments. They should be removed before
2087 this function is called. */
2090 parse_c_expression (string
)
2095 if (lexptr
== 0 || *lexptr
== 0) {
2096 error ("empty #if expression");
2097 return 0; /* don't include the #if group */
2100 /* if there is some sort of scanning error, just return 0 and assume
2101 the parsing routine has printed an error message somewhere.
2102 there is surely a better thing to do than this. */
2103 if (setjmp (parse_return_error
))
2107 return 0; /* actually this is never reached
2108 the way things stand. */
2110 error ("Junk after end of expression.");
2112 return expression_value
; /* set by yyparse () */
2115 #ifdef TEST_EXP_READER
2118 /* Main program for testing purposes. */
2128 initialize_random_junk ();
2131 printf ("enter expression: ");
2133 while ((buf
[n
] = getchar ()) != '\n' && buf
[n
] != EOF
)
2138 printf ("parser returned %d\n", parse_c_expression (buf
));
2144 /* table to tell if char can be part of a C identifier. */
2145 unsigned char is_idchar
[256];
2146 /* table to tell if char can be first char of a c identifier. */
2147 unsigned char is_idstart
[256];
2148 /* table to tell if c is horizontal space. isspace () thinks that
2149 newline is space; this is not a good idea for this program. */
2150 char is_hor_space
[256];
2153 * initialize random junk in the hash table and maybe other places
2155 initialize_random_junk ()
2160 * Set up is_idchar and is_idstart tables. These should be
2161 * faster than saying (is_alpha (c) || c == '_'), etc.
2162 * Must do set up these things before calling any routines tthat
2165 for (i
= 'a'; i
<= 'z'; i
++) {
2166 ++is_idchar
[i
- 'a' + 'A'];
2168 ++is_idstart
[i
- 'a' + 'A'];
2171 for (i
= '0'; i
<= '9'; i
++)
2175 #if DOLLARS_IN_IDENTIFIERS
2180 /* horizontal space table */
2181 ++is_hor_space
[' '];
2182 ++is_hor_space
['\t'];
2187 printf ("error: %s\n", msg
);
2192 printf ("warning: %s\n", msg
);
2196 lookup (name
, len
, hash
)
2201 return (DEFAULT_SIGNED_CHAR
) ? 0 : ((struct hashnode
*) -1);