Annotation of gcc/cexp.c, revision 1.1.1.8

1.1       root        1: 
1.1.1.8 ! root        2: /*  A Bison parser, made from ccdir/cexp.y  */
1.1       root        3: 
                      4: #define        INT     258
                      5: #define        CHAR    259
                      6: #define        NAME    260
                      7: #define        ERROR   261
                      8: #define        OR      262
                      9: #define        AND     263
                     10: #define        EQUAL   264
                     11: #define        NOTEQUAL        265
                     12: #define        LEQ     266
                     13: #define        GEQ     267
                     14: #define        LSH     268
                     15: #define        RSH     269
                     16: #define        UNARY   270
                     17: 
1.1.1.8 ! root       18: #line 26 "ccdir/cexp.y"
1.1       root       19: 
1.1.1.2   root       20: #include "config.h"
1.1       root       21: #include <setjmp.h>
                     22: /* #define YYDEBUG 1 */
                     23: 
1.1.1.3   root       24:   int yylex ();
                     25:   void yyerror ();
1.1       root       26:   int expression_value;
                     27: 
                     28:   static jmp_buf parse_return_error;
                     29: 
                     30:   /* some external tables of character types */
                     31:   extern unsigned char is_idstart[], is_idchar[];
                     32: 
1.1.1.7   root       33: #ifndef CHAR_TYPE_SIZE
                     34: #define CHAR_TYPE_SIZE BITS_PER_UNIT
                     35: #endif
1.1       root       36: 
1.1.1.8 ! root       37: #line 45 "ccdir/cexp.y"
1.1       root       38: typedef union {
1.1.1.7   root       39:   struct constant {long value; int unsignedp;} integer;
1.1       root       40:   int voidval;
                     41:   char *sval;
                     42: } YYSTYPE;
                     43: 
                     44: #ifndef YYLTYPE
                     45: typedef
                     46:   struct yyltype
1.1.1.7   root       47:     {
1.1       root       48:       int timestamp;
                     49:       int first_line;
                     50:       int first_column;
                     51:       int last_line;
                     52:       int last_column;
                     53:       char *text;
                     54:    }
1.1.1.7   root       55:   yyltype;
1.1       root       56: 
                     57: #define YYLTYPE yyltype
                     58: #endif
                     59: 
                     60: #include <stdio.h>
                     61: 
1.1.1.2   root       62: #ifndef __STDC__
                     63: #define const
                     64: #endif
                     65: 
1.1       root       66: 
                     67: 
1.1.1.7   root       68: #define        YYFINAL         61
1.1       root       69: #define        YYFLAG          -32768
                     70: #define        YYNTBASE        33
                     71: 
1.1.1.2   root       72: #define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 36)
1.1       root       73: 
1.1.1.2   root       74: static const char yytranslate[] = {     0,
1.1       root       75:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     76:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     77:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     78:      2,     2,    29,     2,     2,     2,    27,    14,     2,    31,
                     79:     32,    25,    23,     9,    24,     2,    26,     2,     2,     2,
                     80:      2,     2,     2,     2,     2,     2,     2,     8,     2,    17,
                     81:      2,    18,     7,     2,     2,     2,     2,     2,     2,     2,
                     82:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     83:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     84:      2,     2,     2,    13,     2,     2,     2,     2,     2,     2,
                     85:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     86:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     87:      2,     2,     2,    12,     2,    30,     2,     2,     2,     2,
                     88:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     89:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     90:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     91:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     92:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     93:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     94:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     95:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     96:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     97:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     98:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                     99:      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
                    100:      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
                    101:      6,    10,    11,    15,    16,    19,    20,    21,    22,    28
                    102: };
                    103: 
1.1.1.8 ! root      104: #if YYDEBUG != 0
        !           105: static const short yyrline[] = { 0,
1.1.1.7   root      106:     74,    79,    80,    85,    88,    91,    93,    96,   101,   107,
                    107:    118,   129,   132,   135,   141,   147,   150,   153,   159,   165,
                    108:    171,   177,   180,   183,   186,   189,   192,   195,   197,   199
1.1       root      109: };
                    110: 
1.1.1.2   root      111: static const char * const yytname[] = {     0,
1.1       root      112: "error","$illegal.","INT","CHAR","NAME","ERROR","'?'","':'","','","OR",
                    113: "AND","'|'","'^'","'&'","EQUAL","NOTEQUAL","'<'","'>'","LEQ","GEQ",
                    114: "LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'","'~'",
                    115: "'('","')'","start"
                    116: };
1.1.1.8 ! root      117: #endif
1.1       root      118: 
1.1.1.2   root      119: static const short yyr1[] = {     0,
1.1       root      120:     33,    34,    34,    35,    35,    35,    35,    35,    35,    35,
                    121:     35,    35,    35,    35,    35,    35,    35,    35,    35,    35,
1.1.1.7   root      122:     35,    35,    35,    35,    35,    35,    35,    35,    35,    35
1.1       root      123: };
                    124: 
1.1.1.2   root      125: static const short yyr2[] = {     0,
1.1.1.7   root      126:      1,     1,     3,     2,     2,     2,     2,     3,     3,     3,
1.1       root      127:      3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
1.1.1.7   root      128:      3,     3,     3,     3,     3,     3,     5,     1,     1,     1
1.1       root      129: };
                    130: 
1.1.1.2   root      131: static const short yydefact[] = {     0,
1.1.1.7   root      132:     28,    29,    30,     0,     0,     0,     0,     0,     1,     2,
                    133:      6,     4,     5,     7,     0,     0,     0,     0,     0,     0,
1.1       root      134:      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1.1.1.7   root      135:      0,     0,     0,     0,     0,     8,     3,     0,    26,    25,
                    136:     24,    23,    22,    16,    17,    20,    21,    18,    19,    14,
                    137:     15,    12,    13,     9,    10,    11,     0,    27,     0,     0,
                    138:      0
1.1       root      139: };
                    140: 
1.1.1.7   root      141: static const short yydefgoto[] = {    59,
                    142:      9,    10
1.1       root      143: };
                    144: 
1.1.1.7   root      145: static const short yypact[] = {    31,
                    146: -32768,-32768,-32768,    31,    31,    31,    31,    31,     1,    77,
                    147: -32768,-32768,-32768,-32768,     0,    31,    31,    31,    31,    31,
                    148:     31,    31,    31,    31,    31,    31,    31,    31,    31,    31,
                    149:     31,    31,    31,    31,    31,-32768,    77,    56,    94,    25,
                    150:    109,   123,   136,   147,   147,   154,   154,   154,   154,   -19,
                    151:    -19,    32,    32,-32768,-32768,-32768,    31,    77,    11,    33,
                    152: -32768
1.1       root      153: };
                    154: 
1.1.1.2   root      155: static const short yypgoto[] = {-32768,
1.1.1.7   root      156:     48,    -4
1.1       root      157: };
                    158: 
                    159: 
1.1.1.7   root      160: #define        YYLAST          181
1.1       root      161: 
                    162: 
