Annotation of gcc/c-lex.c, revision 1.1.1.6

1.1.1.2   root        1: /* Lexical analyzer for C and Objective C.
1.1       root        2:    Copyright (C) 1987, 1988, 1989, 1992 Free Software Foundation, Inc.
                      3: 
                      4: This file is part of GNU CC.
                      5: 
                      6: GNU CC is free software; you can redistribute it and/or modify
                      7: it under the terms of the GNU General Public License as published by
                      8: the Free Software Foundation; either version 2, or (at your option)
                      9: any later version.
                     10: 
                     11: GNU CC is distributed in the hope that it will be useful,
                     12: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     14: GNU General Public License for more details.
                     15: 
                     16: You should have received a copy of the GNU General Public License
                     17: along with GNU CC; see the file COPYING.  If not, write to
                     18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
                     19: 
                     20: 
                     21: #include <stdio.h>
                     22: #include <errno.h>
                     23: #include <setjmp.h>
                     24: 
                     25: #include "config.h"
                     26: #include "rtl.h"
                     27: #include "tree.h"
                     28: #include "input.h"
                     29: #include "c-lex.h"
                     30: #include "c-tree.h"
                     31: #include "flags.h"
                     32: #include "c-parse.h"
                     33: 
1.1.1.6 ! root       34: #include <ctype.h>
        !            35: 
1.1       root       36: #ifdef MULTIBYTE_CHARS
                     37: #include <stdlib.h>
                     38: #include <locale.h>
                     39: #endif
                     40: 
                     41: #ifndef errno
                     42: extern int errno;
                     43: #endif
                     44: 
                     45: /* The elements of `ridpointers' are identifier nodes
                     46:    for the reserved type names and storage classes.
                     47:    It is indexed by a RID_... value.  */
                     48: tree ridpointers[(int) RID_MAX];
                     49: 
                     50: /* Cause the `yydebug' variable to be defined.  */
                     51: #define YYDEBUG 1
                     52: 
                     53: /* the declaration found for the last IDENTIFIER token read in.
                     54:    yylex must look this up to detect typedefs, which get token type TYPENAME,
                     55:    so it is left around in case the identifier is not a typedef but is
                     56:    used in a context which makes it a reference to a variable.  */
                     57: tree lastiddecl;
                     58: 
                     59: /* Nonzero enables objc features.  */
                     60: 
                     61: int doing_objc_thang;
                     62: 
1.1.1.5   root       63: extern tree is_class_name ();
1.1       root       64: 
                     65: extern int yydebug;
                     66: 
                     67: /* File used for outputting assembler code.  */
                     68: extern FILE *asm_out_file;
                     69: 
                     70: #ifndef WCHAR_TYPE_SIZE
                     71: #ifdef INT_TYPE_SIZE
                     72: #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
                     73: #else
                     74: #define WCHAR_TYPE_SIZE        BITS_PER_WORD
                     75: #endif
                     76: #endif
                     77: 
                     78: /* Number of bytes in a wide character.  */
                     79: #define WCHAR_BYTES (WCHAR_TYPE_SIZE / BITS_PER_UNIT)
                     80: 
                     81: static int maxtoken;           /* Current nominal length of token buffer.  */
                     82: char *token_buffer;    /* Pointer to token buffer.
                     83:                           Actual allocated length is maxtoken + 2.
                     84:                           This is not static because objc-parse.y uses it.  */
                     85: 
                     86: /* Nonzero if end-of-file has been seen on input.  */
                     87: static int end_of_file;
                     88: 
                     89: /* Buffered-back input character; faster than using ungetc.  */
                     90: static int nextchar = -1;
                     91: 
                     92: int check_newline ();
                     93: 
                     94: /* C code produced by gperf version 2.5 (GNU C++ version) */
1.1.1.5   root       95: /* Command-line: gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$ c-parse.gperf  */
1.1       root       96: struct resword { char *name; short token; enum rid rid; };
                     97: 
1.1.1.5   root       98: #define TOTAL_KEYWORDS 79
1.1       root       99: #define MIN_WORD_LENGTH 2
1.1.1.5   root      100: #define MAX_WORD_LENGTH 20
                    101: #define MIN_HASH_VALUE 10
                    102: #define MAX_HASH_VALUE 144
                    103: /* maximum key range = 135, duplicates = 0 */
1.1       root      104: 
                    105: #ifdef __GNUC__
                    106: __inline
                    107: #endif
                    108: static unsigned int
                    109: hash (str, len)
                    110:      register char *str;
                    111:      register int unsigned len;
                    112: {
                    113:   static unsigned char asso_values[] =
                    114:     {
1.1.1.5   root      115:      145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
                    116:      145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
                    117:      145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
                    118:      145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
                    119:      145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
                    120:      145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
                    121:      145, 145, 145, 145,  25, 145, 145, 145, 145, 145,
                    122:      145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
                    123:      145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
                    124:      145, 145, 145, 145, 145,   1, 145,  46,   8,  15,
                    125:       61,   6,  36,  48,   3,   5, 145,  18,  63,  25,
                    126:       29,  76,   1, 145,  13,   2,   1,  51,  37,   9,
                    127:        9,   1,   3, 145, 145, 145, 145, 145,
1.1       root      128:     };
                    129:   register int hval = len;
                    130: 
                    131:   switch (hval)
                    132:     {
                    133:       default:
                    134:       case 3:
                    135:         hval += asso_values[str[2]];
                    136:       case 2:
                    137:       case 1:
                    138:         hval += asso_values[str[0]];
                    139:     }
                    140:   return hval + asso_values[str[len - 1]];
                    141: }
                    142: 
