Annotation of gcc/cexp.c, revision 1.1.1.7

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.