1.1.1.7   root      163: static const short yytable[] = {    11,
                    164:     12,    13,    14,    31,    32,    33,    34,    35,    16,    16,
                    165:     60,    37,    38,    39,    40,    41,    42,    43,    44,    45,
                    166:     46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
                    167:     56,    36,    61,     1,     2,     3,    20,    21,    22,    23,
1.1       root      168:     24,    25,    26,    27,    28,    29,    30,    31,    32,    33,
1.1.1.7   root      169:     34,    35,    58,     4,     5,    15,    33,    34,    35,     6,
                    170:      7,     8,    17,    57,     0,    18,    19,    20,    21,    22,
1.1       root      171:     23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
1.1.1.7   root      172:     33,    34,    35,    17,     0,     0,    18,    19,    20,    21,
1.1       root      173:     22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
1.1.1.7   root      174:     32,    33,    34,    35,    19,    20,    21,    22,    23,    24,
                    175:     25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
                    176:     35,    21,    22,    23,    24,    25,    26,    27,    28,    29,
                    177:     30,    31,    32,    33,    34,    35,    22,    23,    24,    25,
                    178:     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
                    179:     23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
                    180:     33,    34,    35,    25,    26,    27,    28,    29,    30,    31,
                    181:     32,    33,    34,    35,    29,    30,    31,    32,    33,    34,
                    182:     35
1.1       root      183: };
                    184: 
1.1.1.2   root      185: static const short yycheck[] = {     4,
1.1.1.7   root      186:      5,     6,     7,    23,    24,    25,    26,    27,     9,     9,
                    187:      0,    16,    17,    18,    19,    20,    21,    22,    23,    24,
                    188:     25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
                    189:     35,    32,     0,     3,     4,     5,    12,    13,    14,    15,
                    190:     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
                    191:     26,    27,    57,    23,    24,     8,    25,    26,    27,    29,
                    192:     30,    31,     7,     8,    -1,    10,    11,    12,    13,    14,
1.1       root      193:     15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
1.1.1.7   root      194:     25,    26,    27,     7,    -1,    -1,    10,    11,    12,    13,
                    195:     14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
                    196:     24,    25,    26,    27,    11,    12,    13,    14,    15,    16,
1.1       root      197:     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
1.1.1.7   root      198:     27,    13,    14,    15,    16,    17,    18,    19,    20,    21,
                    199:     22,    23,    24,    25,    26,    27,    14,    15,    16,    17,
1.1       root      200:     18,    19,    20,    21,    22,    23,    24,    25,    26,    27,
1.1.1.7   root      201:     15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
                    202:     25,    26,    27,    17,    18,    19,    20,    21,    22,    23,
                    203:     24,    25,    26,    27,    21,    22,    23,    24,    25,    26,
                    204:     27
1.1       root      205: };
                    206: #define YYPURE 1
                    207: 
1.1.1.6   root      208: /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
                    209: #line 3 "bison.simple"
1.1       root      210: 
                    211: /* Skeleton output parser for bison,
1.1.1.7   root      212:    Copyright (C) 1984 Bob Corbett and Richard Stallman
1.1       root      213: 
1.1.1.7   root      214:    This program is free software; you can redistribute it and/or modify
                    215:    it under the terms of the GNU General Public License as published by
                    216:    the Free Software Foundation; either version 1, or (at your option)
                    217:    any later version.
                    218: 
                    219:    This program is distributed in the hope that it will be useful,
                    220:    but WITHOUT ANY WARRANTY; without even the implied warranty of
                    221:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                    222:    GNU General Public License for more details.
                    223: 
                    224:    You should have received a copy of the GNU General Public License
                    225:    along with this program; if not, write to the Free Software
                    226:    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
1.1.1.2   root      227: 
1.1       root      228: 
1.1.1.8 ! root      229: #ifdef __GNUC__
        !           230: #define alloca __builtin_alloca
        !           231: #else /* Not GNU C.  */
1.1.1.6   root      232: #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
                    233: #include <alloca.h>
1.1.1.8 ! root      234: #endif /* Sparc.  */
        !           235: #endif /* Not GNU C.  */
1.1.1.6   root      236: 
1.1       root      237: /* This is the parser code that is written into each bison parser
                    238:   when the %semantic_parser declaration is not specified in the grammar.
                    239:   It was written by Richard Stallman by simplifying the hairy parser
                    240:   used when %semantic_parser is specified.  */
                    241: 
                    242: /* Note: there must be only one dollar sign in this file.
                    243:    It is replaced by the list of actions, each action
                    244:    as one case of the switch.  */
                    245: 
                    246: #define yyerrok                (yyerrstatus = 0)
                    247: #define yyclearin      (yychar = YYEMPTY)
                    248: #define YYEMPTY                -2
                    249: #define YYEOF          0
                    250: #define YYFAIL         goto yyerrlab;
1.1.1.6   root      251: #define YYACCEPT       return(0)
                    252: #define YYABORT        return(1)
                    253: #define YYERROR                goto yyerrlab
1.1       root      254: 
                    255: #define YYTERROR       1
1.1.1.7   root      256: #define YYERRCODE      256
1.1       root      257: 
                    258: #ifndef YYIMPURE
                    259: #define YYLEX          yylex()
                    260: #endif
                    261: 
                    262: #ifndef YYPURE
                    263: #define YYLEX          yylex(&yylval, &yylloc)
                    264: #endif
                    265: 
                    266: /* If nonreentrant, generate the variables here */
                    267: 
                    268: #ifndef YYIMPURE
                    269: 
                    270: int    yychar;                 /*  the lookahead symbol                */
                    271: YYSTYPE        yylval;                 /*  the semantic value of the           */
                    272:                                /*  lookahead symbol                    */
                    273: 
1.1.1.8 ! root      274: #ifdef YYLSP_NEEDED
1.1       root      275: YYLTYPE yylloc;                        /*  location data for the lookahead     */
                    276:                                /*  symbol                              */
1.1.1.8 ! root      277: #endif
1.1       root      278: 
1.1.1.6   root      279: int yynerrs;                   /*  number of parse errors so far       */
1.1       root      280: #endif  /* YYIMPURE */
                    281: 
1.1.1.6   root      282: #if YYDEBUG != 0
                    283: int yydebug;                   /*  nonzero means print parse trace     */
                    284: /* Since this is uninitialized, it does not stop multiple parsers
                    285:    from coexisting.  */
                    286: #endif
1.1       root      287: 
                    288: /*  YYMAXDEPTH indicates the initial size of the parser's stacks       */
                    289: 
                    290: #ifndef        YYMAXDEPTH
                    291: #define YYMAXDEPTH 200
                    292: #endif
                    293: 
                    294: /*  YYMAXLIMIT is the maximum size the stacks can grow to
                    295:     (effective only if the built-in stack extension method is used).  */
                    296: 
                    297: #ifndef YYMAXLIMIT
                    298: #define YYMAXLIMIT 10000
                    299: #endif
                    300: 
1.1.1.8 ! root      301: /* This is the most reliable way to avoid incompatibilities
        !           302:    in available built-in functions on various systems.  */
        !           303: static void
        !           304: __yy_bcopy (from, to, count)
        !           305:      char *from;
        !           306:      char *to;
        !           307:      int count;
        !           308: {
        !           309:   register char *f = from;
        !           310:   register char *t = to;
        !           311:   register int i = count;
        !           312: 
        !           313:   while (i-- > 0)
        !           314:     *t++ = *f++;
        !           315: }
