OSDN Git Service

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