1.1.1.5   root      143: static struct resword wordlist[] =
                    144: {
                    145:   {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
                    146:   {"",}, 
                    147:   {"int",  TYPESPEC, RID_INT},
                    148:   {"",}, {"",}, 
                    149:   {"__typeof__",  TYPEOF, NORID},
                    150:   {"__signed__",  TYPESPEC, RID_SIGNED},
                    151:   {"__imag__",  IMAGPART, NORID},
                    152:   {"switch",  SWITCH, NORID},
                    153:   {"__inline__",  SCSPEC, RID_INLINE},
                    154:   {"else",  ELSE, NORID},
                    155:   {"__iterator__",  SCSPEC, RID_ITERATOR},
                    156:   {"__inline",  SCSPEC, RID_INLINE},
                    157:   {"__extension__",  EXTENSION, NORID},
                    158:   {"struct",  STRUCT, NORID},
                    159:   {"__real__",  REALPART, NORID},
                    160:   {"__const",  TYPE_QUAL, RID_CONST},
                    161:   {"while",  WHILE, NORID},
                    162:   {"__const__",  TYPE_QUAL, RID_CONST},
                    163:   {"case",  CASE, NORID},
                    164:   {"__complex__",  TYPESPEC, RID_COMPLEX},
                    165:   {"__iterator",  SCSPEC, RID_ITERATOR},
                    166:   {"bycopy",  TYPE_QUAL, RID_BYCOPY},
                    167:   {"",}, {"",}, {"",}, 
                    168:   {"__complex",  TYPESPEC, RID_COMPLEX},
                    169:   {"",}, 
                    170:   {"in",  TYPE_QUAL, RID_IN},
                    171:   {"break",  BREAK, NORID},
                    172:   {"@defs",  DEFS, NORID},
                    173:   {"",}, {"",}, {"",}, 
                    174:   {"extern",  SCSPEC, RID_EXTERN},
                    175:   {"if",  IF, NORID},
                    176:   {"typeof",  TYPEOF, NORID},
                    177:   {"typedef",  SCSPEC, RID_TYPEDEF},
                    178:   {"__typeof",  TYPEOF, NORID},
                    179:   {"sizeof",  SIZEOF, NORID},
                    180:   {"",}, 
                    181:   {"return",  RETURN, NORID},
                    182:   {"const",  TYPE_QUAL, RID_CONST},
                    183:   {"__volatile__",  TYPE_QUAL, RID_VOLATILE},
                    184:   {"@private",  PRIVATE, NORID},
                    185:   {"@selector",  SELECTOR, NORID},
                    186:   {"__volatile",  TYPE_QUAL, RID_VOLATILE},
                    187:   {"__asm__",  ASM_KEYWORD, NORID},
                    188:   {"",}, {"",}, 
                    189:   {"continue",  CONTINUE, NORID},
                    190:   {"__alignof__",  ALIGNOF, NORID},
                    191:   {"__imag",  IMAGPART, NORID},
                    192:   {"__attribute__",  ATTRIBUTE, NORID},
                    193:   {"",}, {"",}, 
                    194:   {"__attribute",  ATTRIBUTE, NORID},
                    195:   {"for",  FOR, NORID},
                    196:   {"",}, 
                    197:   {"@encode",  ENCODE, NORID},
                    198:   {"id",  OBJECTNAME, RID_ID},
                    199:   {"static",  SCSPEC, RID_STATIC},
                    200:   {"@interface",  INTERFACE, NORID},
                    201:   {"",}, 
                    202:   {"__signed",  TYPESPEC, RID_SIGNED},
                    203:   {"",}, 
                    204:   {"__label__",  LABEL, NORID},
                    205:   {"",}, {"",}, 
                    206:   {"__asm",  ASM_KEYWORD, NORID},
                    207:   {"char",  TYPESPEC, RID_CHAR},
                    208:   {"",}, 
                    209:   {"inline",  SCSPEC, RID_INLINE},
                    210:   {"out",  TYPE_QUAL, RID_OUT},
                    211:   {"register",  SCSPEC, RID_REGISTER},
                    212:   {"__real",  REALPART, NORID},
                    213:   {"short",  TYPESPEC, RID_SHORT},
                    214:   {"",}, 
                    215:   {"enum",  ENUM, NORID},
                    216:   {"inout",  TYPE_QUAL, RID_INOUT},
                    217:   {"",}, 
                    218:   {"oneway",  TYPE_QUAL, RID_ONEWAY},
                    219:   {"union",  UNION, NORID},
                    220:   {"",}, 
                    221:   {"__alignof",  ALIGNOF, NORID},
                    222:   {"",}, 
                    223:   {"@implementation",  IMPLEMENTATION, NORID},
                    224:   {"",}, 
                    225:   {"@class",  CLASS, NORID},
                    226:   {"",}, 
                    227:   {"@public",  PUBLIC, NORID},
                    228:   {"asm",  ASM_KEYWORD, NORID},
                    229:   {"",}, {"",}, {"",}, {"",}, {"",}, 
                    230:   {"default",  DEFAULT, NORID},
                    231:   {"",}, 
                    232:   {"void",  TYPESPEC, RID_VOID},
                    233:   {"",}, 
                    234:   {"@protected",  PROTECTED, NORID},
                    235:   {"@protocol",  PROTOCOL, NORID},
                    236:   {"",}, {"",}, {"",}, 
                    237:   {"volatile",  TYPE_QUAL, RID_VOLATILE},
                    238:   {"",}, {"",}, 
                    239:   {"signed",  TYPESPEC, RID_SIGNED},
                    240:   {"float",  TYPESPEC, RID_FLOAT},
                    241:   {"@end",  END, NORID},
                    242:   {"",}, {"",}, 
                    243:   {"unsigned",  TYPESPEC, RID_UNSIGNED},
                    244:   {"@compatibility_alias",  ALIAS, NORID},
                    245:   {"double",  TYPESPEC, RID_DOUBLE},
                    246:   {"",}, {"",}, 
                    247:   {"auto",  SCSPEC, RID_AUTO},
                    248:   {"",}, 
                    249:   {"goto",  GOTO, NORID},
                    250:   {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
                    251:   {"do",  DO, NORID},
                    252:   {"",}, {"",}, {"",}, {"",}, 
                    253:   {"long",  TYPESPEC, RID_LONG},
                    254: };
                    255: 
1.1       root      256: #ifdef __GNUC__
                    257: __inline
                    258: #endif
                    259: struct resword *
                    260: is_reserved_word (str, len)
                    261:      register char *str;
                    262:      register unsigned int len;
                    263: {
                    264:   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
                    265:     {
                    266:       register int key = hash (str, len);
                    267: 
                    268:       if (key <= MAX_HASH_VALUE && key >= 0)
                    269:         {
                    270:           register char *s = wordlist[key].name;
                    271: 
                    272:           if (*s == *str && !strcmp (str + 1, s + 1))
                    273:             return &wordlist[key];
                    274:         }
                    275:     }
                    276:   return 0;
                    277: }
                    278: 
                    279: /* Return something to represent absolute declarators containing a *.
                    280:    TARGET is the absolute declarator that the * contains.
                    281:    TYPE_QUALS is a list of modifiers such as const or volatile
                    282:    to apply to the pointer type, represented as identifiers.
                    283: 
                    284:    We return an INDIRECT_REF whose "contents" are TARGET
                    285:    and whose type is the modifier list.  */
                    286: 
                    287: tree
                    288: make_pointer_declarator (type_quals, target)
                    289:      tree type_quals, target;
                    290: {
                    291:   return build1 (INDIRECT_REF, type_quals, target);
                    292: }
                    293: 
                    294: void
1.1.1.5   root      295: forget_protocol_qualifiers ()
                    296: {
                    297:   int i, n = sizeof wordlist / sizeof (struct resword);
                    298: 
                    299:   for (i = 0; i < n; i++)
                    300:     if ((int) wordlist[i].rid >= (int) RID_IN
                    301:         && (int) wordlist[i].rid <= (int) RID_ONEWAY)
                    302:       wordlist[i].name = "";
                    303: }
                    304: 
                    305: void
                    306: remember_protocol_qualifiers ()
                    307: {
                    308:   int i, n = sizeof wordlist / sizeof (struct resword);
                    309: 
                    310:   for (i = 0; i < n; i++)
                    311:     if (wordlist[i].rid == RID_IN)
                    312:       wordlist[i].name = "in";
                    313:     else if (wordlist[i].rid == RID_OUT)
                    314:       wordlist[i].name = "out";
                    315:     else if (wordlist[i].rid == RID_INOUT)
                    316:       wordlist[i].name = "inout";
                    317:     else if (wordlist[i].rid == RID_BYCOPY)
                    318:       wordlist[i].name = "bycopy";
                    319:     else if (wordlist[i].rid == RID_ONEWAY)
                    320:       wordlist[i].name = "oneway";   
                    321: }
                    322: 
                    323: void
1.1       root      324: init_lex ()
                    325: {
                    326:   /* Make identifier nodes long enough for the language-specific slots.  */
                    327:   set_identifier_size (sizeof (struct lang_identifier));
                    328: 
                    329:   /* Start it at 0, because check_newline is called at the very beginning
                    330:      and will increment it to 1.  */
                    331:   lineno = 0;
                    332: 
                    333: #ifdef MULTIBYTE_CHARS
                    334:   /* Change to the native locale for multibyte conversions.  */
                    335:   setlocale (LC_CTYPE, "");
                    336: #endif
                    337: 
                    338:   maxtoken = 40;
                    339:   token_buffer = (char *) xmalloc (maxtoken + 2);
                    340: 
                    341:   ridpointers[(int) RID_INT] = get_identifier ("int");
                    342:   ridpointers[(int) RID_CHAR] = get_identifier ("char");
                    343:   ridpointers[(int) RID_VOID] = get_identifier ("void");
                    344:   ridpointers[(int) RID_FLOAT] = get_identifier ("float");
                    345:   ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
                    346:   ridpointers[(int) RID_SHORT] = get_identifier ("short");
                    347:   ridpointers[(int) RID_LONG] = get_identifier ("long");
                    348:   ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
                    349:   ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
                    350:   ridpointers[(int) RID_INLINE] = get_identifier ("inline");
                    351:   ridpointers[(int) RID_CONST] = get_identifier ("const");
                    352:   ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
                    353:   ridpointers[(int) RID_AUTO] = get_identifier ("auto");
                    354:   ridpointers[(int) RID_STATIC] = get_identifier ("static");
                    355:   ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
                    356:   ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
                    357:   ridpointers[(int) RID_REGISTER] = get_identifier ("register");
1.1.1.5   root      358:   ridpointers[(int) RID_ITERATOR] = get_identifier ("iterator");
                    359:   ridpointers[(int) RID_COMPLEX] = get_identifier ("complex");
                    360:   ridpointers[(int) RID_ID] = get_identifier ("id");
                    361:   ridpointers[(int) RID_IN] = get_identifier ("in");
                    362:   ridpointers[(int) RID_OUT] = get_identifier ("out");
                    363:   ridpointers[(int) RID_INOUT] = get_identifier ("inout");
                    364:   ridpointers[(int) RID_BYCOPY] = get_identifier ("bycopy");
                    365:   ridpointers[(int) RID_ONEWAY] = get_identifier ("oneway");
                    366:   forget_protocol_qualifiers();
1.1       root      367: 
                    368:   /* Some options inhibit certain reserved words.
                    369:      Clear those words out of the hash table so they won't be recognized.  */
                    370: #define UNSET_RESERVED_WORD(STRING) \
                    371:   do { struct resword *s = is_reserved_word (STRING, sizeof (STRING) - 1); \
                    372:        if (s) s->name = ""; } while (0)
                    373: 
1.1.1.5   root      374:   if (! doing_objc_thang)
                    375:     UNSET_RESERVED_WORD ("id");
                    376: 
1.1       root      377:   if (flag_traditional)
                    378:     {
                    379:       UNSET_RESERVED_WORD ("const");
                    380:       UNSET_RESERVED_WORD ("volatile");
                    381:       UNSET_RESERVED_WORD ("typeof");
                    382:       UNSET_RESERVED_WORD ("signed");
                    383:       UNSET_RESERVED_WORD ("inline");
1.1.1.5   root      384:       UNSET_RESERVED_WORD ("iterator");
                    385:       UNSET_RESERVED_WORD ("complex");
1.1       root      386:     }
                    387:   if (flag_no_asm)
                    388:     {
                    389:       UNSET_RESERVED_WORD ("asm");
                    390:       UNSET_RESERVED_WORD ("typeof");
                    391:       UNSET_RESERVED_WORD ("inline");
1.1.1.5   root      392:       UNSET_RESERVED_WORD ("iterator");
                    393:       UNSET_RESERVED_WORD ("complex");
1.1       root      394:     }
                    395: }
                    396: 
                    397: void
                    398: reinit_parse_for_function ()
                    399: {
                    400: }
                    401: 
                    402: /* Function used when yydebug is set, to print a token in more detail.  */
                    403: 
                    404: void
                    405: yyprint (file, yychar, yylval)
                    406:      FILE *file;
                    407:      int yychar;
                    408:      YYSTYPE yylval;
                    409: {
                    410:   tree t;
                    411:   switch (yychar)
                    412:     {
                    413:     case IDENTIFIER:
                    414:     case TYPENAME:
1.1.1.5   root      415:     case OBJECTNAME:
1.1       root      416:       t = yylval.ttype;
                    417:       if (IDENTIFIER_POINTER (t))
                    418:        fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
                    419:       break;
                    420: 
                    421:     case CONSTANT:
                    422:       t = yylval.ttype;
                    423:       if (TREE_CODE (t) == INTEGER_CST)
1.1.1.4   root      424:        fprintf (file,
                    425: #if HOST_BITS_PER_WIDE_INT == 64
                    426: #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
                    427:                 " 0x%lx%016lx",
                    428: #else
                    429:                 " 0x%x%016x",
                    430: #endif
                    431: #else
                    432: #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
                    433:                 " 0x%lx%08lx",
                    434: #else
                    435:                 " 0x%x%08x",
                    436: #endif
                    437: #endif
                    438:                 TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
1.1       root      439:       break;
                    440:     }
                    441: }
                    442: 
                    443: 
                    444: /* If C is not whitespace, return C.
                    445:    Otherwise skip whitespace and return first nonwhite char read.  */
                    446: 
                    447: static int
                    448: skip_white_space (c)
                    449:      register int c;
                    450: {
1.1.1.3   root      451:   static int newline_warning = 0;
1.1       root      452: 
                    453:   for (;;)
                    454:     {
                    455:       switch (c)
                    456:        {
1.1.1.3   root      457:          /* We don't recognize comments here, because
                    458:             cpp output can include / and * consecutively as operators.
                    459:             Also, there's no need, since cpp removes all comments.  */
1.1       root      460: 
                    461:        case '\n':
                    462:          c = check_newline ();
                    463:          break;
                    464: 
                    465:        case ' ':
                    466:        case '\t':
                    467:        case '\f':
                    468:        case '\v':
                    469:        case '\b':
                    470:          c = getc (finput);
                    471:          break;
                    472: 
1.1.1.3   root      473:        case '\r':
                    474:          /* ANSI C says the effects of a carriage return in a source file
                    475:             are undefined.  */
                    476:          if (pedantic && !newline_warning)
                    477:            {
                    478:              warning ("carriage return in source file");
                    479:              warning ("(we only warn about the first carriage return)");
                    480:              newline_warning = 1;
                    481:            }
                    482:          c = getc (finput);
                    483:          break;
                    484: 
1.1       root      485:        case '\\':
                    486:          c = getc (finput);
                    487:          if (c == '\n')
                    488:            lineno++;
                    489:          else
                    490:            error ("stray '\\' in program");
                    491:          c = getc (finput);
                    492:          break;
                    493: 
                    494:        default:
                    495:          return (c);
                    496:        }
                    497:     }
                    498: }
                    499: 
                    500: /* Skips all of the white space at the current location in the input file.
                    501:    Must use and reset nextchar if it has the next character.  */
                    502: 
                    503: void
                    504: position_after_white_space ()
                    505: {
                    506:   register int c;
                    507: 
                    508:   if (nextchar != -1)
                    509:     c = nextchar, nextchar = -1;
                    510:   else
                    511:     c = getc (finput);
                    512: 
                    513:   ungetc (skip_white_space (c), finput);
                    514: }
                    515: 
                    516: /* Make the token buffer longer, preserving the data in it.
                    517:    P should point to just beyond the last valid character in the old buffer.
                    518:    The value we return is a pointer to the new buffer
                    519:    at a place corresponding to P.  */
                    520: 
                    521: static char *
                    522: extend_token_buffer (p)
                    523:      char *p;
                    524: {
                    525:   int offset = p - token_buffer;
                    526: 
                    527:   maxtoken = maxtoken * 2 + 10;
                    528:   token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
                    529: 
                    530:   return token_buffer + offset;
                    531: }
                    532: 
                    533: /* At the beginning of a line, increment the line number
                    534:    and process any #-directive on this line.
                    535:    If the line is a #-directive, read the entire line and return a newline.
                    536:    Otherwise, return the line's first non-whitespace character.  */
                    537: 
                    538: int
                    539: check_newline ()
                    540: {
                    541:   register int c;
                    542:   register int token;
                    543: 
                    544:   lineno++;
                    545: 
                    546:   /* Read first nonwhite char on the line.  */
                    547: 
                    548:   c = getc (finput);
                    549:   while (c == ' ' || c == '\t')
                    550:     c = getc (finput);
                    551: 
                    552:   if (c != '#')
                    553:     {
                    554:       /* If not #, return it so caller will use it.  */
                    555:       return c;
                    556:     }
                    557: 
                    558:   /* Read first nonwhite char after the `#'.  */
                    559: 
                    560:   c = getc (finput);
                    561:   while (c == ' ' || c == '\t')
                    562:     c = getc (finput);
                    563: 
                    564:   /* If a letter follows, then if the word here is `line', skip
                    565:      it and ignore it; otherwise, ignore the line, with an error
                    566:      if the word isn't `pragma', `ident', `define', or `undef'.  */
                    567: 
                    568:   if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
                    569:     {
                    570:       if (c == 'p')
                    571:        {
                    572:          if (getc (finput) == 'r'
                    573:              && getc (finput) == 'a'
                    574:              && getc (finput) == 'g'
                    575:              && getc (finput) == 'm'
                    576:              && getc (finput) == 'a'
                    577:              && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
                    578:            {
1.1.1.4   root      579: #ifdef HANDLE_SYSV_PRAGMA
                    580:              return handle_sysv_pragma (finput, c);
                    581: #endif /* HANDLE_SYSV_PRAGMA */
1.1       root      582: #ifdef HANDLE_PRAGMA
                    583:              HANDLE_PRAGMA (finput);
                    584: #endif /* HANDLE_PRAGMA */
                    585:              goto skipline;
                    586:            }
                    587:        }
                    588: 
                    589:       else if (c == 'd')
                    590:        {
                    591:          if (getc (finput) == 'e'
                    592:              && getc (finput) == 'f'
                    593:              && getc (finput) == 'i'
                    594:              && getc (finput) == 'n'
                    595:              && getc (finput) == 'e'
                    596:              && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
                    597:            {
                    598: #ifdef DWARF_DEBUGGING_INFO
                    599:              if ((debug_info_level == DINFO_LEVEL_VERBOSE)
                    600:                  && (write_symbols == DWARF_DEBUG))
                    601:                dwarfout_define (lineno, get_directive_line (finput));
                    602: #endif /* DWARF_DEBUGGING_INFO */
                    603:              goto skipline;
                    604:            }
                    605:        }
                    606:       else if (c == 'u')
                    607:        {
                    608:          if (getc (finput) == 'n'
                    609:              && getc (finput) == 'd'
                    610:              && getc (finput) == 'e'
                    611:              && getc (finput) == 'f'
                    612:              && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
                    613:            {
                    614: #ifdef DWARF_DEBUGGING_INFO
                    615:              if ((debug_info_level == DINFO_LEVEL_VERBOSE)
                    616:                  && (write_symbols == DWARF_DEBUG))
                    617:                dwarfout_undef (lineno, get_directive_line (finput));
                    618: #endif /* DWARF_DEBUGGING_INFO */
                    619:              goto skipline;
                    620:            }
                    621:        }
                    622:       else if (c == 'l')
                    623:        {
                    624:          if (getc (finput) == 'i'
                    625:              && getc (finput) == 'n'
                    626:              && getc (finput) == 'e'
                    627:              && ((c = getc (finput)) == ' ' || c == '\t'))
                    628:            goto linenum;
                    629:        }
                    630:       else if (c == 'i')
                    631:        {
                    632:          if (getc (finput) == 'd'
                    633:              && getc (finput) == 'e'
                    634:              && getc (finput) == 'n'
                    635:              && getc (finput) == 't'
                    636:              && ((c = getc (finput)) == ' ' || c == '\t'))
                    637:            {
                    638:              /* #ident.  The pedantic warning is now in cccp.c.  */
                    639: 
                    640:              /* Here we have just seen `#ident '.
                    641:                 A string constant should follow.  */
                    642: 
                    643:              while (c == ' ' || c == '\t')
                    644:                c = getc (finput);
                    645: 
                    646:              /* If no argument, ignore the line.  */
                    647:              if (c == '\n')
                    648:                return c;
                    649: 
                    650:              ungetc (c, finput);
                    651:              token = yylex ();
                    652:              if (token != STRING
                    653:                  || TREE_CODE (yylval.ttype) != STRING_CST)
                    654:                {
                    655:                  error ("invalid #ident");
                    656:                  goto skipline;
                    657:                }
                    658: 
                    659:              if (!flag_no_ident)
                    660:                {
                    661: #ifdef ASM_OUTPUT_IDENT
                    662:                  ASM_OUTPUT_IDENT (asm_out_file, TREE_STRING_POINTER (yylval.ttype));
                    663: #endif
                    664:                }
                    665: 
                    666:              /* Skip the rest of this line.  */
                    667:              goto skipline;
                    668:            }
                    669:        }
                    670: 
                    671:       error ("undefined or invalid # directive");
                    672:       goto skipline;
                    673:     }
                    674: 
                    675: linenum:
                    676:   /* Here we have either `#line' or `# <nonletter>'.
                    677:      In either case, it should be a line number; a digit should follow.  */
                    678: 
                    679:   while (c == ' ' || c == '\t')
                    680:     c = getc (finput);
                    681: 
                    682:   /* If the # is the only nonwhite char on the line,
                    683:      just ignore it.  Check the new newline.  */
                    684:   if (c == '\n')
                    685:     return c;
                    686: 
                    687:   /* Something follows the #; read a token.  */
                    688: 
                    689:   ungetc (c, finput);
                    690:   token = yylex ();
                    691: 
                    692:   if (token == CONSTANT
                    693:       && TREE_CODE (yylval.ttype) == INTEGER_CST)
                    694:     {
                    695:       int old_lineno = lineno;
                    696:       int used_up = 0;
                    697:       /* subtract one, because it is the following line that
                    698:         gets the specified number */
                    699: 
                    700:       int l = TREE_INT_CST_LOW (yylval.ttype) - 1;
                    701: 
                    702:       /* Is this the last nonwhite stuff on the line?  */
                    703:       c = getc (finput);
                    704:       while (c == ' ' || c == '\t')
                    705:        c = getc (finput);
                    706:       if (c == '\n')
                    707:        {
                    708:          /* No more: store the line number and check following line.  */
                    709:          lineno = l;
                    710:          return c;
                    711:        }
                    712:       ungetc (c, finput);
                    713: 
                    714:       /* More follows: it must be a string constant (filename).  */
                    715: 
1.1.1.6 ! root      716:       /* Read the string constant.  */
1.1       root      717:       token = yylex ();
                    718: 
                    719:       if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
                    720:        {
                    721:          error ("invalid #line");
                    722:          goto skipline;
                    723:        }
                    724: 
                    725:       input_filename
                    726:        = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1);
                    727:       strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype));
                    728:       lineno = l;
                    729: 
                    730:       /* Each change of file name
                    731:         reinitializes whether we are now in a system header.  */
                    732:       in_system_header = 0;
                    733: 
                    734:       if (main_input_filename == 0)
                    735:        main_input_filename = input_filename;
                    736: 
                    737:       /* Is this the last nonwhite stuff on the line?  */
                    738:       c = getc (finput);
                    739:       while (c == ' ' || c == '\t')
                    740:        c = getc (finput);
                    741:       if (c == '\n')
1.1.1.5   root      742:        {
                    743:          /* Update the name in the top element of input_file_stack.  */
                    744:          if (input_file_stack)
                    745:            input_file_stack->name = input_filename;
                    746: 
                    747:          return c;
                    748:        }
1.1       root      749:       ungetc (c, finput);
                    750: 
                    751:       token = yylex ();
                    752:       used_up = 0;
                    753: 
                    754:       /* `1' after file name means entering new file.
                    755:         `2' after file name means just left a file.  */
                    756: 
                    757:       if (token == CONSTANT
                    758:          && TREE_CODE (yylval.ttype) == INTEGER_CST)
                    759:        {
                    760:          if (TREE_INT_CST_LOW (yylval.ttype) == 1)
                    761:            {
                    762:              /* Pushing to a new file.  */
                    763:              struct file_stack *p
                    764:                = (struct file_stack *) xmalloc (sizeof (struct file_stack));
                    765:              input_file_stack->line = old_lineno;
                    766:              p->next = input_file_stack;
                    767:              p->name = input_filename;
                    768:              input_file_stack = p;
                    769:              input_file_stack_tick++;
                    770: #ifdef DWARF_DEBUGGING_INFO
                    771:              if (debug_info_level == DINFO_LEVEL_VERBOSE
                    772:                  && write_symbols == DWARF_DEBUG)
                    773:                dwarfout_start_new_source_file (input_filename);
                    774: #endif /* DWARF_DEBUGGING_INFO */
                    775: 
                    776:              used_up = 1;
                    777:            }
                    778:          else if (TREE_INT_CST_LOW (yylval.ttype) == 2)
                    779:            {
                    780:              /* Popping out of a file.  */
                    781:              if (input_file_stack->next)
                    782:                {
                    783:                  struct file_stack *p = input_file_stack;
                    784:                  input_file_stack = p->next;
                    785:                  free (p);
                    786:                  input_file_stack_tick++;
                    787: #ifdef DWARF_DEBUGGING_INFO
                    788:                  if (debug_info_level == DINFO_LEVEL_VERBOSE
                    789:                      && write_symbols == DWARF_DEBUG)
                    790:                    dwarfout_resume_previous_source_file (input_file_stack->line);
                    791: #endif /* DWARF_DEBUGGING_INFO */
                    792:                }
                    793:              else
                    794:                error ("#-lines for entering and leaving files don't match");
                    795: 
                    796:              used_up = 1;
                    797:            }
                    798:        }
                    799: 
1.1.1.5   root      800:       /* Now that we've pushed or popped the input stack,
                    801:         update the name in the top element.  */
                    802:       if (input_file_stack)
                    803:        input_file_stack->name = input_filename;
                    804: 
1.1       root      805:       /* If we have handled a `1' or a `2',
                    806:         see if there is another number to read.  */
                    807:       if (used_up)
                    808:        {
                    809:          /* Is this the last nonwhite stuff on the line?  */
                    810:          c = getc (finput);
                    811:          while (c == ' ' || c == '\t')
                    812:            c = getc (finput);
                    813:          if (c == '\n')
                    814:            return c;
                    815:          ungetc (c, finput);
                    816: 
                    817:          token = yylex ();
                    818:          used_up = 0;
                    819:        }
                    820: 
                    821:       /* `3' after file name means this is a system header file.  */
                    822: 
                    823:       if (token == CONSTANT
                    824:          && TREE_CODE (yylval.ttype) == INTEGER_CST
                    825:          && TREE_INT_CST_LOW (yylval.ttype) == 3)
                    826:        in_system_header = 1;
                    827:     }
                    828:   else
                    829:     error ("invalid #-line");
                    830: 
                    831:   /* skip the rest of this line.  */
                    832:  skipline:
                    833:   if (c == '\n')
                    834:     return c;
                    835:   while ((c = getc (finput)) != EOF && c != '\n');
                    836:   return c;
                    837: }
                    838: 
1.1.1.4   root      839: #ifdef HANDLE_SYSV_PRAGMA
                    840: 
                    841: /* Handle a #pragma directive.  INPUT is the current input stream,
                    842:    and C is a character to reread.  Processes the entire input line
                    843:    and returns a character for the caller to reread: either \n or EOF.  */
                    844: 
                    845: /* This function has to be in this file, in order to get at
                    846:    the token types.  */
                    847: 
                    848: int
                    849: handle_sysv_pragma (input, c)
                    850:      FILE *input;
                    851:      int c;
                    852: {
                    853:   for (;;)
                    854:     {
                    855:       while (c == ' ' || c == '\t')
                    856:        c = getc (input);
                    857:       if (c == '\n' || c == EOF)
                    858:        {
                    859:          handle_pragma_token (0, 0);
                    860:          return c;
                    861:        }
                    862:       ungetc (c, input);
                    863:       switch (yylex ())
                    864:        {
                    865:        case IDENTIFIER:
                    866:        case TYPENAME:
                    867:        case STRING:
                    868:        case CONSTANT:
                    869:          handle_pragma_token (token_buffer, yylval.ttype);
                    870:          break;
                    871:        default:
                    872:          handle_pragma_token (token_buffer, 0);
                    873:        }
                    874:       if (nextchar >= 0)
                    875:        c = nextchar, nextchar = -1;
                    876:       else
                    877:        c = getc (input);
                    878:     }
                    879: }
                    880: 
                    881: #endif /* HANDLE_SYSV_PRAGMA */
                    882: 
1.1       root      883: #define ENDFILE -1  /* token that represents end-of-file */
                    884: 
                    885: /* Read an escape sequence, returning its equivalent as a character,
1.1.1.4   root      886:    or store 1 in *ignore_ptr if it is backslash-newline.  */
1.1       root      887: 
                    888: static int
1.1.1.4   root      889: readescape (ignore_ptr)
                    890:      int *ignore_ptr;
1.1       root      891: {
                    892:   register int c = getc (finput);
                    893:   register int code;
                    894:   register unsigned count;
                    895:   unsigned firstdig;
1.1.1.4   root      896:   int nonnull;
1.1       root      897: 
                    898:   switch (c)
                    899:     {
                    900:     case 'x':
                    901:       if (warn_traditional)
                    902:        warning ("the meaning of `\\x' varies with -traditional");
                    903: 
                    904:       if (flag_traditional)
                    905:        return c;
                    906: 
                    907:       code = 0;
                    908:       count = 0;
1.1.1.4   root      909:       nonnull = 0;
1.1       root      910:       while (1)
                    911:        {
                    912:          c = getc (finput);
                    913:          if (!(c >= 'a' && c <= 'f')
                    914:              && !(c >= 'A' && c <= 'F')
                    915:              && !(c >= '0' && c <= '9'))
                    916:            {
                    917:              ungetc (c, finput);
                    918:              break;
                    919:            }
                    920:          code *= 16;
                    921:          if (c >= 'a' && c <= 'f')
                    922:            code += c - 'a' + 10;
                    923:          if (c >= 'A' && c <= 'F')
                    924:            code += c - 'A' + 10;
                    925:          if (c >= '0' && c <= '9')
                    926:            code += c - '0';
1.1.1.4   root      927:          if (code != 0 || count != 0)
                    928:            {
                    929:              if (count == 0)
                    930:                firstdig = code;
                    931:              count++;
                    932:            }
                    933:          nonnull = 1;
1.1       root      934:        }
1.1.1.4   root      935:       if (! nonnull)
1.1       root      936:        error ("\\x used with no following hex digits");
1.1.1.4   root      937:       else if (count == 0)
                    938:        /* Digits are all 0's.  Ok.  */
                    939:        ;
1.1       root      940:       else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
                    941:               || (count > 1
                    942:                   && ((1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4))
                    943:                       <= firstdig)))
                    944:        pedwarn ("hex escape out of range");
                    945:       return code;
                    946: 
                    947:     case '0':  case '1':  case '2':  case '3':  case '4':
                    948:     case '5':  case '6':  case '7':
                    949:       code = 0;
                    950:       count = 0;
                    951:       while ((c <= '7') && (c >= '0') && (count++ < 3))
                    952:        {
                    953:          code = (code * 8) + (c - '0');
                    954:          c = getc (finput);
                    955:        }
                    956:       ungetc (c, finput);
                    957:       return code;
                    958: 
                    959:     case '\\': case '\'': case '"':
                    960:       return c;
                    961: 
                    962:     case '\n':
                    963:       lineno++;
1.1.1.4   root      964:       *ignore_ptr = 1;
                    965:       return 0;
1.1       root      966: 
                    967:     case 'n':
                    968:       return TARGET_NEWLINE;
                    969: 
                    970:     case 't':
                    971:       return TARGET_TAB;
                    972: 
                    973:     case 'r':
                    974:       return TARGET_CR;
                    975: 
                    976:     case 'f':
                    977:       return TARGET_FF;
                    978: 
                    979:     case 'b':
                    980:       return TARGET_BS;
                    981: 
                    982:     case 'a':
                    983:       if (warn_traditional)
                    984:        warning ("the meaning of `\\a' varies with -traditional");
                    985: 
                    986:       if (flag_traditional)
                    987:        return c;
                    988:       return TARGET_BELL;
                    989: 
                    990:     case 'v':
                    991: #if 0 /* Vertical tab is present in common usage compilers.  */
                    992:       if (flag_traditional)
                    993:        return c;
                    994: #endif
                    995:       return TARGET_VT;
                    996: 
1.1.1.4   root      997:     case 'e':
1.1       root      998:     case 'E':
1.1.1.4   root      999:       if (pedantic)
                   1000:        pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c);
1.1       root     1001:       return 033;
                   1002: 
                   1003:     case '?':
                   1004:       return c;
                   1005: 
                   1006:       /* `\(', etc, are used at beginning of line to avoid confusing Emacs.  */
                   1007:     case '(':
                   1008:     case '{':
                   1009:     case '[':
1.1.1.5   root     1010:       /* `\%' is used to prevent SCCS from getting confused.  */
                   1011:     case '%':
1.1       root     1012:       if (pedantic)
                   1013:        pedwarn ("non-ANSI escape sequence `\\%c'", c);
                   1014:       return c;
                   1015:     }
1.1.1.4   root     1016:   if (c >= 040 && c < 0177)
1.1       root     1017:     pedwarn ("unknown escape sequence `\\%c'", c);
                   1018:   else
                   1019:     pedwarn ("unknown escape sequence: `\\' followed by char code 0x%x", c);
                   1020:   return c;
                   1021: }
                   1022: 
                   1023: void
                   1024: yyerror (string)
                   1025:      char *string;
                   1026: {
                   1027:   char buf[200];
                   1028: 
                   1029:   strcpy (buf, string);
                   1030: 
                   1031:   /* We can't print string and character constants well
                   1032:      because the token_buffer contains the result of processing escapes.  */
                   1033:   if (end_of_file)
                   1034:     strcat (buf, " at end of input");
                   1035:   else if (token_buffer[0] == 0)
                   1036:     strcat (buf, " at null character");
                   1037:   else if (token_buffer[0] == '"')
                   1038:     strcat (buf, " before string constant");
                   1039:   else if (token_buffer[0] == '\'')
                   1040:     strcat (buf, " before character constant");
                   1041:   else if (token_buffer[0] < 040 || (unsigned char) token_buffer[0] >= 0177)
                   1042:     sprintf (buf + strlen (buf), " before character 0%o",
                   1043:             (unsigned char) token_buffer[0]);
                   1044:   else
                   1045:     strcat (buf, " before `%s'");
                   1046: 
                   1047:   error (buf, token_buffer);
                   1048: }
                   1049: 
                   1050: #if 0
                   1051: 
                   1052: struct try_type
                   1053: {
                   1054:   tree *node_var;
                   1055:   char unsigned_flag;
                   1056:   char long_flag;
                   1057:   char long_long_flag;
                   1058: };
                   1059: 
                   1060: struct try_type type_sequence[] = 
                   1061: {
                   1062:   { &integer_type_node, 0, 0, 0},
                   1063:   { &unsigned_type_node, 1, 0, 0},
                   1064:   { &long_integer_type_node, 0, 1, 0},
                   1065:   { &long_unsigned_type_node, 1, 1, 0},
                   1066:   { &long_long_integer_type_node, 0, 1, 1},
                   1067:   { &long_long_unsigned_type_node, 1, 1, 1}
                   1068: };
                   1069: #endif /* 0 */
                   1070: 
                   1071: int
                   1072: yylex ()
                   1073: {
                   1074:   register int c;
                   1075:   register char *p;
                   1076:   register int value;
                   1077:   int wide_flag = 0;
1.1.1.5   root     1078:   int objc_flag = 0;
1.1       root     1079: 
                   1080:   if (nextchar >= 0)
                   1081:     c = nextchar, nextchar = -1;
                   1082:   else
                   1083:     c = getc (finput);
                   1084: 
                   1085:   /* Effectively do c = skip_white_space (c)
                   1086:      but do it faster in the usual cases.  */
                   1087:   while (1)
                   1088:     switch (c)
                   1089:       {
                   1090:       case ' ':
                   1091:       case '\t':
                   1092:       case '\f':
                   1093:       case '\v':
                   1094:       case '\b':
                   1095:        c = getc (finput);
                   1096:        break;
                   1097: 
1.1.1.3   root     1098:       case '\r':
                   1099:        /* Call skip_white_space so we can warn if appropriate.  */
                   1100: 
1.1       root     1101:       case '\n':
                   1102:       case '/':
                   1103:       case '\\':
                   1104:        c = skip_white_space (c);
                   1105:       default:
                   1106:        goto found_nonwhite;
                   1107:       }
                   1108:  found_nonwhite:
                   1109: 
                   1110:   token_buffer[0] = c;
                   1111:   token_buffer[1] = 0;
                   1112: 
                   1113: /*  yylloc.first_line = lineno; */
                   1114: 
                   1115:   switch (c)
                   1116:     {
                   1117:     case EOF:
                   1118:       end_of_file = 1;
                   1119:       token_buffer[0] = 0;
                   1120:       value = ENDFILE;
                   1121:       break;
                   1122: 
                   1123:     case '$':
                   1124:       if (dollars_in_ident)
                   1125:        goto letter;
                   1126:       return '$';
                   1127: 
                   1128:     case 'L':
                   1129:       /* Capital L may start a wide-string or wide-character constant.  */
                   1130:       {
                   1131:        register int c = getc (finput);
                   1132:        if (c == '\'')
                   1133:          {
                   1134:            wide_flag = 1;
                   1135:            goto char_constant;
                   1136:          }
                   1137:        if (c == '"')
                   1138:          {
                   1139:            wide_flag = 1;
                   1140:            goto string_constant;
                   1141:          }
                   1142:        ungetc (c, finput);
                   1143:       }
                   1144:       goto letter;
                   1145: 
                   1146:     case '@':
                   1147:       if (!doing_objc_thang)
                   1148:        {
                   1149:          value = c;
                   1150:          break;
                   1151:        }
1.1.1.5   root     1152:       else
1.1       root     1153:        {
1.1.1.5   root     1154:          /* '@' may start a constant string object.  */
                   1155:          register int c = getc(finput);
                   1156:          if (c == '"')
                   1157:            {
                   1158:              objc_flag = 1;
                   1159:              goto string_constant;
                   1160:            }
                   1161:          ungetc(c, finput);
                   1162:          /* Fall through to treat '@' as the start of an indentifier.  */
1.1       root     1163:        }
                   1164: 
                   1165:     case 'A':  case 'B':  case 'C':  case 'D':  case 'E':
                   1166:     case 'F':  case 'G':  case 'H':  case 'I':  case 'J':
                   1167:     case 'K':            case 'M':  case 'N':  case 'O':
                   1168:     case 'P':  case 'Q':  case 'R':  case 'S':  case 'T':
                   1169:     case 'U':  case 'V':  case 'W':  case 'X':  case 'Y':
                   1170:     case 'Z':
                   1171:     case 'a':  case 'b':  case 'c':  case 'd':  case 'e':
                   1172:     case 'f':  case 'g':  case 'h':  case 'i':  case 'j':
                   1173:     case 'k':  case 'l':  case 'm':  case 'n':  case 'o':
                   1174:     case 'p':  case 'q':  case 'r':  case 's':  case 't':
                   1175:     case 'u':  case 'v':  case 'w':  case 'x':  case 'y':
                   1176:     case 'z':
                   1177:     case '_':
                   1178:     letter:
                   1179:       p = token_buffer;
                   1180:       while (isalnum (c) || c == '_' || c == '$' || c == '@')
                   1181:        {
1.1.1.5   root     1182:          /* Make sure this char really belongs in an identifier.  */
                   1183:          if (c == '@' && ! doing_objc_thang)
                   1184:            break;
1.1       root     1185:          if (c == '$' && ! dollars_in_ident)
                   1186:            break;
                   1187: 
1.1.1.5   root     1188:          if (p >= token_buffer + maxtoken)
                   1189:            p = extend_token_buffer (p);
                   1190: 
1.1       root     1191:          *p++ = c;
                   1192:          c = getc (finput);
                   1193:        }
                   1194: 
                   1195:       *p = 0;
                   1196:       nextchar = c;
                   1197: 
                   1198:       value = IDENTIFIER;
                   1199:       yylval.itype = 0;
                   1200: 
                   1201:       /* Try to recognize a keyword.  Uses minimum-perfect hash function */
                   1202: 
                   1203:       {
                   1204:        register struct resword *ptr;
                   1205: 
                   1206:        if (ptr = is_reserved_word (token_buffer, p - token_buffer))
                   1207:          {
                   1208:            if (ptr->rid)
                   1209:              yylval.ttype = ridpointers[(int) ptr->rid];
                   1210:            value = (int) ptr->token;
                   1211: 
1.1.1.5   root     1212:            /* Only return OBJECTNAME if it is a typedef.  */
                   1213:            if (doing_objc_thang && value == OBJECTNAME)
                   1214:              {
                   1215:                lastiddecl = lookup_name(yylval.ttype);
                   1216: 
                   1217:                if (lastiddecl == NULL_TREE
                   1218:                    || TREE_CODE (lastiddecl) != TYPE_DECL)
                   1219:                  value = IDENTIFIER;
                   1220:              }
                   1221: 
1.1       root     1222:            /* Even if we decided to recognize asm, still perhaps warn.  */
                   1223:            if (pedantic
1.1.1.2   root     1224:                && (value == ASM_KEYWORD || value == TYPEOF
1.1       root     1225:                    || ptr->rid == RID_INLINE)
                   1226:                && token_buffer[0] != '_')
                   1227:              pedwarn ("ANSI does not permit the keyword `%s'",
                   1228:                       token_buffer);
                   1229:          }
                   1230:       }
                   1231: 
                   1232:       /* If we did not find a keyword, look for an identifier
                   1233:         (or a typename).  */
                   1234: 
                   1235:       if (value == IDENTIFIER)
                   1236:        {
1.1.1.5   root     1237:          if (token_buffer[0] == '@')
                   1238:            error("invalid identifier `%s'", token_buffer);
                   1239: 
1.1       root     1240:           yylval.ttype = get_identifier (token_buffer);
                   1241:          lastiddecl = lookup_name (yylval.ttype);
                   1242: 
                   1243:          if (lastiddecl != 0 && TREE_CODE (lastiddecl) == TYPE_DECL)
                   1244:            value = TYPENAME;
1.1.1.3   root     1245:          /* A user-invisible read-only initialized variable
                   1246:             should be replaced by its value.
                   1247:             We handle only strings since that's the only case used in C.  */
                   1248:          else if (lastiddecl != 0 && TREE_CODE (lastiddecl) == VAR_DECL
                   1249:                   && DECL_IGNORED_P (lastiddecl)
                   1250:                   && TREE_READONLY (lastiddecl)
                   1251:                   && DECL_INITIAL (lastiddecl) != 0
                   1252:                   && TREE_CODE (DECL_INITIAL (lastiddecl)) == STRING_CST)
                   1253:            {
1.1.1.5   root     1254:              tree stringval = DECL_INITIAL (lastiddecl);
                   1255:              
                   1256:              /* Copy the string value so that we won't clobber anything
                   1257:                 if we put something in the TREE_CHAIN of this one.  */
                   1258:              yylval.ttype = build_string (TREE_STRING_LENGTH (stringval),
                   1259:                                           TREE_STRING_POINTER (stringval));
1.1.1.3   root     1260:              value = STRING;
                   1261:            }
1.1       root     1262:           else if (doing_objc_thang)
                   1263:             {
1.1.1.5   root     1264:              tree objc_interface_decl = is_class_name (yylval.ttype);
1.1       root     1265: 
                   1266:              if (objc_interface_decl)
                   1267:                {
                   1268:                  value = CLASSNAME;
                   1269:                  yylval.ttype = objc_interface_decl;
                   1270:                }
                   1271:            }
                   1272:        }
                   1273: 
                   1274:       break;
                   1275: 
                   1276:     case '0':  case '1':  case '2':  case '3':  case '4':
                   1277:     case '5':  case '6':  case '7':  case '8':  case '9':
                   1278:     case '.':
                   1279:       {
                   1280:        int base = 10;
                   1281:        int count = 0;
                   1282:        int largest_digit = 0;
                   1283:        int numdigits = 0;
                   1284:        /* for multi-precision arithmetic,
1.1.1.4   root     1285:           we actually store only HOST_BITS_PER_CHAR bits in each part.
                   1286:           The number of parts is chosen so as to be sufficient to hold
                   1287:           the enough bits to fit into the two HOST_WIDE_INTs that contain
                   1288:           the integer value (this is always at least as many bits as are
                   1289:           in a target `long long' value, but may be wider).  */
                   1290: #define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2 + 2)
                   1291:        int parts[TOTAL_PARTS];
1.1       root     1292:        int overflow = 0;
                   1293: 
                   1294:        enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag
                   1295:          = NOT_FLOAT;
                   1296: 
1.1.1.4   root     1297:        for (count = 0; count < TOTAL_PARTS; count++)
                   1298:          parts[count] = 0;
1.1       root     1299: 
                   1300:        p = token_buffer;
                   1301:        *p++ = c;
                   1302: 
                   1303:        if (c == '0')
                   1304:          {
                   1305:            *p++ = (c = getc (finput));
                   1306:            if ((c == 'x') || (c == 'X'))
                   1307:              {
                   1308:                base = 16;
                   1309:                *p++ = (c = getc (finput));
                   1310:              }
                   1311:            /* Leading 0 forces octal unless the 0 is the only digit.  */
                   1312:            else if (c >= '0' && c <= '9')
                   1313:              {
                   1314:                base = 8;
                   1315:                numdigits++;
                   1316:              }
                   1317:            else
                   1318:              numdigits++;
                   1319:          }
                   1320: 
                   1321:        /* Read all the digits-and-decimal-points.  */
                   1322: 
                   1323:        while (c == '.'
1.1.1.5   root     1324:               || (isalnum (c) && c != 'l' && c != 'L'
                   1325:                   && c != 'u' && c != 'U'
                   1326:                   && c != 'i' && c != 'I' && c != 'j' && c != 'J'
1.1       root     1327:                   && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
                   1328:          {
                   1329:            if (c == '.')
                   1330:              {
                   1331:                if (base == 16)
                   1332:                  error ("floating constant may not be in radix 16");
1.1.1.6 ! root     1333:                if (floatflag == TOO_MANY_POINTS)
        !          1334:                  /* We have already emitted an error.  Don't need another.  */
        !          1335:                  ;
        !          1336:                else if (floatflag == AFTER_POINT)
1.1       root     1337:                  {
                   1338:                    error ("malformed floating constant");
                   1339:                    floatflag = TOO_MANY_POINTS;
1.1.1.6 ! root     1340:                    /* Avoid another error from atof by forcing all characters
        !          1341:                       from here on to be ignored.  */
        !          1342:                    p[-1] = '\0';
1.1       root     1343:                  }
                   1344:                else
                   1345:                  floatflag = AFTER_POINT;
                   1346: 
                   1347:                base = 10;
                   1348:                *p++ = c = getc (finput);
                   1349:                /* Accept '.' as the start of a floating-point number
                   1350:                   only when it is followed by a digit.
                   1351:                   Otherwise, unread the following non-digit
                   1352:                   and use the '.' as a structural token.  */
                   1353:                if (p == token_buffer + 2 && !isdigit (c))
                   1354:                  {
                   1355:                    if (c == '.')
                   1356:                      {
                   1357:                        c = getc (finput);
                   1358:                        if (c == '.')
                   1359:                          {
                   1360:                            *p++ = c;
                   1361:                            *p = 0;
                   1362:                            return ELLIPSIS;
                   1363:                          }
                   1364:                        error ("parse error at `..'");
                   1365:                      }
                   1366:                    ungetc (c, finput);
                   1367:                    token_buffer[1] = 0;
                   1368:                    value = '.';
                   1369:                    goto done;
                   1370:                  }
                   1371:              }
                   1372:            else
                   1373:              {
                   1374:                /* It is not a decimal point.
                   1375:                   It should be a digit (perhaps a hex digit).  */
                   1376: 
                   1377:                if (isdigit (c))
                   1378:                  {
                   1379:                    c = c - '0';
                   1380:                  }
                   1381:                else if (base <= 10)
                   1382:                  {
1.1.1.5   root     1383:                    if (c == 'e' || c == 'E')
1.1       root     1384:                      {
                   1385:                        base = 10;
                   1386:                        floatflag = AFTER_POINT;
                   1387:                        break;   /* start of exponent */
                   1388:                      }
                   1389:                    error ("nondigits in number and not hexadecimal");
                   1390:                    c = 0;
                   1391:                  }
                   1392:                else if (c >= 'a')
                   1393:                  {
                   1394:                    c = c - 'a' + 10;
                   1395:                  }
                   1396:                else
                   1397:                  {
                   1398:                    c = c - 'A' + 10;
                   1399:                  }
                   1400:                if (c >= largest_digit)
                   1401:                  largest_digit = c;
                   1402:                numdigits++;
                   1403: 
1.1.1.4   root     1404:                for (count = 0; count < TOTAL_PARTS; count++)
1.1       root     1405:                  {
1.1.1.4   root     1406:                    parts[count] *= base;
1.1       root     1407:                    if (count)
                   1408:                      {
1.1.1.4   root     1409:                        parts[count]
                   1410:                          += (parts[count-1] >> HOST_BITS_PER_CHAR);
                   1411:                        parts[count-1]
                   1412:                          &= (1 << HOST_BITS_PER_CHAR) - 1;
1.1       root     1413:                      }
1.1.1.4   root     1414:                    else
                   1415:                      parts[0] += c;
1.1       root     1416:                  }
                   1417: 
1.1.1.4   root     1418:                /* If the extra highest-order part ever gets anything in it,
                   1419:                   the number is certainly too big.  */
                   1420:                if (parts[TOTAL_PARTS - 1] != 0)
                   1421:                  overflow = 1;
1.1       root     1422: 
                   1423:                if (p >= token_buffer + maxtoken - 3)
                   1424:                  p = extend_token_buffer (p);
                   1425:                *p++ = (c = getc (finput));
                   1426:              }
                   1427:          }
                   1428: 
                   1429:        if (numdigits == 0)
                   1430:          error ("numeric constant with no digits");
                   1431: 
                   1432:        if (largest_digit >= base)
                   1433:          error ("numeric constant contains digits beyond the radix");
                   1434: 
                   1435:        /* Remove terminating char from the token buffer and delimit the string */
                   1436:        *--p = 0;
                   1437: 
                   1438:        if (floatflag != NOT_FLOAT)
                   1439:          {
                   1440:            tree type = double_type_node;
1.1.1.4   root     1441:            int garbage_chars = 0, exceeds_double = 0;
1.1.1.5   root     1442:            int imag = 0;
1.1       root     1443:            REAL_VALUE_TYPE value;
                   1444:            jmp_buf handler;
                   1445: 
                   1446:            /* Read explicit exponent if any, and put it in tokenbuf.  */
                   1447: 
                   1448:            if ((c == 'e') || (c == 'E'))
                   1449:              {
                   1450:                if (p >= token_buffer + maxtoken - 3)
                   1451:                  p = extend_token_buffer (p);
                   1452:                *p++ = c;
                   1453:                c = getc (finput);
                   1454:                if ((c == '+') || (c == '-'))
                   1455:                  {
                   1456:                    *p++ = c;
                   1457:                    c = getc (finput);
                   1458:                  }
                   1459:                if (! isdigit (c))
                   1460:                  error ("floating constant exponent has no digits");
                   1461:                while (isdigit (c))
                   1462:                  {
                   1463:                    if (p >= token_buffer + maxtoken - 3)
                   1464:                      p = extend_token_buffer (p);
                   1465:                    *p++ = c;
                   1466:                    c = getc (finput);
                   1467:                  }
                   1468:              }
                   1469: 
                   1470:            *p = 0;
                   1471:            errno = 0;
                   1472: 
                   1473:            /* Convert string to a double, checking for overflow.  */
                   1474:            if (setjmp (handler))
                   1475:              {
                   1476:                error ("floating constant out of range");
                   1477:                value = dconst0;
                   1478:              }
                   1479:            else
                   1480:              {
1.1.1.6 ! root     1481:                int fflag = 0, lflag = 0;
        !          1482:                /* Copy token_buffer now, while it has just the number
        !          1483:                   and not the suffixes; once we add `f' or `i',
        !          1484:                   REAL_VALUE_ATOF may not work any more.  */
        !          1485:                char *copy = (char *) alloca (p - token_buffer + 1);
        !          1486:                bcopy (token_buffer, copy, p - token_buffer + 1);
        !          1487: 
1.1       root     1488:                set_float_handler (handler);
1.1.1.5   root     1489: 
1.1.1.6 ! root     1490:                while (1)
        !          1491:                  {
        !          1492:                    int lose = 0;
1.1       root     1493: 
1.1.1.6 ! root     1494:                    /* Read the suffixes to choose a data type.  */
        !          1495:                    switch (c)
        !          1496:                      {
        !          1497:                      case 'f': case 'F':
        !          1498:                        if (fflag)
        !          1499:                          error ("more than one `f' in numeric constant");
        !          1500:                        fflag = 1;
        !          1501:                        break;
        !          1502: 
        !          1503:                      case 'l': case 'L':
        !          1504:                        if (lflag)
        !          1505:                          error ("more than one `l' in numeric constant");
        !          1506:                        lflag = 1;
        !          1507:                        break;
        !          1508: 
        !          1509:                      case 'i': case 'I':
        !          1510:                        if (imag)
        !          1511:                          error ("more than one `i' or `j' in numeric constant");
        !          1512:                        imag = 1;
        !          1513:                        break;
1.1.1.5   root     1514: 
1.1.1.6 ! root     1515:                      default:
        !          1516:                        lose = 1;
        !          1517:                      }
        !          1518: 
        !          1519:                    if (lose)
        !          1520:                      break;
        !          1521: 
        !          1522:                    if (p >= token_buffer + maxtoken - 3)
        !          1523:                      p = extend_token_buffer (p);
        !          1524:                    *p++ = c;
        !          1525:                    *p = 0;
        !          1526:                    c = getc (finput);
        !          1527:                  }
        !          1528: 
        !          1529:                /* The second argument, machine_mode, of REAL_VALUE_ATOF
        !          1530:                   tells the desired precision of the binary result
        !          1531:                   of decimal-to-binary conversion.  */
        !          1532: 
        !          1533:                if (fflag)
        !          1534:                  {
        !          1535:                    if (lflag)
        !          1536:                      error ("both `f' and `l' in floating constant");
        !          1537: 
        !          1538:                    type = float_type_node;
        !          1539:                    value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
        !          1540:                    if (TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT
        !          1541:                        && REAL_VALUE_ISINF (value) && pedantic)
        !          1542:                      pedwarn ("floating point number exceeds range of `float'");
        !          1543:                  }
        !          1544:                else if (lflag)
        !          1545:                  {
        !          1546:                    type = long_double_type_node;
        !          1547:                    value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
        !          1548:                    if (TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT
        !          1549:                        && REAL_VALUE_ISINF (value) && pedantic)
        !          1550:                      pedwarn ("floating point number exceeds range of `long double'");
        !          1551:                  }
        !          1552:                else
        !          1553:                  {
        !          1554:                    value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
        !          1555:                    if (TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT
        !          1556:                        && REAL_VALUE_ISINF (value) && pedantic)
        !          1557:                      pedwarn ("floating point number exceeds range of `double'");
        !          1558:                  }
        !          1559: 
        !          1560:                set_float_handler (NULL_PTR);
1.1.1.5   root     1561:            }
                   1562: #ifdef ERANGE
                   1563:            if (errno == ERANGE && !flag_traditional && pedantic)
                   1564:              {
                   1565:                /* ERANGE is also reported for underflow,
                   1566:                   so test the value to distinguish overflow from that.  */
                   1567:                if (TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT
                   1568:                    && (REAL_VALUES_LESS (dconst1, value)
                   1569:                        || REAL_VALUES_LESS (value, dconstm1)))
                   1570:                  {
                   1571:                    pedwarn ("floating point number exceeds range of `double'");
                   1572:                    exceeds_double = 1;
                   1573:                  }
1.1.1.4   root     1574:              }
1.1.1.5   root     1575: #endif
1.1.1.6 ! root     1576:            garbage_chars = 0;
1.1.1.5   root     1577:            while (isalnum (c) || c == '.' || c == '_'
                   1578:                   || (!flag_traditional && (c == '+' || c == '-')
                   1579:                       && (p[-1] == 'e' || p[-1] == 'E')))
1.1       root     1580:              {
                   1581:                if (p >= token_buffer + maxtoken - 3)
                   1582:                  p = extend_token_buffer (p);
                   1583:                *p++ = c;
                   1584:                c = getc (finput);
1.1.1.4   root     1585:                garbage_chars++;
1.1       root     1586:              }
1.1.1.4   root     1587:            if (garbage_chars > 0)
                   1588:              error ("garbage at end of number");
1.1       root     1589: 
                   1590:            /* Create a node with determined type and value.  */
1.1.1.5   root     1591:            if (imag)
                   1592:              yylval.ttype = build_complex (convert (type, integer_zero_node),
                   1593:                                            build_real (type, value));
                   1594:            else
                   1595:              yylval.ttype = build_real (type, value);
1.1       root     1596: 
                   1597:            ungetc (c, finput);
                   1598:            *p = 0;
                   1599:          }
                   1600:        else
                   1601:          {
                   1602:            tree traditional_type, ansi_type, type;
1.1.1.4   root     1603:            HOST_WIDE_INT high, low;
1.1       root     1604:            int spec_unsigned = 0;
                   1605:            int spec_long = 0;
                   1606:            int spec_long_long = 0;
1.1.1.5   root     1607:            int spec_imag = 0;
1.1       root     1608:            int bytes, warn, i;
                   1609: 
                   1610:            while (1)
                   1611:              {
                   1612:                if (c == 'u' || c == 'U')
                   1613:                  {
                   1614:                    if (spec_unsigned)
                   1615:                      error ("two `u's in integer constant");
                   1616:                    spec_unsigned = 1;
                   1617:                  }
                   1618:                else if (c == 'l' || c == 'L')
                   1619:                  {
                   1620:                    if (spec_long)
                   1621:                      {
                   1622:                        if (spec_long_long)
                   1623:                          error ("three `l's in integer constant");
                   1624:                        else if (pedantic)
                   1625:                          pedwarn ("ANSI C forbids long long integer constants");
                   1626:                        spec_long_long = 1;
                   1627:                      }
                   1628:                    spec_long = 1;
                   1629:                  }
1.1.1.5   root     1630:                else if (c == 'i' || c == 'j' || c == 'I' || c == 'J')
                   1631:                  {
                   1632:                    if (spec_imag)
                   1633:                      error ("more than one `i' or `j' in numeric constant");
                   1634:                    spec_imag = 1;
                   1635:                  }
1.1       root     1636:                else
                   1637:                  {
1.1.1.5   root     1638:                    if (isalnum (c) || c == '.' || c == '_'
                   1639:                        || (!flag_traditional && (c == '+' || c == '-')
                   1640:                            && (p[-1] == 'e' || p[-1] == 'E')))
1.1       root     1641:                      {
                   1642:                        error ("garbage at end of number");
1.1.1.5   root     1643:                        while (isalnum (c) || c == '.' || c == '_'
                   1644:                               || (!flag_traditional && (c == '+' || c == '-')
                   1645:                                   && (p[-1] == 'e' || p[-1] == 'E')))
1.1       root     1646:                          {
                   1647:                            if (p >= token_buffer + maxtoken - 3)
                   1648:                              p = extend_token_buffer (p);
                   1649:                            *p++ = c;
                   1650:                            c = getc (finput);
                   1651:                          }
                   1652:                      }
                   1653:                    break;
                   1654:                  }
                   1655:                if (p >= token_buffer + maxtoken - 3)
                   1656:                  p = extend_token_buffer (p);
                   1657:                *p++ = c;
                   1658:                c = getc (finput);
                   1659:              }
                   1660: 
                   1661:            ungetc (c, finput);
                   1662: 
                   1663:            /* If the constant is not long long and it won't fit in an
                   1664:               unsigned long, or if the constant is long long and won't fit
                   1665:               in an unsigned long long, then warn that the constant is out
                   1666:               of range.  */
                   1667: 
                   1668:            /* ??? This assumes that long long and long integer types are
                   1669:               a multiple of 8 bits.  This better than the original code
                   1670:               though which assumed that long was exactly 32 bits and long
                   1671:               long was exactly 64 bits.  */
                   1672: 
                   1673:            if (spec_long_long)
                   1674:              bytes = TYPE_PRECISION (long_long_integer_type_node) / 8;
                   1675:            else
                   1676:              bytes = TYPE_PRECISION (long_integer_type_node) / 8;
                   1677: 
1.1.1.4   root     1678:            warn = overflow;
                   1679:            for (i = bytes; i < TOTAL_PARTS; i++)
                   1680:              if (parts[i])
                   1681:                warn = 1;
                   1682:            if (warn)
                   1683:              pedwarn ("integer constant out of range");
1.1       root     1684: 
                   1685:            /* This is simplified by the fact that our constant
                   1686:               is always positive.  */
                   1687: 
1.1.1.4   root     1688:            high = low = 0;
                   1689: 
                   1690:            for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR; i++)
                   1691:              {
                   1692:                high |= ((HOST_WIDE_INT) parts[i + (HOST_BITS_PER_WIDE_INT
                   1693:                                                    / HOST_BITS_PER_CHAR)]
                   1694:                         << (i * HOST_BITS_PER_CHAR));
                   1695:                low |= (HOST_WIDE_INT) parts[i] << (i * HOST_BITS_PER_CHAR);
                   1696:              }
                   1697:            
                   1698:            yylval.ttype = build_int_2 (low, high);
                   1699:            TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node;
1.1       root     1700: 
                   1701:            /* If warn_traditional, calculate both the ANSI type and the
                   1702:               traditional type, then see if they disagree.
                   1703:               Otherwise, calculate only the type for the dialect in use.  */
                   1704:            if (warn_traditional || flag_traditional)
                   1705:              {
                   1706:                /* Calculate the traditional type.  */
                   1707:                /* Traditionally, any constant is signed;
                   1708:                   but if unsigned is specified explicitly, obey that.
                   1709:                   Use the smallest size with the right number of bits,
                   1710:                   except for one special case with decimal constants.  */
                   1711:                if (! spec_long && base != 10
                   1712:                    && int_fits_type_p (yylval.ttype, unsigned_type_node))
                   1713:                  traditional_type = (spec_unsigned ? unsigned_type_node
                   1714:                                      : integer_type_node);
                   1715:                /* A decimal constant must be long
                   1716:                   if it does not fit in type int.
                   1717:                   I think this is independent of whether
                   1718:                   the constant is signed.  */
                   1719:                else if (! spec_long && base == 10
                   1720:                         && int_fits_type_p (yylval.ttype, integer_type_node))
                   1721:                  traditional_type = (spec_unsigned ? unsigned_type_node
                   1722:                                      : integer_type_node);
1.1.1.4   root     1723:                else if (! spec_long_long)
1.1       root     1724:                  traditional_type = (spec_unsigned ? long_unsigned_type_node
                   1725:                                      : long_integer_type_node);
                   1726:                else
                   1727:                  traditional_type = (spec_unsigned
                   1728:                                      ? long_long_unsigned_type_node
                   1729:                                      : long_long_integer_type_node);
                   1730:              }
                   1731:            if (warn_traditional || ! flag_traditional)
                   1732:              {
                   1733:                /* Calculate the ANSI type.  */
                   1734:                if (! spec_long && ! spec_unsigned
                   1735:                    && int_fits_type_p (yylval.ttype, integer_type_node))
                   1736:                  ansi_type = integer_type_node;
                   1737:                else if (! spec_long && (base != 10 || spec_unsigned)
                   1738:                         && int_fits_type_p (yylval.ttype, unsigned_type_node))
                   1739:                  ansi_type = unsigned_type_node;
                   1740:                else if (! spec_unsigned && !spec_long_long
                   1741:                         && int_fits_type_p (yylval.ttype, long_integer_type_node))
                   1742:                  ansi_type = long_integer_type_node;
1.1.1.4   root     1743:                else if (! spec_long_long)
1.1       root     1744:                  ansi_type = long_unsigned_type_node;
                   1745:                else if (! spec_unsigned
1.1.1.4   root     1746:                         /* Verify value does not overflow into sign bit.  */
                   1747:                         && TREE_INT_CST_HIGH (yylval.ttype) >= 0
1.1       root     1748:                         && int_fits_type_p (yylval.ttype,
                   1749:                                             long_long_integer_type_node))
                   1750:                  ansi_type = long_long_integer_type_node;
                   1751:                else
                   1752:                  ansi_type = long_long_unsigned_type_node;
                   1753:              }
                   1754: 
                   1755:            type = flag_traditional ? traditional_type : ansi_type;
                   1756: 
                   1757:            if (warn_traditional && traditional_type != ansi_type)
                   1758:              {
                   1759:                if (TYPE_PRECISION (traditional_type)
                   1760:                    != TYPE_PRECISION (ansi_type))
                   1761:                  warning ("width of integer constant changes with -traditional");
                   1762:                else if (TREE_UNSIGNED (traditional_type)
                   1763:                         != TREE_UNSIGNED (ansi_type))
                   1764:                  warning ("integer constant is unsigned in ANSI C, signed with -traditional");
1.1.1.3   root     1765:                else
                   1766:                  warning ("width of integer constant may change on other systems with -traditional");
1.1       root     1767:              }
                   1768: 
1.1.1.4   root     1769:            if (!flag_traditional && !int_fits_type_p (yylval.ttype, type)
                   1770:                && !warn)
1.1.1.3   root     1771:              pedwarn ("integer constant out of range");
                   1772: 
1.1.1.4   root     1773:            if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type))
1.1.1.5   root     1774:              warning ("decimal constant is so large that it is unsigned");
1.1.1.4   root     1775: 
1.1.1.5   root     1776:            if (spec_imag)
                   1777:              {
                   1778:                if (TYPE_PRECISION (type)
                   1779:                    <= TYPE_PRECISION (integer_type_node))
                   1780:                  yylval.ttype
                   1781:                    = build_complex (integer_zero_node,
                   1782:                                     convert (integer_type_node, yylval.ttype));
                   1783:                else
                   1784:                  error ("complex integer constant is too wide for `complex int'");
                   1785:              }
                   1786:            else if (flag_traditional && !int_fits_type_p (yylval.ttype, type))
1.1.1.4   root     1787:              /* The traditional constant 0x80000000 is signed
                   1788:                 but doesn't fit in the range of int.
                   1789:                 This will change it to -0x80000000, which does fit.  */
                   1790:              {
                   1791:                TREE_TYPE (yylval.ttype) = unsigned_type (type);
                   1792:                yylval.ttype = convert (type, yylval.ttype);
                   1793:              }
                   1794:            else
                   1795:              TREE_TYPE (yylval.ttype) = type;
                   1796: 
1.1       root     1797:            *p = 0;
                   1798:          }
                   1799: 
                   1800:        value = CONSTANT; break;
                   1801:       }
                   1802: 
                   1803:     case '\'':
                   1804:     char_constant:
                   1805:       {
                   1806:        register int result = 0;
1.1.1.4   root     1807:        register int num_chars = 0;
1.1       root     1808:        unsigned width = TYPE_PRECISION (char_type_node);
                   1809:        int max_chars;
                   1810: 
                   1811:        if (wide_flag)
                   1812:          {
                   1813:            width = WCHAR_TYPE_SIZE;
                   1814: #ifdef MULTIBYTE_CHARS
                   1815:            max_chars = MB_CUR_MAX;
                   1816: #else
                   1817:            max_chars = 1;
                   1818: #endif
                   1819:          }
                   1820:        else
                   1821:          max_chars = TYPE_PRECISION (integer_type_node) / width;
                   1822: 
                   1823:        while (1)
                   1824:          {
                   1825:          tryagain:
                   1826: 
                   1827:            c = getc (finput);
                   1828: 
                   1829:            if (c == '\'' || c == EOF)
                   1830:              break;
                   1831: 
                   1832:            if (c == '\\')
                   1833:              {
1.1.1.4   root     1834:                int ignore = 0;
                   1835:                c = readescape (&ignore);
                   1836:                if (ignore)
1.1       root     1837:                  goto tryagain;
                   1838:                if (width < HOST_BITS_PER_INT
                   1839:                    && (unsigned) c >= (1 << width))
                   1840:                  pedwarn ("escape sequence out of range for character");
1.1.1.5   root     1841: #ifdef MAP_CHARACTER
                   1842:                if (isprint (c))
                   1843:                  c = MAP_CHARACTER (c);
                   1844: #endif
1.1       root     1845:              }
                   1846:            else if (c == '\n')
                   1847:              {
                   1848:                if (pedantic)
                   1849:                  pedwarn ("ANSI C forbids newline in character constant");
                   1850:                lineno++;
                   1851:              }
1.1.1.5   root     1852: #ifdef MAP_CHARACTER
                   1853:            else
                   1854:              c = MAP_CHARACTER (c);
                   1855: #endif
1.1       root     1856: 
                   1857:            num_chars++;
                   1858:            if (num_chars > maxtoken - 4)
                   1859:              extend_token_buffer (token_buffer);
                   1860: 
                   1861:            token_buffer[num_chars] = c;
                   1862: 
                   1863:            /* Merge character into result; ignore excess chars.  */
                   1864:            if (num_chars < max_chars + 1)
                   1865:              {
                   1866:                if (width < HOST_BITS_PER_INT)
                   1867:                  result = (result << width) | (c & ((1 << width) - 1));
                   1868:                else
                   1869:                  result = c;
                   1870:              }
                   1871:          }
                   1872: 
                   1873:        token_buffer[num_chars + 1] = '\'';
                   1874:        token_buffer[num_chars + 2] = 0;
                   1875: 
                   1876:        if (c != '\'')
                   1877:          error ("malformatted character constant");
                   1878:        else if (num_chars == 0)
                   1879:          error ("empty character constant");
                   1880:        else if (num_chars > max_chars)
                   1881:          {
                   1882:            num_chars = max_chars;
                   1883:            error ("character constant too long");
                   1884:          }
                   1885:        else if (num_chars != 1 && ! flag_traditional)
                   1886:          warning ("multi-character character constant");
                   1887: 
                   1888:        /* If char type is signed, sign-extend the constant.  */
                   1889:        if (! wide_flag)
                   1890:          {
                   1891:            int num_bits = num_chars * width;
1.1.1.5   root     1892:            if (num_bits == 0)
                   1893:              /* We already got an error; avoid invalid shift.  */
                   1894:              yylval.ttype = build_int_2 (0, 0);
                   1895:            else if (TREE_UNSIGNED (char_type_node)
                   1896:                     || ((result >> (num_bits - 1)) & 1) == 0)
1.1       root     1897:              yylval.ttype
1.1.1.4   root     1898:                = build_int_2 (result & ((unsigned HOST_WIDE_INT) ~0
                   1899:                                         >> (HOST_BITS_PER_WIDE_INT - num_bits)),
1.1       root     1900:                               0);
                   1901:            else
                   1902:              yylval.ttype
1.1.1.4   root     1903:                = build_int_2 (result | ~((unsigned HOST_WIDE_INT) ~0
                   1904:                                          >> (HOST_BITS_PER_WIDE_INT - num_bits)),
1.1       root     1905:                               -1);
1.1.1.5   root     1906:            TREE_TYPE (yylval.ttype) = integer_type_node;
1.1       root     1907:          }
                   1908:        else
                   1909:          {
                   1910: #ifdef MULTIBYTE_CHARS
                   1911:            /* Set the initial shift state and convert the next sequence.  */
                   1912:            result = 0;
                   1913:            /* In all locales L'\0' is zero and mbtowc will return zero,
                   1914:               so don't use it.  */
                   1915:            if (num_chars > 1
                   1916:                || (num_chars == 1 && token_buffer[1] != '\0'))
                   1917:              {
                   1918:                wchar_t wc;
1.1.1.4   root     1919:                (void) mbtowc (NULL_PTR, NULL_PTR, 0);
1.1       root     1920:                if (mbtowc (& wc, token_buffer + 1, num_chars) == num_chars)
                   1921:                  result = wc;
                   1922:                else
                   1923:                  warning ("Ignoring invalid multibyte character");
                   1924:              }
                   1925: #endif
                   1926:            yylval.ttype = build_int_2 (result, 0);
1.1.1.5   root     1927:            TREE_TYPE (yylval.ttype) = wchar_type_node;
1.1       root     1928:          }
                   1929: 
                   1930:        value = CONSTANT;
                   1931:        break;
                   1932:       }
                   1933: 
                   1934:     case '"':
                   1935:     string_constant:
                   1936:       {
                   1937:        c = getc (finput);
                   1938:        p = token_buffer + 1;
                   1939: 
                   1940:        while (c != '"' && c >= 0)
                   1941:          {
1.1.1.6 ! root     1942:            if (c == '\\')
1.1       root     1943:              {
1.1.1.4   root     1944:                int ignore = 0;
                   1945:                c = readescape (&ignore);
                   1946:                if (ignore)
1.1       root     1947:                  goto skipnewline;
1.1.1.2   root     1948:                if (!wide_flag
                   1949:                    && TYPE_PRECISION (char_type_node) < HOST_BITS_PER_INT
                   1950:                    && c >= (1 << TYPE_PRECISION (char_type_node)))
1.1       root     1951:                  pedwarn ("escape sequence out of range for character");
                   1952:              }
                   1953:            else if (c == '\n')
                   1954:              {
                   1955:                if (pedantic)
                   1956:                  pedwarn ("ANSI C forbids newline in string constant");
                   1957:                lineno++;
                   1958:              }
                   1959: 
                   1960:            if (p == token_buffer + maxtoken)
                   1961:              p = extend_token_buffer (p);
                   1962:            *p++ = c;
                   1963: 
                   1964:          skipnewline:
                   1965:            c = getc (finput);
                   1966:          }
                   1967:        *p = 0;
                   1968: 
                   1969:        /* We have read the entire constant.
                   1970:           Construct a STRING_CST for the result.  */
                   1971: 
                   1972:        if (wide_flag)
                   1973:          {
                   1974:            /* If this is a L"..." wide-string, convert the multibyte string
                   1975:               to a wide character string.  */
                   1976:            char *widep = (char *) alloca ((p - token_buffer) * WCHAR_BYTES);
                   1977:            int len;
                   1978: 
                   1979: #ifdef MULTIBYTE_CHARS
                   1980:            len = mbstowcs ((wchar_t *) widep, token_buffer + 1, p - token_buffer);
1.1.1.5   root     1981:            if (len < 0 || len >= (p - token_buffer))
1.1       root     1982:              {
                   1983:                warning ("Ignoring invalid multibyte string");
                   1984:                len = 0;
                   1985:              }
                   1986:            bzero (widep + (len * WCHAR_BYTES), WCHAR_BYTES);
                   1987: #else
                   1988:            {
                   1989:              union { long l; char c[sizeof (long)]; } u;
                   1990:              int big_endian;
                   1991:              char *wp, *cp;
                   1992: 
                   1993:              /* Determine whether host is little or big endian.  */
                   1994:              u.l = 1;
                   1995:              big_endian = u.c[sizeof (long) - 1];
                   1996:              wp = widep + (big_endian ? WCHAR_BYTES - 1 : 0);
                   1997: 
                   1998:              bzero (widep, (p - token_buffer) * WCHAR_BYTES);
                   1999:              for (cp = token_buffer + 1; cp < p; cp++)
                   2000:                *wp = *cp, wp += WCHAR_BYTES;
                   2001:              len = p - token_buffer - 1;
                   2002:            }
                   2003: #endif
                   2004:            yylval.ttype = build_string ((len + 1) * WCHAR_BYTES, widep);
                   2005:            TREE_TYPE (yylval.ttype) = wchar_array_type_node;
1.1.1.5   root     2006:            value = STRING;
                   2007:          }
                   2008:        else if (objc_flag)
                   2009:          {
                   2010:            extern tree build_objc_string();
                   2011:            /* Return an Objective-C @"..." constant string object.  */
                   2012:            yylval.ttype = build_objc_string (p - token_buffer,
                   2013:                                              token_buffer + 1);
                   2014:            TREE_TYPE (yylval.ttype) = char_array_type_node;
                   2015:            value = OBJC_STRING;
1.1       root     2016:          }
                   2017:        else
                   2018:          {
                   2019:            yylval.ttype = build_string (p - token_buffer, token_buffer + 1);
                   2020:            TREE_TYPE (yylval.ttype) = char_array_type_node;
1.1.1.5   root     2021:            value = STRING;
1.1       root     2022:          }
                   2023: 
                   2024:        *p++ = '"';
                   2025:        *p = 0;
                   2026: 
1.1.1.5   root     2027:        break;
1.1       root     2028:       }
                   2029: 
                   2030:     case '+':
                   2031:     case '-':
                   2032:     case '&':
                   2033:     case '|':
                   2034:     case '<':
                   2035:     case '>':
                   2036:     case '*':
                   2037:     case '/':
                   2038:     case '%':
                   2039:     case '^':
                   2040:     case '!':
                   2041:     case '=':
                   2042:       {
                   2043:        register int c1;
                   2044: 
                   2045:       combine:
                   2046: 
                   2047:        switch (c)
                   2048:          {
                   2049:          case '+':
                   2050:            yylval.code = PLUS_EXPR; break;
                   2051:          case '-':
                   2052:            yylval.code = MINUS_EXPR; break;
                   2053:          case '&':
                   2054:            yylval.code = BIT_AND_EXPR; break;
                   2055:          case '|':
                   2056:            yylval.code = BIT_IOR_EXPR; break;
                   2057:          case '*':
                   2058:            yylval.code = MULT_EXPR; break;
                   2059:          case '/':
                   2060:            yylval.code = TRUNC_DIV_EXPR; break;
                   2061:          case '%':
                   2062:            yylval.code = TRUNC_MOD_EXPR; break;
                   2063:          case '^':
                   2064:            yylval.code = BIT_XOR_EXPR; break;
                   2065:          case LSHIFT:
                   2066:            yylval.code = LSHIFT_EXPR; break;
                   2067:          case RSHIFT:
                   2068:            yylval.code = RSHIFT_EXPR; break;
                   2069:          case '<':
                   2070:            yylval.code = LT_EXPR; break;
                   2071:          case '>':
                   2072:            yylval.code = GT_EXPR; break;
                   2073:          }
                   2074: 
                   2075:        token_buffer[1] = c1 = getc (finput);
                   2076:        token_buffer[2] = 0;
                   2077: 
                   2078:        if (c1 == '=')
                   2079:          {
                   2080:            switch (c)
                   2081:              {
                   2082:              case '<':
                   2083:                value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
                   2084:              case '>':
                   2085:                value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
                   2086:              case '!':
                   2087:                value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
                   2088:              case '=':
                   2089:                value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
                   2090:              }
                   2091:            value = ASSIGN; goto done;
                   2092:          }
                   2093:        else if (c == c1)
                   2094:          switch (c)
                   2095:            {
                   2096:            case '+':
                   2097:              value = PLUSPLUS; goto done;
                   2098:            case '-':
                   2099:              value = MINUSMINUS; goto done;
                   2100:            case '&':
                   2101:              value = ANDAND; goto done;
                   2102:            case '|':
                   2103:              value = OROR; goto done;
                   2104:            case '<':
                   2105:              c = LSHIFT;
                   2106:              goto combine;
                   2107:            case '>':
                   2108:              c = RSHIFT;
                   2109:              goto combine;
                   2110:            }
                   2111:        else if ((c == '-') && (c1 == '>'))
                   2112:          { value = POINTSAT; goto done; }
                   2113:        ungetc (c1, finput);
                   2114:        token_buffer[1] = 0;
                   2115: 
                   2116:        if ((c == '<') || (c == '>'))
                   2117:          value = ARITHCOMPARE;
                   2118:        else value = c;
                   2119:        goto done;
                   2120:       }
                   2121: 
                   2122:     case 0:
                   2123:       /* Don't make yyparse think this is eof.  */
                   2124:       value = 1;
                   2125:       break;
                   2126: 
                   2127:     default:
                   2128:       value = c;
                   2129:     }
                   2130: 
                   2131: done:
                   2132: /*  yylloc.last_line = lineno; */
                   2133: 
                   2134:   return value;
                   2135: }
                   2136: 
1.1.1.2   root     2137: /* Sets the value of the 'yydebug' variable to VALUE.
1.1       root     2138:    This is a function so we don't have to have YYDEBUG defined
                   2139:    in order to build the compiler.  */
                   2140: 
                   2141: void
                   2142: set_yydebug (value)
                   2143:      int value;
                   2144: {
                   2145: #if YYDEBUG != 0
                   2146:   yydebug = value;
                   2147: #else
                   2148:   warning ("YYDEBUG not defined.");
                   2149: #endif
                   2150: }

unix.superglobalmegacorp.com

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