OSDN Git Service

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