OSDN Git Service

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