cexp.c
来自「GCC编译器源代码」· C语言 代码 · 共 2,170 行 · 第 1/4 页
C
2,170 行
/* A Bison parser, made from cexp.y by Bison version A2.5 (Andrew Consortium) */#define YYBISON 1 /* Identify Bison output. */#define INT 258#define CHAR 259#define NAME 260#define ERROR 261#define OR 262#define AND 263#define EQUAL 264#define NOTEQUAL 265#define LEQ 266#define GEQ 267#define LSH 268#define RSH 269#define UNARY 270#line 27 "cexp.y"#include "config.h"#include <setjmp.h>/* #define YYDEBUG 1 */#ifdef HAVE_STRING_H# include <string.h>#endif#ifdef HAVE_STDLIB_H# include <stdlib.h>#endif#ifdef HAVE_LIMITS_H# include <limits.h>#endif#ifdef MULTIBYTE_CHARS#include <locale.h>#endif#include <stdio.h>typedef unsigned char U_CHAR;/* This is used for communicating lists of keywords with cccp.c. */struct arglist { struct arglist *next; U_CHAR *name; int length; int argno;};/* Define a generic NULL if one hasn't already been defined. */#ifndef NULL#define NULL 0#endif#ifndef GENERIC_PTR#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)#define GENERIC_PTR void *#else#define GENERIC_PTR char *#endif#endif#ifndef NULL_PTR#define NULL_PTR ((GENERIC_PTR) 0)#endif/* Find the largest host integer type and set its size and type. Watch out: on some crazy hosts `long' is shorter than `int'. */#ifndef HOST_WIDE_INT# if HAVE_INTTYPES_H# include <inttypes.h># define HOST_WIDE_INT intmax_t# define unsigned_HOST_WIDE_INT uintmax_t# else# if (HOST_BITS_PER_LONG <= HOST_BITS_PER_INT && HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_INT)# define HOST_WIDE_INT int# else# if (HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_LONG || ! (defined LONG_LONG_MAX || defined LLONG_MAX))# define HOST_WIDE_INT long# else# define HOST_WIDE_INT long long# endif# endif# endif#endif#ifndef unsigned_HOST_WIDE_INT#define unsigned_HOST_WIDE_INT unsigned HOST_WIDE_INT#endif#ifndef CHAR_BIT#define CHAR_BIT 8#endif#ifndef HOST_BITS_PER_WIDE_INT#define HOST_BITS_PER_WIDE_INT (CHAR_BIT * sizeof (HOST_WIDE_INT))#endif#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)# define __attribute__(x)#endif#ifndef PROTO# if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)# define PROTO(ARGS) ARGS# else# define PROTO(ARGS) ()# endif#endif#if defined (__STDC__) && defined (HAVE_VPRINTF)# include <stdarg.h># define VA_START(va_list, var) va_start (va_list, var)# define PRINTF_ALIST(msg) char *msg, ...# define PRINTF_DCL(msg)# define PRINTF_PROTO(ARGS, m, n) PROTO (ARGS) __attribute__ ((format (__printf__, m, n)))#else# include <varargs.h># define VA_START(va_list, var) va_start (va_list)# define PRINTF_ALIST(msg) msg, va_alist# define PRINTF_DCL(msg) char *msg; va_dcl# define PRINTF_PROTO(ARGS, m, n) () __attribute__ ((format (__printf__, m, n)))# define vfprintf(file, msg, args) \ { \ char *a0 = va_arg(args, char *); \ char *a1 = va_arg(args, char *); \ char *a2 = va_arg(args, char *); \ char *a3 = va_arg(args, char *); \ fprintf (file, msg, a0, a1, a2, a3); \ }#endif#define PRINTF_PROTO_1(ARGS) PRINTF_PROTO(ARGS, 1, 2)HOST_WIDE_INT parse_c_expression PROTO((char *, int));static int yylex PROTO((void));static void yyerror PROTO((char *)) __attribute__ ((noreturn));static HOST_WIDE_INT expression_value;#ifdef TEST_EXP_READERstatic int expression_signedp;#endifstatic jmp_buf parse_return_error;/* Nonzero means count most punctuation as part of a name. */static int keyword_parsing = 0;/* Nonzero means do not evaluate this expression. This is a count, since unevaluated expressions can nest. */static int skip_evaluation;/* Nonzero means warn if undefined identifiers are evaluated. */static int warn_undef;/* some external tables of character types */extern unsigned char is_idstart[], is_idchar[], is_space[];/* Flag for -pedantic. */extern int pedantic;/* Flag for -traditional. */extern int traditional;/* Flag for -lang-c89. */extern int c89;#ifndef CHAR_TYPE_SIZE#define CHAR_TYPE_SIZE BITS_PER_UNIT#endif#ifndef INT_TYPE_SIZE#define INT_TYPE_SIZE BITS_PER_WORD#endif#ifndef LONG_TYPE_SIZE#define LONG_TYPE_SIZE BITS_PER_WORD#endif#ifndef WCHAR_TYPE_SIZE#define WCHAR_TYPE_SIZE INT_TYPE_SIZE#endif#ifndef MAX_CHAR_TYPE_SIZE#define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE#endif#ifndef MAX_INT_TYPE_SIZE#define MAX_INT_TYPE_SIZE INT_TYPE_SIZE#endif#ifndef MAX_LONG_TYPE_SIZE#define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE#endif#ifndef MAX_WCHAR_TYPE_SIZE#define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE#endif#define MAX_CHAR_TYPE_MASK (MAX_CHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \ ? (~ (~ (HOST_WIDE_INT) 0 << MAX_CHAR_TYPE_SIZE)) \ : ~ (HOST_WIDE_INT) 0)#define MAX_WCHAR_TYPE_MASK (MAX_WCHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \ ? ~ (~ (HOST_WIDE_INT) 0 << MAX_WCHAR_TYPE_SIZE) \ : ~ (HOST_WIDE_INT) 0)/* Suppose A1 + B1 = SUM1, using 2's complement arithmetic ignoring overflow. Suppose A, B and SUM have the same respective signs as A1, B1, and SUM1. Suppose SIGNEDP is negative if the result is signed, zero if unsigned. Then this yields nonzero if overflow occurred during the addition. Overflow occurs if A and B have the same sign, but A and SUM differ in sign, and SIGNEDP is negative. Use `^' to test whether signs differ, and `< 0' to isolate the sign. */#define overflow_sum_sign(a, b, sum, signedp) \ ((~((a) ^ (b)) & ((a) ^ (sum)) & (signedp)) < 0)struct constant;GENERIC_PTR xmalloc PROTO((size_t));HOST_WIDE_INT parse_escape PROTO((char **, HOST_WIDE_INT));int check_assertion PROTO((U_CHAR *, int, int, struct arglist *));struct hashnode *lookup PROTO((U_CHAR *, int, int));void error PRINTF_PROTO_1((char *, ...));void pedwarn PRINTF_PROTO_1((char *, ...));void warning PRINTF_PROTO_1((char *, ...));static int parse_number PROTO((int));static HOST_WIDE_INT left_shift PROTO((struct constant *, unsigned_HOST_WIDE_INT));static HOST_WIDE_INT right_shift PROTO((struct constant *, unsigned_HOST_WIDE_INT));static void integer_overflow PROTO((void));/* `signedp' values */#define SIGNED (~0)#define UNSIGNED 0#line 251 "cexp.y"typedef union { struct constant {HOST_WIDE_INT value; int signedp;} integer; struct name {U_CHAR *address; int length;} name; struct arglist *keywords;} YYSTYPE;#include <stdio.h>#ifndef __cplusplus#ifndef __STDC__#define const#endif#endif#define YYFINAL 77#define YYFLAG -32768#define YYNTBASE 34#define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 43)static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 29, 2, 31, 2, 27, 14, 2, 32, 33, 25, 23, 9, 24, 2, 26, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 8, 2, 17, 2, 18, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 13, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 12, 2, 30, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 10, 11, 15, 16, 19, 20, 21, 22, 28};#if YYDEBUG != 0static const short yyprhs[] = { 0, 0, 2, 4, 8, 11, 14, 17, 20, 23, 24, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, 100, 105, 106, 111, 112, 113, 121, 123, 125, 127, 128, 133};static const short yyrhs[] = { 35, 0, 36, 0, 35, 9, 36, 0, 24, 36, 0, 29, 36, 0, 23, 36, 0, 30, 36, 0, 31, 5, 0, 0, 31, 5, 37, 32, 42, 33, 0, 32, 35, 33, 0, 36, 25, 36, 0, 36, 26, 36, 0, 36, 27, 36, 0, 36, 23, 36, 0, 36, 24, 36, 0, 36, 21, 36, 0, 36, 22, 36, 0, 36, 15, 36, 0, 36, 16, 36, 0, 36, 19, 36, 0, 36, 20, 36, 0, 36, 17, 36, 0, 36, 18, 36, 0, 36, 14, 36, 0, 36, 13, 36, 0, 36, 12, 36, 0, 0, 36, 11, 38, 36, 0, 0, 36, 10, 39, 36, 0, 0, 0, 36, 7, 40, 36, 8, 41, 36, 0, 3, 0, 4, 0, 5, 0, 0, 32, 42, 33, 42, 0, 5, 42, 0};#endif#if YYDEBUG != 0static const short yyrline[] = { 0, 281, 291, 292, 299, 304, 307, 309, 312, 316, 318, 323, 328, 341, 358, 371, 377, 383, 389, 395, 398, 401, 408, 415, 422, 429, 432, 435, 438, 441, 444, 447, 450, 452, 455, 458, 460, 462, 470, 472, 485};#endif#if YYDEBUG != 0static const char * const yytname[] = { "$","error","$undefined.","INT","CHAR","NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL","'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'","'~'","'#'","'('","')'","start","exp1","exp","@1","@2","@3","@4","@5","keywords", NULL};#endifstatic const short yyr1[] = { 0, 34, 35, 35, 36, 36, 36, 36, 36, 37, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 38, 36, 39, 36, 40, 41, 36, 36, 36, 36, 42, 42, 42};static const short yyr2[] = { 0, 1, 1, 3, 2, 2, 2, 2, 2, 0, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 4, 0, 4, 0, 0, 7, 1, 1, 1, 0, 4, 2};static const short yydefact[] = { 0, 35, 36, 37, 0, 0, 0, 0, 0, 0, 1, 2, 6, 4, 5, 7, 8, 0, 0, 32, 30, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 3, 0, 0, 0, 27, 26, 25, 19, 20, 23, 24, 21, 22, 17, 18, 15, 16, 12, 13, 14, 38, 0, 31, 29, 38, 38, 0, 33, 40, 0, 10, 0, 38, 34, 39, 0, 0, 0};static const short yydefgoto[] = { 75, 10, 11, 38, 43, 42, 41, 71, 66};static const short yypact[] = { 12,-32768,-32768,-32768, 12, 12, 12, 12, 1, 12, 4, 79,-32768,-32768,-32768,-32768, -21, 31, 12,-32768,-32768,-32768, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 30,-32768, 79, 12, 12, 12, 110, 124, 137, 148, 148, 155, 155, 155, 155, 160, 160, -17, -17,-32768,-32768,-32768, 2, 58, 34, 95, 2, 2, 54,-32768,-32768, 55,-32768, 12, 2, 79,-32768, 63, 188,-32768};static const short yypgoto[] = {-32768, 180, -4,-32768,-32768,-32768,-32768,-32768, -60};#define YYLAST 189static const short yytable[] = { 12, 13, 14, 15, 68, 69, 16, 64, 35, 36, 37, -9, 74, 18, 40, 1, 2, 3, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 65, 4, 5, 61, 62, 63, 18, 6, 7, 8, 9, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 60, 76, 39, 19, 67, 73, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 19, 70, 72, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 31, 32, 33, 34, 35, 36, 37, 33, 34, 35, 36, 37, 77, 17};static const short yycheck[] = { 4, 5, 6, 7, 64, 65, 5, 5, 25, 26, 27, 32, 72, 9, 18, 3, 4, 5, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 32, 23, 24, 41, 42, 43, 9, 29, 30, 31, 32, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 32, 0, 33, 7, 8, 71, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 7, 33, 33, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 21, 22, 23, 24, 25, 26, 27, 23, 24, 25, 26, 27, 0, 9};/* -*-C-*- Note some compilers choke on comments on `#line' lines. */#line 3 "/usr/share/bison.simple"/* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */#ifndef alloca#ifdef __GNUC__#define alloca __builtin_alloca#else /* not GNU C. */#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)#include <alloca.h>#else /* not sparc */#if defined (MSDOS) && !defined (__TURBOC__)#include <malloc.h>#else /* not MSDOS, or __TURBOC__ */#if defined(_AIX)#include <malloc.h> #pragma alloca#else /* not MSDOS, __TURBOC__, or _AIX */#ifdef __hpux#ifdef __cplusplusextern "C" {void *alloca (unsigned int);};#else /* not __cplusplus */void *alloca ();#endif /* not __cplusplus */#endif /* __hpux */#endif /* not _AIX */#endif /* not MSDOS, or __TURBOC__ */#endif /* not sparc. */#endif /* not GNU C. */#endif /* alloca not defined. *//* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. *//* Note: there must be only one dollar sign in this file. It is replaced by the list of actions, each action as one case of the switch. */#define yyerrok (yyerrstatus = 0)#define yyclearin (yychar = YYEMPTY)#define YYEMPTY -2#define YYEOF 0#define YYACCEPT return(0)#define YYABORT return(1)#define YYERROR goto yyerrlab1/* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */#define YYFAIL goto yyerrlab#define YYRECOVERING() (!!yyerrstatus)#define YYBACKUP(token, value) \do \ if (yychar == YYEMPTY && yylen == 1) \ { yychar = (token), yylval = (value); \ yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { yyerror ("syntax error: cannot back up"); YYERROR; } \while (0)#define YYTERROR 1#define YYERRCODE 256#ifndef YYPURE#define YYLEX yylex()#endif#ifdef YYPURE#ifdef YYLSP_NEEDED#ifdef YYLEX_PARAM#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)#else#define YYLEX yylex(&yylval, &yylloc)#endif#else /* not YYLSP_NEEDED */#ifdef YYLEX_PARAM#define YYLEX yylex(&yylval, YYLEX_PARAM)#else#define YYLEX yylex(&yylval)#endif#endif /* not YYLSP_NEEDED */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?