OSDN Git Service

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