1.1       root      316: 
1.1.1.8 ! root      317: #line 111 "bison.simple"
1.1       root      318: int
                    319: yyparse()
                    320: {
                    321:   register int yystate;
                    322:   register int yyn;
                    323:   register short *yyssp;
                    324:   register YYSTYPE *yyvsp;
                    325:   int yyerrstatus;     /*  number of tokens to shift before error messages enabled */
                    326:   int yychar1;         /*  lookahead token as an internal (translated) token number */
                    327: 
                    328:   short        yyssa[YYMAXDEPTH];      /*  the state stack                     */
                    329:   YYSTYPE yyvsa[YYMAXDEPTH];   /*  the semantic value stack            */
                    330: 
                    331:   short *yyss = yyssa;         /*  refer to the stacks thru separate pointers */
                    332:   YYSTYPE *yyvs = yyvsa;       /*  to allow yyoverflow to reallocate them elsewhere */
1.1.1.8 ! root      333: 
        !           334: #ifdef YYLSP_NEEDED
1.1       root      335:   YYLTYPE *yyls = yylsa;
1.1.1.8 ! root      336:   YYLTYPE *yylsp;
        !           337:   YYLTYPE yylsa[YYMAXDEPTH];   /*  the location stack                  */
        !           338: #endif
1.1       root      339: 
                    340:   int yymaxdepth = YYMAXDEPTH;
                    341: 
                    342: #ifndef YYPURE
                    343:   int yychar;
                    344:   YYSTYPE yylval;
1.1.1.6   root      345:   int yynerrs;
1.1.1.8 ! root      346: #ifdef YYLSP_NEEDED
        !           347:   YYLTYPE yylloc;
        !           348: #endif
1.1.1.2   root      349: #endif
1.1       root      350: 
                    351:   YYSTYPE yyval;               /*  the variable used to return         */
                    352:                                /*  semantic values from the action     */
                    353:                                /*  routines                            */
                    354: 
                    355:   int yylen;
                    356: 
1.1.1.6   root      357: #if YYDEBUG != 0
1.1       root      358:   if (yydebug)
                    359:     fprintf(stderr, "Starting parse\n");
1.1.1.2   root      360: #endif
1.1       root      361: 
                    362:   yystate = 0;
                    363:   yyerrstatus = 0;
1.1.1.6   root      364:   yynerrs = 0;
1.1       root      365:   yychar = YYEMPTY;            /* Cause a token to be read.  */
                    366: 
                    367:   /* Initialize stack pointers.
                    368:      Waste one element of value and location stack
                    369:      so that they stay on the same level as the state stack.  */
                    370: 
                    371:   yyssp = yyss - 1;
                    372:   yyvsp = yyvs;
1.1.1.8 ! root      373: #ifdef YYLSP_NEEDED
1.1       root      374:   yylsp = yyls;
1.1.1.8 ! root      375: #endif
1.1       root      376: 
                    377: /* Push a new state, which is found in  yystate  .  */
                    378: /* In all cases, when you get here, the value and location stacks
                    379:    have just been pushed. so pushing a state here evens the stacks.  */
                    380: yynewstate:
                    381: 
                    382:   *++yyssp = yystate;
                    383: 
                    384:   if (yyssp >= yyss + yymaxdepth - 1)
                    385:     {
                    386:       /* Give user a chance to reallocate the stack */
                    387:       /* Use copies of these so that the &'s don't force the real ones into memory. */
                    388:       YYSTYPE *yyvs1 = yyvs;
                    389:       short *yyss1 = yyss;
1.1.1.8 ! root      390: #ifdef YYLSP_NEEDED
        !           391:       YYLTYPE *yyls1 = yyls;
        !           392: #endif
1.1       root      393: 
                    394:       /* Get the current used size of the three stacks, in elements.  */
                    395:       int size = yyssp - yyss + 1;
                    396: 
                    397: #ifdef yyoverflow
                    398:       /* Each stack pointer address is followed by the size of
                    399:         the data in use in that stack, in bytes.  */
                    400:       yyoverflow("parser stack overflow",
                    401:                 &yyss1, size * sizeof (*yyssp),
                    402:                 &yyvs1, size * sizeof (*yyvsp),
1.1.1.8 ! root      403: #ifdef YYLSP_NEEDED
1.1       root      404:                 &yyls1, size * sizeof (*yylsp),
1.1.1.8 ! root      405: #endif
1.1       root      406:                 &yymaxdepth);
                    407: 
1.1.1.8 ! root      408:       yyss = yyss1; yyvs = yyvs1;
        !           409: #ifdef YYLSP_NEEDED
        !           410:       yyls = yyls1;
        !           411: #endif
1.1       root      412: #else /* no yyoverflow */
                    413:       /* Extend the stack our own way.  */
                    414:       if (yymaxdepth >= YYMAXLIMIT)
                    415:        yyerror("parser stack overflow");
                    416:       yymaxdepth *= 2;
                    417:       if (yymaxdepth > YYMAXLIMIT)
                    418:        yymaxdepth = YYMAXLIMIT;
                    419:       yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
1.1.1.8 ! root      420:       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
1.1       root      421:       yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
1.1.1.8 ! root      422:       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
1.1.1.3   root      423: #ifdef YYLSP_NEEDED
1.1.1.2   root      424:       yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
1.1.1.8 ! root      425:       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
1.1.1.2   root      426: #endif
1.1       root      427: #endif /* no yyoverflow */
                    428: 
                    429:       yyssp = yyss + size - 1;
                    430:       yyvsp = yyvs + size - 1;
1.1.1.3   root      431: #ifdef YYLSP_NEEDED
1.1.1.2   root      432:       yylsp = yyls + size - 1;
                    433: #endif
1.1       root      434: 
1.1.1.6   root      435: #if YYDEBUG != 0
1.1       root      436:       if (yydebug)
                    437:        fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
1.1.1.2   root      438: #endif
1.1       root      439: 
                    440:       if (yyssp >= yyss + yymaxdepth - 1)
1.1.1.6   root      441:        YYABORT;
1.1       root      442:     }
                    443: 
1.1.1.6   root      444: #if YYDEBUG != 0
1.1       root      445:   if (yydebug)
                    446:     fprintf(stderr, "Entering state %d\n", yystate);
1.1.1.2   root      447: #endif
1.1       root      448: 
                    449: /* Do appropriate processing given the current state.  */
                    450: /* Read a lookahead token if we need one and don't already have one.  */
1.1.1.8 ! root      451: /* yyresume: */
1.1       root      452: 
                    453:   /* First try to decide what to do without reference to lookahead token.  */
                    454: 
                    455:   yyn = yypact[yystate];
                    456:   if (yyn == YYFLAG)
                    457:     goto yydefault;
                    458: 
                    459:   /* Not known => get a lookahead token if don't already have one.  */
                    460: 
                    461:   /* yychar is either YYEMPTY or YYEOF
                    462:      or a valid token in external form.  */
                    463: 
                    464:   if (yychar == YYEMPTY)
                    465:     {
1.1.1.6   root      466: #if YYDEBUG != 0
1.1.1.2   root      467:       if (yydebug)
                    468:        fprintf(stderr, "Reading a token: ");
                    469: #endif
1.1       root      470:       yychar = YYLEX;
                    471:     }
                    472: 
                    473:   /* Convert token to internal form (in yychar1) for indexing tables with */
                    474: 
                    475:   if (yychar <= 0)             /* This means end of input. */
                    476:     {
                    477:       yychar1 = 0;
                    478:       yychar = YYEOF;          /* Don't call YYLEX any more */
                    479: 
1.1.1.6   root      480: #if YYDEBUG != 0
1.1       root      481:       if (yydebug)
                    482:        fprintf(stderr, "Now at end of input.\n");
1.1.1.2   root      483: #endif
1.1       root      484:     }
                    485:   else
                    486:     {
                    487:       yychar1 = YYTRANSLATE(yychar);
                    488: 
1.1.1.6   root      489: #if YYDEBUG != 0
1.1       root      490:       if (yydebug)
1.1.1.2   root      491:        fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
                    492: #endif
1.1       root      493:     }
                    494: 
                    495:   yyn += yychar1;
                    496:   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
                    497:     goto yydefault;
                    498: 
                    499:   yyn = yytable[yyn];
                    500: 
                    501:   /* yyn is what to do for this token type in this state.
                    502:      Negative => reduce, -yyn is rule number.
                    503:      Positive => shift, yyn is new state.
                    504:        New state is final state => don't bother to shift,
                    505:        just return success.
                    506:      0, or most negative number => error.  */
                    507: 
                    508:   if (yyn < 0)
                    509:     {
                    510:       if (yyn == YYFLAG)
                    511:        goto yyerrlab;
                    512:       yyn = -yyn;
                    513:       goto yyreduce;
                    514:     }
                    515:   else if (yyn == 0)
                    516:     goto yyerrlab;
                    517: 
                    518:   if (yyn == YYFINAL)
                    519:     YYACCEPT;
                    520: 
                    521:   /* Shift the lookahead token.  */
                    522: 
1.1.1.6   root      523: #if YYDEBUG != 0
1.1       root      524:   if (yydebug)
                    525:     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1.1.1.2   root      526: #endif
1.1       root      527: 
                    528:   /* Discard the token being shifted unless it is eof.  */
                    529:   if (yychar != YYEOF)
                    530:     yychar = YYEMPTY;
                    531: 
                    532:   *++yyvsp = yylval;
1.1.1.3   root      533: #ifdef YYLSP_NEEDED
1.1       root      534:   *++yylsp = yylloc;
1.1.1.2   root      535: #endif
1.1       root      536: 
                    537:   /* count tokens shifted since error; after three, turn off error status.  */
                    538:   if (yyerrstatus) yyerrstatus--;
                    539: 
                    540:   yystate = yyn;
                    541:   goto yynewstate;
                    542: 
                    543: /* Do the default action for the current state.  */
                    544: yydefault:
                    545: 
                    546:   yyn = yydefact[yystate];
                    547:   if (yyn == 0)
                    548:     goto yyerrlab;
                    549: 
                    550: /* Do a reduction.  yyn is the number of a rule to reduce with.  */
                    551: yyreduce:
                    552:   yylen = yyr2[yyn];
                    553:   yyval = yyvsp[1-yylen]; /* implement default value of the action */
                    554: 
1.1.1.6   root      555: #if YYDEBUG != 0
1.1       root      556:   if (yydebug)
                    557:     {
                    558:       if (yylen == 1)
1.1.1.8 ! root      559:        fprintf (stderr, "Reducing 1 value via rule %d (line %d), ",
        !           560:                 yyn, yyrline[yyn]);
1.1       root      561:       else
1.1.1.8 ! root      562:        fprintf (stderr, "Reducing %d values via rule %d (line %d), ",
        !           563:                 yylen, yyn, yyrline[yyn]);
1.1       root      564:     }
1.1.1.2   root      565: #endif
1.1       root      566: 
                    567: 
                    568:   switch (yyn) {
                    569: 
                    570: case 1:
1.1.1.8 ! root      571: #line 75 "ccdir/cexp.y"
1.1.1.7   root      572: { expression_value = yyvsp[0].integer.value; ;
1.1       root      573:     break;}
                    574: case 3:
1.1.1.8 ! root      575: #line 81 "ccdir/cexp.y"
1.1.1.7   root      576: { yyval.integer = yyvsp[0].integer; ;
1.1       root      577:     break;}
                    578: case 4:
1.1.1.8 ! root      579: #line 86 "ccdir/cexp.y"
1.1.1.7   root      580: { yyval.integer.value = - yyvsp[0].integer.value;
                    581:                          yyval.integer.unsignedp = yyvsp[0].integer.unsignedp; ;
1.1       root      582:     break;}
                    583: case 5:
1.1.1.8 ! root      584: #line 89 "ccdir/cexp.y"
1.1.1.7   root      585: { yyval.integer.value = ! yyvsp[0].integer.value;
                    586:                          yyval.integer.unsignedp = 0; ;
1.1       root      587:     break;}
                    588: case 6:
1.1.1.8 ! root      589: #line 92 "ccdir/cexp.y"
1.1.1.7   root      590: { yyval.integer = yyvsp[0].integer; ;
1.1       root      591:     break;}
                    592: case 7:
1.1.1.8 ! root      593: #line 94 "ccdir/cexp.y"
1.1.1.7   root      594: { yyval.integer.value = ~ yyvsp[0].integer.value;
                    595:                          yyval.integer.unsignedp = yyvsp[0].integer.unsignedp; ;
1.1       root      596:     break;}
                    597: case 8:
1.1.1.8 ! root      598: #line 97 "ccdir/cexp.y"
1.1.1.7   root      599: { yyval.integer = yyvsp[-1].integer; ;
1.1       root      600:     break;}
                    601: case 9:
1.1.1.8 ! root      602: #line 102 "ccdir/cexp.y"
1.1.1.7   root      603: { yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp;
                    604:                          if (yyval.integer.unsignedp)
                    605:                            yyval.integer.value = (unsigned) yyvsp[-2].integer.value * yyvsp[0].integer.value;
                    606:                          else
                    607:                            yyval.integer.value = yyvsp[-2].integer.value * yyvsp[0].integer.value; ;
1.1       root      608:     break;}
                    609: case 10:
1.1.1.8 ! root      610: #line 108 "ccdir/cexp.y"
1.1.1.7   root      611: { if (yyvsp[0].integer.value == 0)
1.1.1.6   root      612:                            {
                    613:                              error ("division by zero in #if");
1.1.1.7   root      614:                              yyvsp[0].integer.value = 1;
1.1.1.6   root      615:                            }
1.1.1.7   root      616:                          yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp;
                    617:                          if (yyval.integer.unsignedp)
                    618:                            yyval.integer.value = (unsigned) yyvsp[-2].integer.value / yyvsp[0].integer.value;
                    619:                          else
                    620:                            yyval.integer.value = yyvsp[-2].integer.value / yyvsp[0].integer.value; ;
1.1       root      621:     break;}
                    622: case 11:
1.1.1.8 ! root      623: #line 119 "ccdir/cexp.y"
1.1.1.7   root      624: { if (yyvsp[0].integer.value == 0)
                    625:                            {
                    626:                              error ("division by zero in #if");
                    627:                              yyvsp[0].integer.value = 1;
                    628:                            }
                    629:                          yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp;
                    630:                          if (yyval.integer.unsignedp)
                    631:                            yyval.integer.value = (unsigned) yyvsp[-2].integer.value % yyvsp[0].integer.value;
                    632:                          else
                    633:                            yyval.integer.value = yyvsp[-2].integer.value % yyvsp[0].integer.value; ;
1.1       root      634:     break;}
                    635: case 12:
1.1.1.8 ! root      636: #line 130 "ccdir/cexp.y"
1.1.1.7   root      637: { yyval.integer.value = yyvsp[-2].integer.value + yyvsp[0].integer.value;
                    638:                          yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
1.1       root      639:     break;}
                    640: case 13:
1.1.1.8 ! root      641: #line 133 "ccdir/cexp.y"
1.1.1.7   root      642: { yyval.integer.value = yyvsp[-2].integer.value - yyvsp[0].integer.value;
                    643:                          yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
1.1       root      644:     break;}
                    645: case 14:
1.1.1.8 ! root      646: #line 136 "ccdir/cexp.y"
1.1.1.7   root      647: { yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp;
                    648:                          if (yyval.integer.unsignedp)
                    649:                            yyval.integer.value = (unsigned) yyvsp[-2].integer.value << yyvsp[0].integer.value;
                    650:                          else
                    651:                            yyval.integer.value = yyvsp[-2].integer.value << yyvsp[0].integer.value; ;
1.1       root      652:     break;}
                    653: case 15:
1.1.1.8 ! root      654: #line 142 "ccdir/cexp.y"
1.1.1.7   root      655: { yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp;
                    656:                          if (yyval.integer.unsignedp)
                    657:                            yyval.integer.value = (unsigned) yyvsp[-2].integer.value >> yyvsp[0].integer.value;
                    658:                          else
                    659:                            yyval.integer.value = yyvsp[-2].integer.value >> yyvsp[0].integer.value; ;
1.1       root      660:     break;}
                    661: case 16:
1.1.1.8 ! root      662: #line 148 "ccdir/cexp.y"
1.1.1.7   root      663: { yyval.integer.value = (yyvsp[-2].integer.value == yyvsp[0].integer.value);
                    664:                          yyval.integer.unsignedp = 0; ;
1.1       root      665:     break;}
                    666: case 17:
1.1.1.8 ! root      667: #line 151 "ccdir/cexp.y"
1.1.1.7   root      668: { yyval.integer.value = (yyvsp[-2].integer.value != yyvsp[0].integer.value);
                    669:                          yyval.integer.unsignedp = 0; ;
1.1       root      670:     break;}
                    671: case 18:
1.1.1.8 ! root      672: #line 154 "ccdir/cexp.y"
1.1.1.7   root      673: { yyval.integer.unsignedp = 0;
                    674:                          if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp)
                    675:                            yyval.integer.value = (unsigned) yyvsp[-2].integer.value <= yyvsp[0].integer.value;
                    676:                          else
                    677:                            yyval.integer.value = yyvsp[-2].integer.value <= yyvsp[0].integer.value; ;
1.1       root      678:     break;}
                    679: case 19:
1.1.1.8 ! root      680: #line 160 "ccdir/cexp.y"
1.1.1.7   root      681: { yyval.integer.unsignedp = 0;
                    682:                          if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp)
                    683:                            yyval.integer.value = (unsigned) yyvsp[-2].integer.value >= yyvsp[0].integer.value;
                    684:                          else
                    685:                            yyval.integer.value = yyvsp[-2].integer.value >= yyvsp[0].integer.value; ;
1.1       root      686:     break;}
                    687: case 20:
