OSDN Git Service

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