OSDN Git Service

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