1.1.1.8 ! root      688: #line 166 "ccdir/cexp.y"
1.1.1.7   root      689: { yyval.integer.unsignedp = 0;
                    690:                          if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp)
                    691:                            yyval.integer.value = (unsigned) yyvsp[-2].integer.value < yyvsp[0].integer.value;
                    692:                          else
                    693:                            yyval.integer.value = yyvsp[-2].integer.value < yyvsp[0].integer.value; ;
1.1       root      694:     break;}
                    695: case 21:
1.1.1.8 ! root      696: #line 172 "ccdir/cexp.y"
1.1.1.7   root      697: { yyval.integer.unsignedp = 0;
                    698:                          if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp)
                    699:                            yyval.integer.value = (unsigned) yyvsp[-2].integer.value > yyvsp[0].integer.value;
                    700:                          else
                    701:                            yyval.integer.value = yyvsp[-2].integer.value > yyvsp[0].integer.value; ;
1.1       root      702:     break;}
                    703: case 22:
1.1.1.8 ! root      704: #line 178 "ccdir/cexp.y"
1.1.1.7   root      705: { yyval.integer.value = yyvsp[-2].integer.value & yyvsp[0].integer.value;
                    706:                          yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
1.1       root      707:     break;}
                    708: case 23:
1.1.1.8 ! root      709: #line 181 "ccdir/cexp.y"
1.1.1.7   root      710: { yyval.integer.value = yyvsp[-2].integer.value ^ yyvsp[0].integer.value;
                    711:                          yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
1.1       root      712:     break;}
                    713: case 24:
1.1.1.8 ! root      714: #line 184 "ccdir/cexp.y"
1.1.1.7   root      715: { yyval.integer.value = yyvsp[-2].integer.value | yyvsp[0].integer.value;
                    716:                          yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
1.1       root      717:     break;}
                    718: case 25:
1.1.1.8 ! root      719: #line 187 "ccdir/cexp.y"
1.1.1.7   root      720: { yyval.integer.value = (yyvsp[-2].integer.value && yyvsp[0].integer.value);
                    721:                          yyval.integer.unsignedp = 0; ;
1.1       root      722:     break;}
                    723: case 26:
1.1.1.8 ! root      724: #line 190 "ccdir/cexp.y"
1.1.1.7   root      725: { yyval.integer.value = (yyvsp[-2].integer.value || yyvsp[0].integer.value);
                    726:                          yyval.integer.unsignedp = 0; ;
1.1       root      727:     break;}
                    728: case 27:
1.1.1.8 ! root      729: #line 193 "ccdir/cexp.y"
1.1.1.7   root      730: { yyval.integer.value = yyvsp[-4].integer.value ? yyvsp[-2].integer.value : yyvsp[0].integer.value;
                    731:                          yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
1.1       root      732:     break;}
                    733: case 28:
1.1.1.8 ! root      734: #line 196 "ccdir/cexp.y"
1.1.1.7   root      735: { yyval.integer = yylval.integer; ;
1.1       root      736:     break;}
                    737: case 29:
1.1.1.8 ! root      738: #line 198 "ccdir/cexp.y"
1.1.1.7   root      739: { yyval.integer = yylval.integer; ;
                    740:     break;}
                    741: case 30:
1.1.1.8 ! root      742: #line 200 "ccdir/cexp.y"
1.1.1.7   root      743: { yyval.integer.value = 0;
                    744:                          yyval.integer.unsignedp = 0; ;
1.1       root      745:     break;}
                    746: }
                    747:    /* the action file gets copied in in place of this dollarsign */
1.1.1.8 ! root      748: #line 362 "bison.simple"
1.1       root      749: 
                    750:   yyvsp -= yylen;
                    751:   yyssp -= yylen;
1.1.1.3   root      752: #ifdef YYLSP_NEEDED
1.1.1.2   root      753:   yylsp -= yylen;
                    754: #endif
1.1       root      755: 
1.1.1.6   root      756: #if YYDEBUG != 0
1.1       root      757:   if (yydebug)
                    758:     {
                    759:       short *ssp1 = yyss - 1;
1.1.1.6   root      760:       fprintf (stderr, "state stack now");
1.1       root      761:       while (ssp1 != yyssp)
                    762:        fprintf (stderr, " %d", *++ssp1);
                    763:       fprintf (stderr, "\n");
                    764:     }
1.1.1.2   root      765: #endif
1.1       root      766: 
                    767:   *++yyvsp = yyval;
                    768: 
1.1.1.3   root      769: #ifdef YYLSP_NEEDED
1.1       root      770:   yylsp++;
                    771:   if (yylen == 0)
                    772:     {
                    773:       yylsp->first_line = yylloc.first_line;
                    774:       yylsp->first_column = yylloc.first_column;
                    775:       yylsp->last_line = (yylsp-1)->last_line;
                    776:       yylsp->last_column = (yylsp-1)->last_column;
                    777:       yylsp->text = 0;
                    778:     }
                    779:   else
                    780:     {
                    781:       yylsp->last_line = (yylsp+yylen-1)->last_line;
                    782:       yylsp->last_column = (yylsp+yylen-1)->last_column;
                    783:     }
1.1.1.2   root      784: #endif
1.1       root      785: 
                    786:   /* Now "shift" the result of the reduction.
                    787:      Determine what state that goes to,
                    788:      based on the state we popped back to
                    789:      and the rule number reduced by.  */
                    790: 
                    791:   yyn = yyr1[yyn];
                    792: 
                    793:   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
                    794:   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
                    795:     yystate = yytable[yystate];
                    796:   else
                    797:     yystate = yydefgoto[yyn - YYNTBASE];
                    798: 
                    799:   goto yynewstate;
                    800: 
                    801: yyerrlab:   /* here on detecting error */
                    802: 
                    803:   if (! yyerrstatus)
                    804:     /* If not already recovering from an error, report this error.  */
                    805:     {
1.1.1.6   root      806:       ++yynerrs;
1.1.1.8 ! root      807: 
        !           808: #ifdef YYERROR_VERBOSE
        !           809:       yyn = yypact[yystate];
        !           810: 
        !           811:       if (yyn > YYFLAG && yyn < YYLAST)
        !           812:        {
        !           813:          int size = 0;
        !           814:          char *msg;
        !           815:          int x, count;
        !           816: 
        !           817:          count = 0;
        !           818:          for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
        !           819:            if (yycheck[x + yyn] == x)
        !           820:              size += strlen(yytname[x]) + 15, count++;
        !           821:          msg = (char *) xmalloc(size + 15);
        !           822:          strcpy(msg, "parse error");
        !           823: 
        !           824:          if (count < 5)
        !           825:            {
        !           826:              count = 0;
        !           827:              for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
        !           828:                if (yycheck[x + yyn] == x)
        !           829:                  {
        !           830:                    strcat(msg, count == 0 ? ", expecting `" : " or `");
        !           831:                    strcat(msg, yytname[x]);
        !           832:                    strcat(msg, "'");
        !           833:                    count++;
        !           834:                  }
        !           835:            }
        !           836:          yyerror(msg);
        !           837:          free(msg);
        !           838:        }
        !           839:       else
        !           840: #endif /* YYERROR_VERBOSE */
        !           841:        yyerror("parse error");
1.1       root      842:     }
                    843: 
                    844:   if (yyerrstatus == 3)
                    845:     {
                    846:       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
                    847: 
                    848:       /* return failure if at end of input */
                    849:       if (yychar == YYEOF)
1.1.1.6   root      850:        YYABORT;
1.1       root      851: 
1.1.1.6   root      852: #if YYDEBUG != 0
1.1       root      853:       if (yydebug)
                    854:        fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1.1.1.2   root      855: #endif
1.1       root      856: 
                    857:       yychar = YYEMPTY;
                    858:     }
                    859: 
                    860:   /* Else will try to reuse lookahead token
                    861:      after shifting the error token.  */
                    862: 
                    863:   yyerrstatus = 3;             /* Each real token shifted decrements this */
                    864: 
                    865:   goto yyerrhandle;
                    866: 
                    867: yyerrdefault:  /* current state does not do anything special for the error token. */
                    868: 
                    869: #if 0
                    870:   /* This is wrong; only states that explicitly want error tokens
                    871:      should shift them.  */
                    872:   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
                    873:   if (yyn) goto yydefault;
                    874: #endif
                    875: 
                    876: yyerrpop:   /* pop the current state because it cannot handle the error token */
                    877: 
1.1.1.6   root      878:   if (yyssp == yyss) YYABORT;
1.1       root      879:   yyvsp--;
                    880:   yystate = *--yyssp;
1.1.1.3   root      881: #ifdef YYLSP_NEEDED
1.1.1.2   root      882:   yylsp--;
                    883: #endif
1.1       root      884: 
1.1.1.6   root      885: #if YYDEBUG != 0
1.1       root      886:   if (yydebug)
                    887:     {
                    888:       short *ssp1 = yyss - 1;
1.1.1.6   root      889:       fprintf (stderr, "Error: state stack now");
1.1       root      890:       while (ssp1 != yyssp)
                    891:        fprintf (stderr, " %d", *++ssp1);
                    892:       fprintf (stderr, "\n");
                    893:     }
1.1.1.2   root      894: #endif
1.1       root      895: 
                    896: yyerrhandle:
                    897: 
                    898:   yyn = yypact[yystate];
                    899:   if (yyn == YYFLAG)
                    900:     goto yyerrdefault;
                    901: 
                    902:   yyn += YYTERROR;
                    903:   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
                    904:     goto yyerrdefault;
                    905: 
                    906:   yyn = yytable[yyn];
                    907:   if (yyn < 0)
                    908:     {
                    909:       if (yyn == YYFLAG)
                    910:        goto yyerrpop;
                    911:       yyn = -yyn;
                    912:       goto yyreduce;
                    913:     }
                    914:   else if (yyn == 0)
                    915:     goto yyerrpop;
                    916: 
                    917:   if (yyn == YYFINAL)
                    918:     YYACCEPT;
                    919: 
1.1.1.6   root      920: #if YYDEBUG != 0
1.1       root      921:   if (yydebug)
                    922:     fprintf(stderr, "Shifting error token, ");
1.1.1.2   root      923: #endif
1.1       root      924: 
                    925:   *++yyvsp = yylval;
1.1.1.3   root      926: #ifdef YYLSP_NEEDED
1.1       root      927:   *++yylsp = yylloc;
1.1.1.2   root      928: #endif
1.1       root      929: 
                    930:   yystate = yyn;
                    931:   goto yynewstate;
                    932: }
1.1.1.8 ! root      933: #line 203 "ccdir/cexp.y"
1.1       root      934: 
                    935: 
                    936: /* During parsing of a C expression, the pointer to the next character
                    937:    is in this variable.  */
                    938: 
                    939: static char *lexptr;
                    940: 
                    941: /* Take care of parsing a number (anything that starts with a digit).
                    942:    Set yylval and return the token type; update lexptr.
                    943:    LEN is the number of characters in it.  */
                    944: 
                    945: /* maybe needs to actually deal with floating point numbers */
                    946: 
1.1.1.3   root      947: int
1.1       root      948: parse_number (olen)
                    949:      int olen;
                    950: {
                    951:   register char *p = lexptr;
                    952:   register long n = 0;
                    953:   register int c;
                    954:   register int base = 10;
1.1.1.7   root      955:   register int len = olen;
1.1       root      956: 
                    957:   for (c = 0; c < len; c++)
                    958:     if (p[c] == '.') {
                    959:       /* It's a float since it contains a point.  */
                    960:       yyerror ("floating point numbers not allowed in #if expressions");
                    961:       return ERROR;
                    962:     }
1.1.1.7   root      963: 
                    964:   yylval.integer.unsignedp = 0;
                    965: 
1.1       root      966:   if (len >= 3 && (!strncmp (p, "0x", 2) || !strncmp (p, "0X", 2))) {
                    967:     p += 2;
                    968:     base = 16;
                    969:     len -= 2;
                    970:   }
                    971:   else if (*p == '0')
                    972:     base = 8;
1.1.1.7   root      973: 
                    974:   while (len > 0) {
1.1       root      975:     c = *p++;
1.1.1.7   root      976:     len--;
                    977:     if (c >= 'A' && c <= 'Z') c += 'a' - 'A';
                    978: 
                    979:     if (c >= '0' && c <= '9') {
                    980:       n *= base;
1.1       root      981:       n += c - '0';
1.1.1.7   root      982:     } else if (base == 16 && c >= 'a' && c <= 'f') {
                    983:       n *= base;
                    984:       n += c - 'a' + 10;
                    985:     } else {
                    986:       /* `l' means long, and `u' means unsigned.  */
                    987:       while (1) {
                    988:        if (c == 'l' || c == 'L')
                    989:          ;
                    990:        else if (c == 'u' || c == 'U')
                    991:          yylval.integer.unsignedp = 1;
                    992:        else
                    993:          break;
                    994: 
                    995:        if (len == 0)
                    996:          break;
                    997:        c = *p++;
                    998:        len--;
1.1       root      999:       }
1.1.1.7   root     1000:       /* Don't look for any more digits after the suffixes.  */
                   1001:       break;
1.1       root     1002:     }
                   1003:   }
                   1004: 
1.1.1.7   root     1005:   if (len != 0) {
                   1006:     yyerror ("Invalid number in #if expression");
                   1007:     return ERROR;
                   1008:   }
                   1009: 
                   1010:   /* If too big to be signed, consider it unsigned.  */
                   1011:   if (n < 0)
                   1012:     yylval.integer.unsignedp = 1;
                   1013: 
1.1       root     1014:   lexptr = p;
1.1.1.7   root     1015:   yylval.integer.value = n;
1.1       root     1016:   return INT;
                   1017: }
                   1018: 
                   1019: struct token {
                   1020:   char *operator;
                   1021:   int token;
                   1022: };
                   1023: 
1.1.1.7   root     1024: #ifndef NULL
1.1       root     1025: #define NULL 0
1.1.1.7   root     1026: #endif
1.1       root     1027: 
                   1028: static struct token tokentab2[] = {
                   1029:   {"&&", AND},
                   1030:   {"||", OR},
                   1031:   {"<<", LSH},
                   1032:   {">>", RSH},
                   1033:   {"==", EQUAL},
                   1034:   {"!=", NOTEQUAL},
                   1035:   {"<=", LEQ},
                   1036:   {">=", GEQ},
                   1037:   {NULL, ERROR}
                   1038: };
                   1039: 
                   1040: /* Read one token, getting characters through lexptr.  */
                   1041: 
1.1.1.3   root     1042: int
1.1       root     1043: yylex ()
                   1044: {
                   1045:   register int c;
                   1046:   register int namelen;
                   1047:   register char *tokstart;
                   1048:   register struct token *toktab;
                   1049: 
                   1050:  retry:
                   1051: 
                   1052:   tokstart = lexptr;
                   1053:   c = *tokstart;
                   1054:   /* See if it is a special token of length 2.  */
                   1055:   for (toktab = tokentab2; toktab->operator != NULL; toktab++)
                   1056:     if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) {
                   1057:       lexptr += 2;
                   1058:       return toktab->token;
                   1059:     }
                   1060: 
                   1061:   switch (c) {
                   1062:   case 0:
                   1063:     return 0;
                   1064:     
                   1065:   case ' ':
                   1066:   case '\t':
1.1.1.8 ! root     1067:   case '\r':
1.1       root     1068:   case '\n':
                   1069:     lexptr++;
                   1070:     goto retry;
                   1071:     
                   1072:   case '\'':
                   1073:     lexptr++;
                   1074:     c = *lexptr++;
                   1075:     if (c == '\\')
                   1076:       c = parse_escape (&lexptr);
1.1.1.7   root     1077: 
                   1078:     /* Sign-extend the constant if chars are signed on target machine.  */
                   1079:     {
                   1080:       if (lookup ("__CHAR_UNSIGNED__", sizeof ("__CHAR_UNSIGNED__")-1, -1)
                   1081:          || ((c >> (CHAR_TYPE_SIZE - 1)) & 1) == 0)
                   1082:        yylval.integer.value = c & ((1 << CHAR_TYPE_SIZE) - 1);
                   1083:       else
                   1084:        yylval.integer.value = c | ~((1 << CHAR_TYPE_SIZE) - 1);
                   1085:     }
                   1086: 
                   1087:     yylval.integer.unsignedp = 0;
1.1       root     1088:     c = *lexptr++;
                   1089:     if (c != '\'') {
                   1090:       yyerror ("Invalid character constant in #if");
                   1091:       return ERROR;
                   1092:     }
                   1093:     
                   1094:     return CHAR;
                   1095: 
                   1096:     /* some of these chars are invalid in constant expressions;
                   1097:        maybe do something about them later */
                   1098:   case '/':
                   1099:   case '+':
                   1100:   case '-':
                   1101:   case '*':
                   1102:   case '%':
                   1103:   case '|':
                   1104:   case '&':
                   1105:   case '^':
                   1106:   case '~':
                   1107:   case '!':
                   1108:   case '@':
                   1109:   case '<':
                   1110:   case '>':
                   1111:   case '(':
                   1112:   case ')':
                   1113:   case '[':
                   1114:   case ']':
                   1115:   case '.':
                   1116:   case '?':
                   1117:   case ':':
                   1118:   case '=':
                   1119:   case '{':
                   1120:   case '}':
                   1121:   case ',':
                   1122:     lexptr++;
                   1123:     return c;
                   1124:     
                   1125:   case '"':
                   1126:     yyerror ("double quoted strings not allowed in #if expressions");
                   1127:     return ERROR;
                   1128:   }
                   1129:   if (c >= '0' && c <= '9') {
                   1130:     /* It's a number */
                   1131:     for (namelen = 0;
                   1132:         c = tokstart[namelen], is_idchar[c] || c == '.'; 
                   1133:         namelen++)
                   1134:       ;
                   1135:     return parse_number (namelen);
                   1136:   }
                   1137:   
                   1138:   if (!is_idstart[c]) {
                   1139:     yyerror ("Invalid token in expression");
                   1140:     return ERROR;
                   1141:   }
                   1142:   
                   1143:   /* It is a name.  See how long it is.  */
                   1144:   
                   1145:   for (namelen = 0; is_idchar[tokstart[namelen]]; namelen++)
                   1146:     ;
                   1147:   
                   1148:   lexptr += namelen;
                   1149:   return NAME;
                   1150: }
                   1151: 
                   1152: 
                   1153: /* Parse a C escape sequence.  STRING_PTR points to a variable
                   1154:    containing a pointer to the string to parse.  That pointer
                   1155:    is updated past the characters we use.  The value of the
                   1156:    escape sequence is returned.
                   1157: 
                   1158:    A negative value means the sequence \ newline was seen,
                   1159:    which is supposed to be equivalent to nothing at all.
                   1160: 
                   1161:    If \ is followed by a null character, we return a negative
                   1162:    value and leave the string pointer pointing at the null character.
                   1163: 
                   1164:    If \ is followed by 000, we return 0 and leave the string pointer
                   1165:    after the zeros.  A value of 0 does not mean end of string.  */
                   1166: 
1.1.1.3   root     1167: int
1.1       root     1168: parse_escape (string_ptr)
                   1169:      char **string_ptr;
                   1170: {
                   1171:   register int c = *(*string_ptr)++;
                   1172:   switch (c)
                   1173:     {
                   1174:     case 'a':
1.1.1.7   root     1175:       return TARGET_BELL;
1.1       root     1176:     case 'b':
1.1.1.7   root     1177:       return TARGET_BS;
1.1       root     1178:     case 'e':
                   1179:       return 033;
                   1180:     case 'f':
1.1.1.7   root     1181:       return TARGET_FF;
1.1       root     1182:     case 'n':
1.1.1.7   root     1183:       return TARGET_NEWLINE;
1.1       root     1184:     case 'r':
1.1.1.7   root     1185:       return TARGET_CR;
1.1       root     1186:     case 't':
1.1.1.7   root     1187:       return TARGET_TAB;
1.1       root     1188:     case 'v':
1.1.1.7   root     1189:       return TARGET_VT;
1.1       root     1190:     case '\n':
                   1191:       return -2;
                   1192:     case 0:
                   1193:       (*string_ptr)--;
                   1194:       return 0;
                   1195:     case '^':
                   1196:       c = *(*string_ptr)++;
                   1197:       if (c == '\\')
                   1198:        c = parse_escape (string_ptr);
                   1199:       if (c == '?')
                   1200:        return 0177;
                   1201:       return (c & 0200) | (c & 037);
                   1202:       
                   1203:     case '0':
                   1204:     case '1':
                   1205:     case '2':
                   1206:     case '3':
                   1207:     case '4':
                   1208:     case '5':
                   1209:     case '6':
                   1210:     case '7':
                   1211:       {
                   1212:        register int i = c - '0';
                   1213:        register int count = 0;
                   1214:        while (++count < 3)
                   1215:          {
1.1.1.7   root     1216:            c = *(*string_ptr)++;
                   1217:            if (c >= '0' && c <= '7')
                   1218:              i = (i << 3) + c - '0';
                   1219:            else
1.1       root     1220:              {
1.1.1.7   root     1221:                (*string_ptr)--;
                   1222:                break;
1.1       root     1223:              }
1.1.1.7   root     1224:          }
                   1225:        if ((i & ~((1 << CHAR_TYPE_SIZE) - 1)) != 0)
                   1226:          {
                   1227:            i &= (1 << CHAR_TYPE_SIZE) - 1;
                   1228:            warning ("octal character constant does not fit in a byte");
                   1229:          }
                   1230:        return i;
                   1231:       }
                   1232:     case 'x':
                   1233:       {
                   1234:        register int i = 0;
                   1235:        register int count = 0;
                   1236:        for (;;)
                   1237:          {
                   1238:            c = *(*string_ptr)++;
                   1239:            if (c >= '0' && c <= '9')
                   1240:              i = (i << 4) + c - '0';
                   1241:            else if (c >= 'a' && c <= 'f')
                   1242:              i = (i << 4) + c - 'a' + 10;
                   1243:            else if (c >= 'A' && c <= 'F')
                   1244:              i = (i << 4) + c - 'A' + 10;
1.1       root     1245:            else
                   1246:              {
                   1247:                (*string_ptr)--;
                   1248:                break;
                   1249:              }
                   1250:          }
1.1.1.7   root     1251:        if ((i & ~((1 << BITS_PER_UNIT) - 1)) != 0)
                   1252:          {
                   1253:            i &= (1 << BITS_PER_UNIT) - 1;
                   1254:            warning ("hex character constant does not fit in a byte");
                   1255:          }
1.1       root     1256:        return i;
                   1257:       }
                   1258:     default:
                   1259:       return c;
                   1260:     }
                   1261: }
                   1262: 
1.1.1.3   root     1263: void
1.1       root     1264: yyerror (s)
                   1265:      char *s;
                   1266: {
                   1267:   error (s);
                   1268:   longjmp (parse_return_error, 1);
                   1269: }
                   1270: 
                   1271: /* This page contains the entry point to this file.  */
                   1272: 
                   1273: /* Parse STRING as an expression, and complain if this fails
                   1274:    to use up all of the contents of STRING.  */
                   1275: /* We do not support C comments.  They should be removed before
                   1276:    this function is called.  */
                   1277: 
                   1278: int
                   1279: parse_c_expression (string)
                   1280:      char *string;
                   1281: {
                   1282:   lexptr = string;
                   1283:   
                   1284:   if (lexptr == 0 || *lexptr == 0) {
                   1285:     error ("empty #if expression");
                   1286:     return 0;                  /* don't include the #if group */
                   1287:   }
                   1288: 
                   1289:   /* if there is some sort of scanning error, just return 0 and assume
                   1290:      the parsing routine has printed an error message somewhere.
                   1291:      there is surely a better thing to do than this.     */
1.1.1.7   root     1292:   if (setjmp (parse_return_error))
1.1       root     1293:     return 0;
                   1294: 
                   1295:   if (yyparse ())
                   1296:     return 0;                  /* actually this is never reached
                   1297:                                   the way things stand. */
                   1298:   if (*lexptr)
                   1299:     error ("Junk after end of expression.");
                   1300: 
1.1.1.7   root     1301:   return expression_value;     /* set by yyparse () */
1.1       root     1302: }
                   1303: 
                   1304: #ifdef TEST_EXP_READER
                   1305: /* main program, for testing purposes. */
1.1.1.7   root     1306: main ()
1.1       root     1307: {
1.1.1.7   root     1308:   int n, c;
1.1       root     1309:   char buf[1024];
                   1310:   extern int yydebug;
                   1311: /*
                   1312:   yydebug = 1;
                   1313: */
                   1314:   initialize_random_junk ();
                   1315: 
                   1316:   for (;;) {
1.1.1.7   root     1317:     printf ("enter expression: ");
1.1       root     1318:     n = 0;
1.1.1.7   root     1319:     while ((buf[n] = getchar ()) != '\n' && buf[n] != EOF)
1.1       root     1320:       n++;
1.1.1.7   root     1321:     if (buf[n] == EOF)
                   1322:       break;
1.1       root     1323:     buf[n] = '\0';
1.1.1.7   root     1324:     printf ("parser returned %d\n", parse_c_expression (buf));
1.1       root     1325:   }
                   1326: }
                   1327: 
                   1328: /* table to tell if char can be part of a C identifier. */
1.1.1.7   root     1329: unsigned char is_idchar[256];
1.1       root     1330: /* table to tell if char can be first char of a c identifier. */
1.1.1.7   root     1331: unsigned char is_idstart[256];
                   1332: /* table to tell if c is horizontal space.  isspace () thinks that
1.1       root     1333:    newline is space; this is not a good idea for this program. */
                   1334: char is_hor_space[256];
                   1335: 
                   1336: /*
                   1337:  * initialize random junk in the hash table and maybe other places
                   1338:  */
1.1.1.7   root     1339: initialize_random_junk ()
1.1       root     1340: {
                   1341:   register int i;
                   1342: 
                   1343:   /*
                   1344:    * Set up is_idchar and is_idstart tables.  These should be
1.1.1.7   root     1345:    * faster than saying (is_alpha (c) || c == '_'), etc.
1.1       root     1346:    * Must do set up these things before calling any routines tthat
                   1347:    * refer to them.
                   1348:    */
                   1349:   for (i = 'a'; i <= 'z'; i++) {
                   1350:     ++is_idchar[i - 'a' + 'A'];
                   1351:     ++is_idchar[i];
                   1352:     ++is_idstart[i - 'a' + 'A'];
                   1353:     ++is_idstart[i];
                   1354:   }
                   1355:   for (i = '0'; i <= '9'; i++)
                   1356:     ++is_idchar[i];
                   1357:   ++is_idchar['_'];
                   1358:   ++is_idstart['_'];
1.1.1.7   root     1359: #if DOLLARS_IN_IDENTIFIERS
1.1       root     1360:   ++is_idchar['$'];
                   1361:   ++is_idstart['$'];
                   1362: #endif
                   1363: 
                   1364:   /* horizontal space table */
                   1365:   ++is_hor_space[' '];
                   1366:   ++is_hor_space['\t'];
                   1367: }
                   1368: 
                   1369: error (msg)
                   1370: {
1.1.1.7   root     1371:   printf ("error: %s\n", msg);
                   1372: }
                   1373: 
                   1374: warning (msg)
                   1375: {
                   1376:   printf ("warning: %s\n", msg);
                   1377: }
                   1378: 
                   1379: struct hashnode *
                   1380: lookup (name, len, hash)
                   1381:      char *name;
                   1382:      int len;
                   1383:      int hash;
                   1384: {
                   1385:   return (DEFAULT_SIGNED_CHAR) ? 0 : ((struct hashnode *) -1);
1.1       root     1386: }
                   1387: #endif

unix.superglobalmegacorp.com

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