home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Compilers⁄Interps / GCC-2.3.3r12 / Sources-C / c-lex.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-27  |  51.2 KB  |  2,049 lines  |  [TEXT/MPS ]

  1. /* Lexical analyzer for C and Objective C.
  2.    Copyright (C) 1987, 1988, 1989, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #ifdef MPW
  21. #include <stdlib.h>
  22. #endif
  23. #include <stdio.h>
  24. #include <errno.h>
  25. #include <setjmp.h>
  26.  
  27. #include "config.h"
  28. #include "rtl.h"
  29. #include "tree.h"
  30. #include "input.h"
  31. #include "c-lex.h"
  32. #include "c-tree.h"
  33. #include "flags.h"
  34. #include "c-parse.h"
  35.  
  36. #ifdef MULTIBYTE_CHARS
  37. #ifndef MPW
  38. #include <stdlib.h>
  39. #endif
  40. #include <locale.h>
  41. #endif
  42.  
  43. #ifndef errno
  44. extern int errno;
  45. #endif
  46.  
  47. /* The elements of `ridpointers' are identifier nodes
  48.    for the reserved type names and storage classes.
  49.    It is indexed by a RID_... value.  */
  50. tree ridpointers[(int) RID_MAX];
  51.  
  52. /* Cause the `yydebug' variable to be defined.  */
  53. #define YYDEBUG 1
  54.  
  55. /* the declaration found for the last IDENTIFIER token read in.
  56.    yylex must look this up to detect typedefs, which get token type TYPENAME,
  57.    so it is left around in case the identifier is not a typedef but is
  58.    used in a context which makes it a reference to a variable.  */
  59. tree lastiddecl;
  60.  
  61. /* Nonzero enables objc features.  */
  62.  
  63. int doing_objc_thang;
  64.  
  65. extern tree lookup_interface ();
  66.  
  67. extern int yydebug;
  68.  
  69. /* File used for outputting assembler code.  */
  70. extern FILE *asm_out_file;
  71.  
  72. #ifndef WCHAR_TYPE_SIZE
  73. #ifdef INT_TYPE_SIZE
  74. #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
  75. #else
  76. #define WCHAR_TYPE_SIZE    BITS_PER_WORD
  77. #endif
  78. #endif
  79.  
  80. /* Number of bytes in a wide character.  */
  81. #define WCHAR_BYTES (WCHAR_TYPE_SIZE / BITS_PER_UNIT)
  82.  
  83. static int maxtoken;        /* Current nominal length of token buffer.  */
  84. char *token_buffer;    /* Pointer to token buffer.
  85.                Actual allocated length is maxtoken + 2.
  86.                This is not static because objc-parse.y uses it.  */
  87.  
  88. /* Nonzero if end-of-file has been seen on input.  */
  89. static int end_of_file;
  90.  
  91. /* Buffered-back input character; faster than using ungetc.  */
  92. static int nextchar = -1;
  93.  
  94. int check_newline ();
  95.  
  96. /* Nonzero tells yylex to ignore \ in string constants.  */
  97. static int ignore_escape_flag = 0;
  98.  
  99. /* starting time is 13:31:54 */
  100. /* C code produced by gperf version 2.5 (GNU C++ version) */
  101. /* Command-line: gperf -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf  */ 
  102. struct resword { char *name; short token; enum rid rid; };
  103.  
  104. #define TOTAL_KEYWORDS 56
  105. #define MIN_WORD_LENGTH 2
  106. #define MAX_WORD_LENGTH 13
  107. #define MIN_HASH_VALUE 7
  108. #define MAX_HASH_VALUE 114
  109. /* maximum key range = 108, duplicates = 0 */
  110.  
  111. #if 0/*def __GNUC__*/
  112. inline
  113. #endif
  114. static unsigned int
  115. hash (str, len)
  116.      register char *str;
  117.      register int unsigned len;
  118. {
  119.   static unsigned char asso_values[] =
  120.     {
  121.      115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
  122.      115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
  123.      115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
  124.      115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
  125.      115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
  126.      115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
  127.      115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
  128.      115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
  129.      115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
  130.      115, 115, 115, 115, 115,   1, 115,   2,   1,  24,
  131.       26,   5,  19,  28,   6,  13, 115,   1,  12,   1,
  132.       30,  21,  35, 115,  39,  12,   1,  20,  27,   9,
  133.      115, 115,   1, 115, 115, 115, 115, 115,
  134.     };
  135.   register int hval = len;
  136.  
  137.   switch (hval)
  138.     {
  139.       default:
  140.       case 3:
  141.         hval += asso_values[str[2]];
  142.       case 2:
  143.       case 1:
  144.         hval += asso_values[str[0]];
  145.     }
  146.   return hval + asso_values[str[len - 1]];
  147. }
  148.  
  149. #if 0/*def __GNUC__*/
  150. inline
  151. #endif
  152. struct resword *
  153. is_reserved_word (str, len)
  154.      register char *str;
  155.      register unsigned int len;
  156. {
  157.   static struct resword wordlist[] =
  158.     {
  159.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  160.       {"asm",  ASM_KEYWORD, NORID},
  161.       {"",}, 
  162.       {"__asm",  ASM_KEYWORD, NORID},
  163.       {"",}, 
  164.       {"__asm__",  ASM_KEYWORD, NORID},
  165.       {"break",  BREAK, NORID},
  166.       {"__typeof__",  TYPEOF, NORID},
  167.       {"",}, 
  168.       {"__alignof__",  ALIGNOF, NORID},
  169.       {"",}, 
  170.       {"__attribute__",  ATTRIBUTE, NORID},
  171.       {"int",  TYPESPEC, RID_INT},
  172.       {"__attribute",  ATTRIBUTE, NORID},
  173.       {"__extension__",  EXTENSION, NORID},
  174.       {"",}, {"",}, 
  175.       {"__label__",  LABEL, NORID},
  176.       {"__signed__",  TYPESPEC, RID_SIGNED},
  177.       {"__inline__",  SCSPEC, RID_INLINE},
  178.       {"else",  ELSE, NORID},
  179.       {"__inline",  SCSPEC, RID_INLINE},
  180.       {"auto",  SCSPEC, RID_AUTO},
  181.       {"__typeof",  TYPEOF, NORID},
  182.       {"enum",  ENUM, NORID},
  183.       {"__alignof",  ALIGNOF, NORID},
  184.       {"while",  WHILE, NORID},
  185.       {"__const",  TYPE_QUAL, RID_CONST},
  186.       {"if",  IF, NORID},
  187.       {"__const__",  TYPE_QUAL, RID_CONST},
  188.       {"inline",  SCSPEC, RID_INLINE},
  189.       {"switch",  SWITCH, NORID},
  190.       {"sizeof",  SIZEOF, NORID},
  191.       {"short",  TYPESPEC, RID_SHORT},
  192.       {"extended",  TYPESPEC, RID_EXTENDED,},
  193.       {"__volatile__",  TYPE_QUAL, RID_VOLATILE},
  194.       {"extern",  SCSPEC, RID_EXTERN},
  195.       {"__volatile",  TYPE_QUAL, RID_VOLATILE},
  196.       {"static",  SCSPEC, RID_STATIC},
  197.       {"case",  CASE, NORID},
  198.       {"float",  TYPESPEC, RID_FLOAT},
  199.       {"__signed",  TYPESPEC, RID_SIGNED},
  200.       {"",}, 
  201.       {"do",  DO, NORID},
  202.       {"",}, {"",}, 
  203.       {"volatile",  TYPE_QUAL, RID_VOLATILE},
  204.       {"default",  DEFAULT, NORID},
  205.       {"goto",  GOTO, NORID},
  206.       {"",}, {"",}, 
  207.       {"double",  TYPESPEC, RID_DOUBLE},
  208.       {"struct",  STRUCT, NORID},
  209.       {"",}, 
  210.       {"const",  TYPE_QUAL, RID_CONST},
  211.       {"typeof",  TYPEOF, NORID},
  212.       {"typedef",  SCSPEC, RID_TYPEDEF},
  213.       {"",}, 
  214.       {"comp",  TYPESPEC, RID_COMP},
  215.       {"pascal",  SCSPEC, RID_PASCAL,},
  216.       {"unsigned",  TYPESPEC, RID_UNSIGNED},
  217.       {"continue",  CONTINUE, NORID},
  218.       {"union",  UNION, NORID},
  219.       {"char",  TYPESPEC, RID_CHAR},
  220.       {"void",  TYPESPEC, RID_VOID},
  221.       {"",}, 
  222.       {"signed",  TYPESPEC, RID_SIGNED},
  223.       {"",}, 
  224.       {"long",  TYPESPEC, RID_LONG},
  225.       {"",}, 
  226.       {"return",  RETURN, NORID},
  227.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  228.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  229.       {"",}, {"",}, {"",}, {"",}, {"",}, 
  230.       {"for",  FOR, NORID},
  231.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  232.       {"",}, {"",}, {"",}, {"",}, 
  233.       {"register",  SCSPEC, RID_REGISTER},
  234.     };
  235.  
  236.   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
  237.     {
  238.       register int key = hash (str, len);
  239.  
  240.       if (key <= MAX_HASH_VALUE && key >= 0)
  241.         {
  242.           register char *s = wordlist[key].name;
  243.  
  244.           if (*s == *str && !strcmp (str + 1, s + 1))
  245.             return &wordlist[key];
  246.         }
  247.     }
  248.   return 0;
  249. }
  250. /* ending time is 13:31:54 */
  251.  
  252. /* Return something to represent absolute declarators containing a *.
  253.    TARGET is the absolute declarator that the * contains.
  254.    TYPE_QUALS is a list of modifiers such as const or volatile
  255.    to apply to the pointer type, represented as identifiers.
  256.  
  257.    We return an INDIRECT_REF whose "contents" are TARGET
  258.    and whose type is the modifier list.  */
  259.  
  260. tree
  261. make_pointer_declarator (type_quals, target)
  262.      tree type_quals, target;
  263. {
  264.   return build1 (INDIRECT_REF, type_quals, target);
  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. #endif
  281.  
  282.   maxtoken = 40;
  283.   token_buffer = (char *) xmalloc (maxtoken + 2);
  284.  
  285.   ridpointers[(int) RID_INT] = get_identifier ("int");
  286.   ridpointers[(int) RID_CHAR] = get_identifier ("char");
  287.   ridpointers[(int) RID_VOID] = get_identifier ("void");
  288.   ridpointers[(int) RID_FLOAT] = get_identifier ("float");
  289.   ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
  290.   ridpointers[(int) RID_SHORT] = get_identifier ("short");
  291.   ridpointers[(int) RID_LONG] = get_identifier ("long");
  292.   ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
  293.   ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
  294.   ridpointers[(int) RID_INLINE] = get_identifier ("inline");
  295.   ridpointers[(int) RID_CONST] = get_identifier ("const");
  296.   ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
  297.   ridpointers[(int) RID_AUTO] = get_identifier ("auto");
  298.   ridpointers[(int) RID_STATIC] = get_identifier ("static");
  299.   ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
  300.   ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
  301.   ridpointers[(int) RID_REGISTER] = get_identifier ("register");
  302.   /* Add Apple-defined keywords to the rid table. */
  303.   if (flag_apple)
  304.     {
  305.       ridpointers[(int) RID_COMP] = get_identifier ("comp"); 
  306.       ridpointers[(int) RID_EXTENDED] = get_identifier ("extended");
  307.       ridpointers[(int) RID_PASCAL] = get_identifier ("pascal");
  308.     }
  309.  
  310.   /* Some options inhibit certain reserved words.
  311.      Clear those words out of the hash table so they won't be recognized.  */
  312. #define UNSET_RESERVED_WORD(STRING) \
  313.   do { struct resword *s = is_reserved_word (STRING, sizeof (STRING) - 1); \
  314.        if (s) s->name = ""; } while (0)
  315.  
  316.   if (flag_traditional)
  317.     {
  318.       UNSET_RESERVED_WORD ("const");
  319.       UNSET_RESERVED_WORD ("volatile");
  320.       UNSET_RESERVED_WORD ("typeof");
  321.       UNSET_RESERVED_WORD ("signed");
  322.       UNSET_RESERVED_WORD ("inline");
  323.     }
  324.   if (flag_no_asm)
  325.     {
  326.       UNSET_RESERVED_WORD ("asm");
  327.       UNSET_RESERVED_WORD ("typeof");
  328.       UNSET_RESERVED_WORD ("inline");
  329.     }
  330.   /* If Apple extensions are disabled, then the extra keywords
  331.      should not be reserved. */
  332.   if (!flag_apple)
  333.     {
  334.       UNSET_RESERVED_WORD ("pascal");
  335.       UNSET_RESERVED_WORD ("comp");
  336.       UNSET_RESERVED_WORD ("extended");
  337.     }
  338. }
  339.  
  340. void
  341. reinit_parse_for_function ()
  342. {
  343. }
  344.  
  345. /* Function used when yydebug is set, to print a token in more detail.  */
  346.  
  347. void
  348. yyprint (file, yychar, yylval)
  349.      FILE *file;
  350.      int yychar;
  351.      YYSTYPE yylval;
  352. {
  353.   tree t;
  354.   switch (yychar)
  355.     {
  356.     case IDENTIFIER:
  357.     case TYPENAME:
  358.       t = yylval.ttype;
  359.       if (IDENTIFIER_POINTER (t))
  360.     fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
  361.       break;
  362.  
  363.     case CONSTANT:
  364.       t = yylval.ttype;
  365.       if (TREE_CODE (t) == INTEGER_CST)
  366.     fprintf (file,
  367. #if HOST_BITS_PER_WIDE_INT == 64
  368. #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
  369.          " 0x%lx%016lx",
  370. #else
  371.          " 0x%x%016x",
  372. #endif
  373. #else
  374. #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
  375.          " 0x%lx%08lx",
  376. #else
  377.          " 0x%x%08x",
  378. #endif
  379. #endif
  380.          TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
  381.       break;
  382.     }
  383. }
  384.  
  385.  
  386. /* If C is not whitespace, return C.
  387.    Otherwise skip whitespace and return first nonwhite char read.  */
  388.  
  389. static int
  390. skip_white_space (c)
  391.      register int c;
  392. {
  393.   static int newline_warning = 0;
  394.  
  395.   for (;;)
  396.     {
  397.       switch (c)
  398.     {
  399.       /* We don't recognize comments here, because
  400.          cpp output can include / and * consecutively as operators.
  401.          Also, there's no need, since cpp removes all comments.  */
  402.  
  403.     case '\n':
  404.       c = check_newline ();
  405.       break;
  406.  
  407.     case ' ':
  408.     case '\t':
  409.     case '\f':
  410.     case '\v':
  411.     case '\b':
  412.       c = getc (finput);
  413.       break;
  414.  
  415.     case '\r':
  416.       /* ANSI C says the effects of a carriage return in a source file
  417.          are undefined.  */
  418.       if (pedantic && !newline_warning)
  419.         {
  420.           warning ("carriage return in source file");
  421.           warning ("(we only warn about the first carriage return)");
  422.           newline_warning = 1;
  423.         }
  424.       c = getc (finput);
  425.       break;
  426.  
  427.     case '\\':
  428.       c = getc (finput);
  429.       if (c == '\n')
  430.         lineno++;
  431.       else
  432.         error ("stray '\\' in program");
  433.       c = getc (finput);
  434.       break;
  435.  
  436.     default:
  437.       return (c);
  438.     }
  439.     }
  440. }
  441.  
  442. /* Skips all of the white space at the current location in the input file.
  443.    Must use and reset nextchar if it has the next character.  */
  444.  
  445. void
  446. position_after_white_space ()
  447. {
  448.   register int c;
  449.  
  450.   if (nextchar != -1)
  451.     c = nextchar, nextchar = -1;
  452.   else
  453.     c = getc (finput);
  454.  
  455.   ungetc (skip_white_space (c), finput);
  456. }
  457.  
  458. /* Make the token buffer longer, preserving the data in it.
  459.    P should point to just beyond the last valid character in the old buffer.
  460.    The value we return is a pointer to the new buffer
  461.    at a place corresponding to P.  */
  462.  
  463. static char *
  464. extend_token_buffer (p)
  465.      char *p;
  466. {
  467.   int offset = p - token_buffer;
  468.  
  469.   maxtoken = maxtoken * 2 + 10;
  470.   token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
  471.  
  472.   return token_buffer + offset;
  473. }
  474.  
  475. /* At the beginning of a line, increment the line number
  476.    and process any #-directive on this line.
  477.    If the line is a #-directive, read the entire line and return a newline.
  478.    Otherwise, return the line's first non-whitespace character.  */
  479.  
  480. int
  481. check_newline ()
  482. {
  483.   register int c;
  484.   register int token;
  485.  
  486.   lineno++;
  487.  
  488.   /* Read first nonwhite char on the line.  */
  489.  
  490.   c = getc (finput);
  491.   while (c == ' ' || c == '\t')
  492.     c = getc (finput);
  493.  
  494.   if (c != '#')
  495.     {
  496.       /* If not #, return it so caller will use it.  */
  497.       return c;
  498.     }
  499.  
  500.   /* Read first nonwhite char after the `#'.  */
  501.  
  502.   c = getc (finput);
  503.   while (c == ' ' || c == '\t')
  504.     c = getc (finput);
  505.  
  506.   /* If a letter follows, then if the word here is `line', skip
  507.      it and ignore it; otherwise, ignore the line, with an error
  508.      if the word isn't `pragma', `ident', `define', or `undef'.  */
  509.  
  510.   if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
  511.     {
  512.       if (c == 'p')
  513.     {
  514.       if (getc (finput) == 'r'
  515.           && getc (finput) == 'a'
  516.           && getc (finput) == 'g'
  517.           && getc (finput) == 'm'
  518.           && getc (finput) == 'a'
  519.           && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
  520.         {
  521. #ifdef HANDLE_SYSV_PRAGMA
  522.           return handle_sysv_pragma (finput, c);
  523. #endif /* HANDLE_SYSV_PRAGMA */
  524. #ifdef HANDLE_MPW_PRAGMA
  525.           /* Handling for MPW-defined pragmas. */
  526.           return handle_mpw_pragma (finput, c);
  527. #endif /* HANDLE_MPW_PRAGMA */
  528. #ifdef HANDLE_PRAGMA
  529.           HANDLE_PRAGMA (finput);
  530. #endif /* HANDLE_PRAGMA */
  531.           goto skipline;
  532.         }
  533.     }
  534.  
  535.       else if (c == 'd')
  536.     {
  537.       if (getc (finput) == 'e'
  538.           && getc (finput) == 'f'
  539.           && getc (finput) == 'i'
  540.           && getc (finput) == 'n'
  541.           && getc (finput) == 'e'
  542.           && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
  543.         {
  544. #ifdef DWARF_DEBUGGING_INFO
  545.           if ((debug_info_level == DINFO_LEVEL_VERBOSE)
  546.           && (write_symbols == DWARF_DEBUG))
  547.             dwarfout_define (lineno, get_directive_line (finput));
  548. #endif /* DWARF_DEBUGGING_INFO */
  549.           goto skipline;
  550.         }
  551.     }
  552.       else if (c == 'u')
  553.     {
  554.       if (getc (finput) == 'n'
  555.           && getc (finput) == 'd'
  556.           && getc (finput) == 'e'
  557.           && getc (finput) == 'f'
  558.           && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
  559.         {
  560. #ifdef DWARF_DEBUGGING_INFO
  561.           if ((debug_info_level == DINFO_LEVEL_VERBOSE)
  562.           && (write_symbols == DWARF_DEBUG))
  563.             dwarfout_undef (lineno, get_directive_line (finput));
  564. #endif /* DWARF_DEBUGGING_INFO */
  565.           goto skipline;
  566.         }
  567.     }
  568.       else if (c == 'l')
  569.     {
  570.       if (getc (finput) == 'i'
  571.           && getc (finput) == 'n'
  572.           && getc (finput) == 'e'
  573.           && ((c = getc (finput)) == ' ' || c == '\t'))
  574.         goto linenum;
  575.     }
  576.       else if (c == 'i')
  577.     {
  578.       if (getc (finput) == 'd'
  579.           && getc (finput) == 'e'
  580.           && getc (finput) == 'n'
  581.           && getc (finput) == 't'
  582.           && ((c = getc (finput)) == ' ' || c == '\t'))
  583.         {
  584.           /* #ident.  The pedantic warning is now in cccp.c.  */
  585.  
  586.           /* Here we have just seen `#ident '.
  587.          A string constant should follow.  */
  588.  
  589.           while (c == ' ' || c == '\t')
  590.         c = getc (finput);
  591.  
  592.           /* If no argument, ignore the line.  */
  593.           if (c == '\n')
  594.         return c;
  595.  
  596.           ungetc (c, finput);
  597.           token = yylex ();
  598.           if (token != STRING
  599.           || TREE_CODE (yylval.ttype) != STRING_CST)
  600.         {
  601.           error ("invalid #ident");
  602.           goto skipline;
  603.         }
  604.  
  605.           if (!flag_no_ident)
  606.         {
  607. #ifdef ASM_OUTPUT_IDENT
  608.           ASM_OUTPUT_IDENT (asm_out_file, TREE_STRING_POINTER (yylval.ttype));
  609. #endif
  610.         }
  611.  
  612.           /* Skip the rest of this line.  */
  613.           goto skipline;
  614.         }
  615.     }
  616.  
  617.       error ("undefined or invalid # directive");
  618.       goto skipline;
  619.     }
  620.  
  621. linenum:
  622.   /* Here we have either `#line' or `# <nonletter>'.
  623.      In either case, it should be a line number; a digit should follow.  */
  624.  
  625.   while (c == ' ' || c == '\t')
  626.     c = getc (finput);
  627.  
  628.   /* If the # is the only nonwhite char on the line,
  629.      just ignore it.  Check the new newline.  */
  630.   if (c == '\n')
  631.     return c;
  632.  
  633.   /* Something follows the #; read a token.  */
  634.  
  635.   ungetc (c, finput);
  636.   token = yylex ();
  637.  
  638.   if (token == CONSTANT
  639.       && TREE_CODE (yylval.ttype) == INTEGER_CST)
  640.     {
  641.       int old_lineno = lineno;
  642.       int used_up = 0;
  643.       /* subtract one, because it is the following line that
  644.      gets the specified number */
  645.  
  646.       int l = TREE_INT_CST_LOW (yylval.ttype) - 1;
  647.  
  648.       /* Is this the last nonwhite stuff on the line?  */
  649.       c = getc (finput);
  650.       while (c == ' ' || c == '\t')
  651.     c = getc (finput);
  652.       if (c == '\n')
  653.     {
  654.       /* No more: store the line number and check following line.  */
  655.       lineno = l;
  656.       return c;
  657.     }
  658.       ungetc (c, finput);
  659.  
  660.       /* More follows: it must be a string constant (filename).  */
  661.  
  662.       /* Read the string constant, but don't treat \ as special.  */
  663.       ignore_escape_flag = 1;
  664.       token = yylex ();
  665.       ignore_escape_flag = 0;
  666.  
  667.       if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
  668.     {
  669.       error ("invalid #line");
  670.       goto skipline;
  671.     }
  672.  
  673.       input_filename
  674.     = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1);
  675.       strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype));
  676.       lineno = l;
  677.  
  678.       /* Each change of file name
  679.      reinitializes whether we are now in a system header.  */
  680.       in_system_header = 0;
  681.  
  682.       if (main_input_filename == 0)
  683.     main_input_filename = input_filename;
  684.  
  685.       /* Is this the last nonwhite stuff on the line?  */
  686.       c = getc (finput);
  687.       while (c == ' ' || c == '\t')
  688.     c = getc (finput);
  689.       if (c == '\n')
  690.     return c;
  691.       ungetc (c, finput);
  692.  
  693.       token = yylex ();
  694.       used_up = 0;
  695.  
  696.       /* `1' after file name means entering new file.
  697.      `2' after file name means just left a file.  */
  698.  
  699.       if (token == CONSTANT
  700.       && TREE_CODE (yylval.ttype) == INTEGER_CST)
  701.     {
  702.       if (TREE_INT_CST_LOW (yylval.ttype) == 1)
  703.         {
  704.           /* Pushing to a new file.  */
  705.           struct file_stack *p
  706.         = (struct file_stack *) xmalloc (sizeof (struct file_stack));
  707.           input_file_stack->line = old_lineno;
  708.           p->next = input_file_stack;
  709.           p->name = input_filename;
  710.           input_file_stack = p;
  711.           input_file_stack_tick++;
  712. #ifdef DWARF_DEBUGGING_INFO
  713.           if (debug_info_level == DINFO_LEVEL_VERBOSE
  714.           && write_symbols == DWARF_DEBUG)
  715.         dwarfout_start_new_source_file (input_filename);
  716. #endif /* DWARF_DEBUGGING_INFO */
  717.  
  718.           used_up = 1;
  719.         }
  720.       else if (TREE_INT_CST_LOW (yylval.ttype) == 2)
  721.         {
  722.           /* Popping out of a file.  */
  723.           if (input_file_stack->next)
  724.         {
  725.           struct file_stack *p = input_file_stack;
  726.           input_file_stack = p->next;
  727.           free (p);
  728.           input_file_stack_tick++;
  729. #ifdef DWARF_DEBUGGING_INFO
  730.           if (debug_info_level == DINFO_LEVEL_VERBOSE
  731.               && write_symbols == DWARF_DEBUG)
  732.             dwarfout_resume_previous_source_file (input_file_stack->line);
  733. #endif /* DWARF_DEBUGGING_INFO */
  734.         }
  735.           else
  736.         error ("#-lines for entering and leaving files don't match");
  737.  
  738.           used_up = 1;
  739.         }
  740.     }
  741.  
  742.       /* If we have handled a `1' or a `2',
  743.      see if there is another number to read.  */
  744.       if (used_up)
  745.     {
  746.       /* Is this the last nonwhite stuff on the line?  */
  747.       c = getc (finput);
  748.       while (c == ' ' || c == '\t')
  749.         c = getc (finput);
  750.       if (c == '\n')
  751.         return c;
  752.       ungetc (c, finput);
  753.  
  754.       token = yylex ();
  755.       used_up = 0;
  756.     }
  757.  
  758.       /* `3' after file name means this is a system header file.  */
  759.  
  760.       if (token == CONSTANT
  761.       && TREE_CODE (yylval.ttype) == INTEGER_CST
  762.       && TREE_INT_CST_LOW (yylval.ttype) == 3)
  763.     in_system_header = 1;
  764.     }
  765.   else
  766.     error ("invalid #-line");
  767.  
  768.   /* skip the rest of this line.  */
  769.  skipline:
  770.   if (c == '\n')
  771.     return c;
  772.   while ((c = getc (finput)) != EOF && c != '\n');
  773.   return c;
  774. }
  775.  
  776. #ifdef HANDLE_SYSV_PRAGMA
  777.  
  778. /* Handle a #pragma directive.  INPUT is the current input stream,
  779.    and C is a character to reread.  Processes the entire input line
  780.    and returns a character for the caller to reread: either \n or EOF.  */
  781.  
  782. /* This function has to be in this file, in order to get at
  783.    the token types.  */
  784.  
  785. int
  786. handle_sysv_pragma (input, c)
  787.      FILE *input;
  788.      int c;
  789. {
  790.   for (;;)
  791.     {
  792.       while (c == ' ' || c == '\t')
  793.     c = getc (input);
  794.       if (c == '\n' || c == EOF)
  795.     {
  796.       handle_pragma_token (0, 0);
  797.       return c;
  798.     }
  799.       ungetc (c, input);
  800.       switch (yylex ())
  801.     {
  802.     case IDENTIFIER:
  803.     case TYPENAME:
  804.     case STRING:
  805.     case CONSTANT:
  806.       handle_pragma_token (token_buffer, yylval.ttype);
  807.       break;
  808.     default:
  809.       handle_pragma_token (token_buffer, 0);
  810.     }
  811.       if (nextchar >= 0)
  812.     c = nextchar, nextchar = -1;
  813.       else
  814.     c = getc (input);
  815.     }
  816. }
  817.  
  818. #endif /* HANDLE_SYSV_PRAGMA */
  819.  
  820. #ifdef HANDLE_MPW_PRAGMA
  821.  
  822. /* Handle a #pragma directive.  INPUT is the current input stream,
  823.    and C is a character to reread.  Processes the entire input line
  824.    and returns a character for the caller to reread: either \n or EOF.  */
  825.  
  826. /* This function has to be in this file, in order to get at
  827.    the token types.  */
  828.  
  829. int
  830. handle_mpw_pragma (input, c)
  831.      FILE *input;
  832.      int c;
  833. {
  834.   for (;;)
  835.     {
  836.       while (c == ' ' || c == '\t')
  837.     c = getc (input);
  838.       if (c == '\n' || c == EOF)
  839.     {
  840.       handle_pragma_token (0, 0);
  841.       return c;
  842.     }
  843.       ungetc (c, input);
  844.       switch (yylex ())
  845.     {
  846.     case IDENTIFIER:
  847.     case TYPENAME:
  848. #ifdef HANDLE_SEGMENT_PRAGMA
  849.       /* The MPW-style segment pragma uses all chars up to the
  850.          end of the line to be the name of the current segment. */
  851.       if (strcmp(token_buffer, "segment") == 0)
  852.         {
  853.           char pragma_line_buffer[200];
  854.           int i = 0;
  855.  
  856.           while ((c = getc (input)) != EOF && c != '\n')
  857.         {
  858.           pragma_line_buffer[i++] = c;
  859.           /* something's bad wrong if this happens */
  860.           if (i >= 200) abort ();
  861.         }
  862.           if (c == '\n') ungetc(c, input);
  863.           pragma_line_buffer[i] = '\0';
  864.           set_segment_name (pragma_line_buffer);
  865.           break;
  866.         }
  867. #endif /* HANDLE_SEGMENT_PRAGMA */
  868.       /* Other pragma keywords. */
  869.       handle_pragma_token (token_buffer, yylval.ttype);
  870.       break;
  871.     case STRING:
  872.     case CONSTANT:
  873.       handle_pragma_token (token_buffer, yylval.ttype);
  874.       break;
  875.     default:
  876.       handle_pragma_token (token_buffer, 0);
  877.     }
  878.       if (nextchar >= 0)
  879.     c = nextchar, nextchar = -1;
  880.       else
  881.     c = getc (input);
  882.     }
  883. }
  884.  
  885. #endif /* HANDLE_MPW_PRAGMA */
  886.  
  887. #define isalnum(char) ((char >= 'a' && char <= 'z') || (char >= 'A' && char <= 'Z') || (char >= '0' && char <= '9'))
  888. #define isdigit(char) (char >= '0' && char <= '9')
  889. #define ENDFILE -1  /* token that represents end-of-file */
  890.  
  891. /* Read an escape sequence, returning its equivalent as a character,
  892.    or store 1 in *ignore_ptr if it is backslash-newline.  */
  893.  
  894. static int
  895. readescape (ignore_ptr)
  896.      int *ignore_ptr;
  897. {
  898.   register int c = getc (finput);
  899.   register int code;
  900.   register unsigned count;
  901.   unsigned firstdig;
  902.   int nonnull;
  903.  
  904.   switch (c)
  905.     {
  906.     case 'x':
  907.       if (warn_traditional)
  908.     warning ("the meaning of `\\x' varies with -traditional");
  909.  
  910.       if (flag_traditional)
  911.     return c;
  912.  
  913.       code = 0;
  914.       count = 0;
  915.       nonnull = 0;
  916.       while (1)
  917.     {
  918.       c = getc (finput);
  919.       if (!(c >= 'a' && c <= 'f')
  920.           && !(c >= 'A' && c <= 'F')
  921.           && !(c >= '0' && c <= '9'))
  922.         {
  923.           ungetc (c, finput);
  924.           break;
  925.         }
  926.       code *= 16;
  927.       if (c >= 'a' && c <= 'f')
  928.         code += c - 'a' + 10;
  929.       if (c >= 'A' && c <= 'F')
  930.         code += c - 'A' + 10;
  931.       if (c >= '0' && c <= '9')
  932.         code += c - '0';
  933.       if (code != 0 || count != 0)
  934.         {
  935.           if (count == 0)
  936.         firstdig = code;
  937.           count++;
  938.         }
  939.       nonnull = 1;
  940.     }
  941.       if (! nonnull)
  942.     error ("\\x used with no following hex digits");
  943.       else if (count == 0)
  944.     /* Digits are all 0's.  Ok.  */
  945.     ;
  946.       else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
  947.            || (count > 1
  948.            && ((1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4))
  949.                <= firstdig)))
  950.     pedwarn ("hex escape out of range");
  951.       return code;
  952.  
  953.     case '0':  case '1':  case '2':  case '3':  case '4':
  954.     case '5':  case '6':  case '7':
  955.       code = 0;
  956.       count = 0;
  957.       while ((c <= '7') && (c >= '0') && (count++ < 3))
  958.     {
  959.       code = (code * 8) + (c - '0');
  960.       c = getc (finput);
  961.     }
  962.       ungetc (c, finput);
  963.       return code;
  964.  
  965.     case '\\': case '\'': case '"':
  966.       return c;
  967.  
  968.     case '\n':
  969.       lineno++;
  970.       *ignore_ptr = 1;
  971.       return 0;
  972.  
  973.     case 'n':
  974.       return TARGET_NEWLINE;
  975.  
  976.     case 't':
  977.       return TARGET_TAB;
  978.  
  979.     case 'r':
  980.       return TARGET_CR;
  981.  
  982.     case 'f':
  983.       return TARGET_FF;
  984.  
  985.     case 'b':
  986.       return TARGET_BS;
  987.  
  988.     case 'a':
  989.       if (warn_traditional)
  990.     warning ("the meaning of `\\a' varies with -traditional");
  991.  
  992.       if (flag_traditional)
  993.     return c;
  994.       return TARGET_BELL;
  995.  
  996.     case 'v':
  997. #if 0 /* Vertical tab is present in common usage compilers.  */
  998.       if (flag_traditional)
  999.     return c;
  1000. #endif
  1001.       return TARGET_VT;
  1002.  
  1003.     case 'e':
  1004.     case 'E':
  1005.       if (pedantic)
  1006.     pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c);
  1007.       return 033;
  1008.  
  1009.     case '?':
  1010.       return c;
  1011.  
  1012.       /* `\(', etc, are used at beginning of line to avoid confusing Emacs.  */
  1013.     case '(':
  1014.     case '{':
  1015.     case '[':
  1016.       if (pedantic)
  1017.     pedwarn ("non-ANSI escape sequence `\\%c'", c);
  1018.       return c;
  1019.     }
  1020.     /* backslash-p needs to return a special code so that the string
  1021.        constructor can leave a hole and patch in the string length later. */
  1022.     /* (What happens if this char appears in a char constant?) */
  1023.     if (flag_apple && c == 'p') 
  1024.       return -2;
  1025.   if (c >= 040 && c < 0177)
  1026.     pedwarn ("unknown escape sequence `\\%c'", c);
  1027.   else
  1028.     pedwarn ("unknown escape sequence: `\\' followed by char code 0x%x", c);
  1029.   return c;
  1030. }
  1031.  
  1032. void
  1033. yyerror (string)
  1034.      char *string;
  1035. {
  1036.   char buf[200];
  1037.  
  1038.   strcpy (buf, string);
  1039.  
  1040.   /* We can't print string and character constants well
  1041.      because the token_buffer contains the result of processing escapes.  */
  1042.   if (end_of_file)
  1043.     strcat (buf, " at end of input");
  1044.   else if (token_buffer[0] == 0)
  1045.     strcat (buf, " at null character");
  1046.   else if (token_buffer[0] == '"')
  1047.     strcat (buf, " before string constant");
  1048.   else if (token_buffer[0] == '\'')
  1049.     strcat (buf, " before character constant");
  1050.   else if (token_buffer[0] < 040 || (unsigned char) token_buffer[0] >= 0177)
  1051.     sprintf (buf + strlen (buf), " before character 0%o",
  1052.          (unsigned char) token_buffer[0]);
  1053.   else
  1054.     strcat (buf, " before `%s'");
  1055.  
  1056.   error (buf, token_buffer);
  1057. }
  1058.  
  1059. #if 0
  1060.  
  1061. struct try_type
  1062. {
  1063.   tree *node_var;
  1064.   char unsigned_flag;
  1065.   char long_flag;
  1066.   char long_long_flag;
  1067. };
  1068.  
  1069. struct try_type type_sequence[] = 
  1070. {
  1071.   { &integer_type_node, 0, 0, 0},
  1072.   { &unsigned_type_node, 1, 0, 0},
  1073.   { &long_integer_type_node, 0, 1, 0},
  1074.   { &long_unsigned_type_node, 1, 1, 0},
  1075.   { &long_long_integer_type_node, 0, 1, 1},
  1076.   { &long_long_unsigned_type_node, 1, 1, 1}
  1077. };
  1078. #endif /* 0 */
  1079.  
  1080. int
  1081. yylex ()
  1082. {
  1083.   register int c;
  1084.   register char *p;
  1085.   register int value;
  1086.   int wide_flag = 0;
  1087.  
  1088.   if (nextchar >= 0)
  1089.     c = nextchar, nextchar = -1;
  1090.   else
  1091.     c = getc (finput);
  1092.  
  1093.   /* Effectively do c = skip_white_space (c)
  1094.      but do it faster in the usual cases.  */
  1095.   while (1)
  1096.     switch (c)
  1097.       {
  1098.       case ' ':
  1099.       case '\t':
  1100.       case '\f':
  1101.       case '\v':
  1102.       case '\b':
  1103.     c = getc (finput);
  1104.     break;
  1105.  
  1106.       case '\r':
  1107.     /* Call skip_white_space so we can warn if appropriate.  */
  1108.  
  1109.       case '\n':
  1110.       case '/':
  1111.       case '\\':
  1112.     c = skip_white_space (c);
  1113.       default:
  1114.     goto found_nonwhite;
  1115.       }
  1116.  found_nonwhite:
  1117.  
  1118.   token_buffer[0] = c;
  1119.   token_buffer[1] = 0;
  1120.  
  1121. /*  yylloc.first_line = lineno; */
  1122.  
  1123.   switch (c)
  1124.     {
  1125.     case EOF:
  1126.       end_of_file = 1;
  1127.       token_buffer[0] = 0;
  1128.       value = ENDFILE;
  1129.       break;
  1130.  
  1131.     case '$':
  1132.       if (dollars_in_ident)
  1133.     goto letter;
  1134.       return '$';
  1135.  
  1136.     case 'L':
  1137.       /* Capital L may start a wide-string or wide-character constant.  */
  1138.       {
  1139.     register int c = getc (finput);
  1140.     if (c == '\'')
  1141.       {
  1142.         wide_flag = 1;
  1143.         goto char_constant;
  1144.       }
  1145.     if (c == '"')
  1146.       {
  1147.         wide_flag = 1;
  1148.         goto string_constant;
  1149.       }
  1150.     ungetc (c, finput);
  1151.       }
  1152.       goto letter;
  1153.  
  1154.     case '@':
  1155.       if (!doing_objc_thang)
  1156.     {
  1157.       value = c;
  1158.       break;
  1159.     }
  1160.       p = token_buffer;
  1161.       *p++ = '@';
  1162.       c = getc (finput);
  1163.       while (isalnum (c) || c == '_')
  1164.     {
  1165.       if (p >= token_buffer + maxtoken)
  1166.         p = extend_token_buffer (p);
  1167.  
  1168.       *p++ = c;
  1169.       c = getc (finput);
  1170.     }
  1171.  
  1172.       *p = 0;
  1173.       nextchar = c;
  1174.       value = recognize_objc_keyword (token_buffer + 1);
  1175.       if (value != 0)
  1176.     break;
  1177.       error ("invalid Objective C keyword `%s'", token_buffer);
  1178.       /* Cause a syntax error--1 is not a valid token type.  */
  1179.       value = 1;
  1180.       break;
  1181.  
  1182.     case 'A':  case 'B':  case 'C':  case 'D':  case 'E':
  1183.     case 'F':  case 'G':  case 'H':  case 'I':  case 'J':
  1184.     case 'K':          case 'M':  case 'N':  case 'O':
  1185.     case 'P':  case 'Q':  case 'R':  case 'S':  case 'T':
  1186.     case 'U':  case 'V':  case 'W':  case 'X':  case 'Y':
  1187.     case 'Z':
  1188.     case 'a':  case 'b':  case 'c':  case 'd':  case 'e':
  1189.     case 'f':  case 'g':  case 'h':  case 'i':  case 'j':
  1190.     case 'k':  case 'l':  case 'm':  case 'n':  case 'o':
  1191.     case 'p':  case 'q':  case 'r':  case 's':  case 't':
  1192.     case 'u':  case 'v':  case 'w':  case 'x':  case 'y':
  1193.     case 'z':
  1194.     case '_':
  1195.     letter:
  1196.       p = token_buffer;
  1197.       while (isalnum (c) || c == '_' || c == '$' || c == '@')
  1198.     {
  1199.       if (p >= token_buffer + maxtoken)
  1200.         p = extend_token_buffer (p);
  1201.       if (c == '$' && ! dollars_in_ident)
  1202.         break;
  1203.  
  1204.       *p++ = c;
  1205.       c = getc (finput);
  1206.     }
  1207.  
  1208.       *p = 0;
  1209.       nextchar = c;
  1210.  
  1211.       value = IDENTIFIER;
  1212.       yylval.itype = 0;
  1213.  
  1214.       /* Try to recognize a keyword.  Uses minimum-perfect hash function */
  1215.  
  1216.       {
  1217.     register struct resword *ptr;
  1218.  
  1219.     if (ptr = is_reserved_word (token_buffer, p - token_buffer))
  1220.       {
  1221.         if (ptr->rid)
  1222.           yylval.ttype = ridpointers[(int) ptr->rid];
  1223.         value = (int) ptr->token;
  1224.  
  1225.         /* Even if we decided to recognize asm, still perhaps warn.  */
  1226.         if (pedantic
  1227.         && (value == ASM_KEYWORD || value == TYPEOF
  1228.             || ptr->rid == RID_INLINE)
  1229.         && token_buffer[0] != '_')
  1230.           pedwarn ("ANSI does not permit the keyword `%s'",
  1231.                token_buffer);
  1232.       }
  1233.       }
  1234.  
  1235.       /* If we did not find a keyword, look for an identifier
  1236.      (or a typename).  */
  1237.  
  1238.       if (value == IDENTIFIER)
  1239.     {
  1240.           yylval.ttype = get_identifier (token_buffer);
  1241.       lastiddecl = lookup_name (yylval.ttype);
  1242.  
  1243.       if (lastiddecl != 0 && TREE_CODE (lastiddecl) == TYPE_DECL)
  1244.         value = TYPENAME;
  1245.       /* A user-invisible read-only initialized variable
  1246.          should be replaced by its value.
  1247.          We handle only strings since that's the only case used in C.  */
  1248.       else if (lastiddecl != 0 && TREE_CODE (lastiddecl) == VAR_DECL
  1249.            && DECL_IGNORED_P (lastiddecl)
  1250.            && TREE_READONLY (lastiddecl)
  1251.            && DECL_INITIAL (lastiddecl) != 0
  1252.            && TREE_CODE (DECL_INITIAL (lastiddecl)) == STRING_CST)
  1253.         {
  1254.           yylval.ttype = DECL_INITIAL (lastiddecl);
  1255.           value = STRING;
  1256.         }
  1257.           else if (doing_objc_thang)
  1258.             {
  1259.           tree objc_interface_decl = lookup_interface (yylval.ttype);
  1260.  
  1261.           if (objc_interface_decl)
  1262.         {
  1263.           value = CLASSNAME;
  1264.           yylval.ttype = objc_interface_decl;
  1265.         }
  1266.         }
  1267.     }
  1268.  
  1269.       break;
  1270.  
  1271.     case '0':  case '1':  case '2':  case '3':  case '4':
  1272.     case '5':  case '6':  case '7':  case '8':  case '9':
  1273.     case '.':
  1274.       {
  1275.     int base = 10;
  1276.     int count = 0;
  1277.     int largest_digit = 0;
  1278.     int numdigits = 0;
  1279.     /* for multi-precision arithmetic,
  1280.        we actually store only HOST_BITS_PER_CHAR bits in each part.
  1281.        The number of parts is chosen so as to be sufficient to hold
  1282.        the enough bits to fit into the two HOST_WIDE_INTs that contain
  1283.        the integer value (this is always at least as many bits as are
  1284.        in a target `long long' value, but may be wider).  */
  1285. #define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2 + 2)
  1286.     int parts[TOTAL_PARTS];
  1287.     int overflow = 0;
  1288.  
  1289.     enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag
  1290.       = NOT_FLOAT;
  1291.  
  1292.     for (count = 0; count < TOTAL_PARTS; count++)
  1293.       parts[count] = 0;
  1294.  
  1295.     p = token_buffer;
  1296.     *p++ = c;
  1297.  
  1298.     if (c == '0')
  1299.       {
  1300.         *p++ = (c = getc (finput));
  1301.         if ((c == 'x') || (c == 'X'))
  1302.           {
  1303.         base = 16;
  1304.         *p++ = (c = getc (finput));
  1305.           }
  1306.         /* Leading 0 forces octal unless the 0 is the only digit.  */
  1307.         else if (c >= '0' && c <= '9')
  1308.           {
  1309.         base = 8;
  1310.         numdigits++;
  1311.           }
  1312.         else
  1313.           numdigits++;
  1314.       }
  1315.  
  1316.     /* Read all the digits-and-decimal-points.  */
  1317.  
  1318.     while (c == '.'
  1319.            || (isalnum (c) && (c != 'l') && (c != 'L')
  1320.            && (c != 'u') && (c != 'U')
  1321.            && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
  1322.       {
  1323.         if (c == '.')
  1324.           {
  1325.         if (base == 16)
  1326.           error ("floating constant may not be in radix 16");
  1327.         if (floatflag == AFTER_POINT)
  1328.           {
  1329.             error ("malformed floating constant");
  1330.             floatflag = TOO_MANY_POINTS;
  1331.           }
  1332.         else
  1333.           floatflag = AFTER_POINT;
  1334.  
  1335.         base = 10;
  1336.         *p++ = c = getc (finput);
  1337.         /* Accept '.' as the start of a floating-point number
  1338.            only when it is followed by a digit.
  1339.            Otherwise, unread the following non-digit
  1340.            and use the '.' as a structural token.  */
  1341.         if (p == token_buffer + 2 && !isdigit (c))
  1342.           {
  1343.             if (c == '.')
  1344.               {
  1345.             c = getc (finput);
  1346.             if (c == '.')
  1347.               {
  1348.                 *p++ = c;
  1349.                 *p = 0;
  1350.                 return ELLIPSIS;
  1351.               }
  1352.             error ("parse error at `..'");
  1353.               }
  1354.             ungetc (c, finput);
  1355.             token_buffer[1] = 0;
  1356.             value = '.';
  1357.             goto done;
  1358.           }
  1359.           }
  1360.         else
  1361.           {
  1362.         /* It is not a decimal point.
  1363.            It should be a digit (perhaps a hex digit).  */
  1364.  
  1365.         if (isdigit (c))
  1366.           {
  1367.             c = c - '0';
  1368.           }
  1369.         else if (base <= 10)
  1370.           {
  1371.             if ((c&~040) == 'E')
  1372.               {
  1373.             base = 10;
  1374.             floatflag = AFTER_POINT;
  1375.             break;   /* start of exponent */
  1376.               }
  1377.             error ("nondigits in number and not hexadecimal");
  1378.             c = 0;
  1379.           }
  1380.         else if (c >= 'a')
  1381.           {
  1382.             c = c - 'a' + 10;
  1383.           }
  1384.         else
  1385.           {
  1386.             c = c - 'A' + 10;
  1387.           }
  1388.         if (c >= largest_digit)
  1389.           largest_digit = c;
  1390.         numdigits++;
  1391.  
  1392.         for (count = 0; count < TOTAL_PARTS; count++)
  1393.           {
  1394.             parts[count] *= base;
  1395.             if (count)
  1396.               {
  1397.             parts[count]
  1398.               += (parts[count-1] >> HOST_BITS_PER_CHAR);
  1399.             parts[count-1]
  1400.               &= (1 << HOST_BITS_PER_CHAR) - 1;
  1401.               }
  1402.             else
  1403.               parts[0] += c;
  1404.           }
  1405.  
  1406.         /* If the extra highest-order part ever gets anything in it,
  1407.            the number is certainly too big.  */
  1408.         if (parts[TOTAL_PARTS - 1] != 0)
  1409.           overflow = 1;
  1410.  
  1411.         if (p >= token_buffer + maxtoken - 3)
  1412.           p = extend_token_buffer (p);
  1413.         *p++ = (c = getc (finput));
  1414.           }
  1415.       }
  1416.  
  1417.     if (numdigits == 0)
  1418.       error ("numeric constant with no digits");
  1419.  
  1420.     if (largest_digit >= base)
  1421.       error ("numeric constant contains digits beyond the radix");
  1422.  
  1423.     /* Remove terminating char from the token buffer and delimit the string */
  1424.     *--p = 0;
  1425.  
  1426.     if (floatflag != NOT_FLOAT)
  1427.       {
  1428.         tree type = double_type_node;
  1429.         int garbage_chars = 0, exceeds_double = 0;
  1430.         REAL_VALUE_TYPE value;
  1431.         jmp_buf handler;
  1432.  
  1433.         /* Read explicit exponent if any, and put it in tokenbuf.  */
  1434.  
  1435.         if ((c == 'e') || (c == 'E'))
  1436.           {
  1437.         if (p >= token_buffer + maxtoken - 3)
  1438.           p = extend_token_buffer (p);
  1439.         *p++ = c;
  1440.         c = getc (finput);
  1441.         if ((c == '+') || (c == '-'))
  1442.           {
  1443.             *p++ = c;
  1444.             c = getc (finput);
  1445.           }
  1446.         if (! isdigit (c))
  1447.           error ("floating constant exponent has no digits");
  1448.             while (isdigit (c))
  1449.           {
  1450.             if (p >= token_buffer + maxtoken - 3)
  1451.               p = extend_token_buffer (p);
  1452.             *p++ = c;
  1453.             c = getc (finput);
  1454.           }
  1455.           }
  1456.  
  1457.         *p = 0;
  1458.         errno = 0;
  1459.  
  1460.         /* Convert string to a double, checking for overflow.  */
  1461.         if (setjmp (handler))
  1462.           {
  1463.         error ("floating constant out of range");
  1464.         value = dconst0;
  1465.           }
  1466.         else
  1467.           {
  1468.         set_float_handler (handler);
  1469.         value = REAL_VALUE_ATOF (token_buffer);
  1470.         set_float_handler (NULL_PTR);
  1471.           }
  1472. #ifdef ERANGE
  1473.         if (errno == ERANGE && !flag_traditional && pedantic)
  1474.           {
  1475.           /* ERANGE is also reported for underflow,
  1476.              so test the value to distinguish overflow from that.  */
  1477.         if (REAL_VALUES_LESS (dconst1, value)
  1478.             || REAL_VALUES_LESS (value, dconstm1))
  1479.           {
  1480.             pedwarn ("floating point number exceeds range of `double'");
  1481.             exceeds_double = 1;
  1482.           }
  1483.           }
  1484. #endif
  1485.  
  1486.         /* Read the suffixes to choose a data type.  */
  1487.         switch (c)
  1488.           {
  1489.           case 'f': case 'F':
  1490.         type = float_type_node;
  1491.         value = REAL_VALUE_TRUNCATE (TYPE_MODE (type), value);
  1492.         if (REAL_VALUE_ISINF (value) && ! exceeds_double && pedantic)
  1493.           pedwarn ("floating point number exceeds range of `float'");
  1494.         garbage_chars = -1;
  1495.         break;
  1496.  
  1497.           case 'l': case 'L':
  1498.         type = long_double_type_node;
  1499.         garbage_chars = -1;
  1500.         break;
  1501.           }
  1502.         /* Note: garbage_chars is -1 if first char is *not* garbage.  */
  1503.         while (isalnum (c))
  1504.           {
  1505.         if (p >= token_buffer + maxtoken - 3)
  1506.           p = extend_token_buffer (p);
  1507.         *p++ = c;
  1508.         c = getc (finput);
  1509.         garbage_chars++;
  1510.           }
  1511.         if (garbage_chars > 0)
  1512.           error ("garbage at end of number");
  1513.  
  1514.         /* Create a node with determined type and value.  */
  1515.         yylval.ttype = build_real (type, value);
  1516.  
  1517.         ungetc (c, finput);
  1518.         *p = 0;
  1519.       }
  1520.     else
  1521.       {
  1522.         tree traditional_type, ansi_type, type;
  1523.         HOST_WIDE_INT high, low;
  1524.         int spec_unsigned = 0;
  1525.         int spec_long = 0;
  1526.         int spec_long_long = 0;
  1527.         int bytes, warn, i;
  1528.  
  1529.         while (1)
  1530.           {
  1531.         if (c == 'u' || c == 'U')
  1532.           {
  1533.             if (spec_unsigned)
  1534.               error ("two `u's in integer constant");
  1535.             spec_unsigned = 1;
  1536.           }
  1537.         else if (c == 'l' || c == 'L')
  1538.           {
  1539.             if (spec_long)
  1540.               {
  1541.             if (spec_long_long)
  1542.               error ("three `l's in integer constant");
  1543.             else if (pedantic)
  1544.               pedwarn ("ANSI C forbids long long integer constants");
  1545.             spec_long_long = 1;
  1546.               }
  1547.             spec_long = 1;
  1548.           }
  1549.         else
  1550.           {
  1551.             if (isalnum (c))
  1552.               {
  1553.             error ("garbage at end of number");
  1554.             while (isalnum (c))
  1555.               {
  1556.                 if (p >= token_buffer + maxtoken - 3)
  1557.                   p = extend_token_buffer (p);
  1558.                 *p++ = c;
  1559.                 c = getc (finput);
  1560.               }
  1561.               }
  1562.             break;
  1563.           }
  1564.         if (p >= token_buffer + maxtoken - 3)
  1565.           p = extend_token_buffer (p);
  1566.         *p++ = c;
  1567.         c = getc (finput);
  1568.           }
  1569.  
  1570.         ungetc (c, finput);
  1571.  
  1572.         /* If the constant is not long long and it won't fit in an
  1573.            unsigned long, or if the constant is long long and won't fit
  1574.            in an unsigned long long, then warn that the constant is out
  1575.            of range.  */
  1576.  
  1577.         /* ??? This assumes that long long and long integer types are
  1578.            a multiple of 8 bits.  This better than the original code
  1579.            though which assumed that long was exactly 32 bits and long
  1580.            long was exactly 64 bits.  */
  1581.  
  1582.         if (spec_long_long)
  1583.           bytes = TYPE_PRECISION (long_long_integer_type_node) / 8;
  1584.         else
  1585.           bytes = TYPE_PRECISION (long_integer_type_node) / 8;
  1586.  
  1587.         warn = overflow;
  1588.         for (i = bytes; i < TOTAL_PARTS; i++)
  1589.           if (parts[i])
  1590.         warn = 1;
  1591.         if (warn)
  1592.           pedwarn ("integer constant out of range");
  1593.  
  1594.         /* This is simplified by the fact that our constant
  1595.            is always positive.  */
  1596.  
  1597.         high = low = 0;
  1598.  
  1599.         for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR; i++)
  1600.           {
  1601.         high |= ((HOST_WIDE_INT) parts[i + (HOST_BITS_PER_WIDE_INT
  1602.                             / HOST_BITS_PER_CHAR)]
  1603.              << (i * HOST_BITS_PER_CHAR));
  1604.         low |= (HOST_WIDE_INT) parts[i] << (i * HOST_BITS_PER_CHAR);
  1605.           }
  1606.         
  1607.         yylval.ttype = build_int_2 (low, high);
  1608.         TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node;
  1609.  
  1610.         /* If warn_traditional, calculate both the ANSI type and the
  1611.            traditional type, then see if they disagree.
  1612.            Otherwise, calculate only the type for the dialect in use.  */
  1613.         if (warn_traditional || flag_traditional)
  1614.           {
  1615.         /* Calculate the traditional type.  */
  1616.         /* Traditionally, any constant is signed;
  1617.            but if unsigned is specified explicitly, obey that.
  1618.            Use the smallest size with the right number of bits,
  1619.            except for one special case with decimal constants.  */
  1620.         if (! spec_long && base != 10
  1621.             && int_fits_type_p (yylval.ttype, unsigned_type_node))
  1622.           traditional_type = (spec_unsigned ? unsigned_type_node
  1623.                       : integer_type_node);
  1624.         /* A decimal constant must be long
  1625.            if it does not fit in type int.
  1626.            I think this is independent of whether
  1627.            the constant is signed.  */
  1628.         else if (! spec_long && base == 10
  1629.              && int_fits_type_p (yylval.ttype, integer_type_node))
  1630.           traditional_type = (spec_unsigned ? unsigned_type_node
  1631.                       : integer_type_node);
  1632.         else if (! spec_long_long)
  1633.           traditional_type = (spec_unsigned ? long_unsigned_type_node
  1634.                       : long_integer_type_node);
  1635.         else
  1636.           traditional_type = (spec_unsigned
  1637.                       ? long_long_unsigned_type_node
  1638.                       : long_long_integer_type_node);
  1639.           }
  1640.         if (warn_traditional || ! flag_traditional)
  1641.           {
  1642.         /* Calculate the ANSI type.  */
  1643.         if (! spec_long && ! spec_unsigned
  1644.             && int_fits_type_p (yylval.ttype, integer_type_node))
  1645.           ansi_type = integer_type_node;
  1646.         else if (! spec_long && (base != 10 || spec_unsigned)
  1647.              && int_fits_type_p (yylval.ttype, unsigned_type_node))
  1648.           ansi_type = unsigned_type_node;
  1649.         else if (! spec_unsigned && !spec_long_long
  1650.              && int_fits_type_p (yylval.ttype, long_integer_type_node))
  1651.           ansi_type = long_integer_type_node;
  1652.         else if (! spec_long_long)
  1653.           ansi_type = long_unsigned_type_node;
  1654.         else if (! spec_unsigned
  1655.              /* Verify value does not overflow into sign bit.  */
  1656.              && TREE_INT_CST_HIGH (yylval.ttype) >= 0
  1657.              && int_fits_type_p (yylval.ttype,
  1658.                          long_long_integer_type_node))
  1659.           ansi_type = long_long_integer_type_node;
  1660.         else
  1661.           ansi_type = long_long_unsigned_type_node;
  1662.           }
  1663.  
  1664.         type = flag_traditional ? traditional_type : ansi_type;
  1665.  
  1666.         if (warn_traditional && traditional_type != ansi_type)
  1667.           {
  1668.         if (TYPE_PRECISION (traditional_type)
  1669.             != TYPE_PRECISION (ansi_type))
  1670.           warning ("width of integer constant changes with -traditional");
  1671.         else if (TREE_UNSIGNED (traditional_type)
  1672.              != TREE_UNSIGNED (ansi_type))
  1673.           warning ("integer constant is unsigned in ANSI C, signed with -traditional");
  1674.         else
  1675.           warning ("width of integer constant may change on other systems with -traditional");
  1676.           }
  1677.  
  1678.         if (!flag_traditional && !int_fits_type_p (yylval.ttype, type)
  1679.         && !warn)
  1680.           pedwarn ("integer constant out of range");
  1681.  
  1682.         if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type))
  1683.           warning ("integer constant is so large that it is unsigned");
  1684.  
  1685.         if (flag_traditional && !int_fits_type_p (yylval.ttype, type))
  1686.           /* The traditional constant 0x80000000 is signed
  1687.          but doesn't fit in the range of int.
  1688.          This will change it to -0x80000000, which does fit.  */
  1689.           {
  1690.         TREE_TYPE (yylval.ttype) = unsigned_type (type);
  1691.         yylval.ttype = convert (type, yylval.ttype);
  1692.           }
  1693.         else
  1694.           TREE_TYPE (yylval.ttype) = type;
  1695.  
  1696.         *p = 0;
  1697.       }
  1698.  
  1699.     value = CONSTANT; break;
  1700.       }
  1701.  
  1702.     case '\'':
  1703.     char_constant:
  1704.       {
  1705.     register int result = 0;
  1706.     register int num_chars = 0;
  1707.     unsigned width = TYPE_PRECISION (char_type_node);
  1708.     int max_chars;
  1709.  
  1710.     if (wide_flag)
  1711.       {
  1712.         width = WCHAR_TYPE_SIZE;
  1713. #ifdef MULTIBYTE_CHARS
  1714.         max_chars = MB_CUR_MAX;
  1715. #else
  1716.         max_chars = 1;
  1717. #endif
  1718.       }
  1719.     else
  1720.       max_chars = TYPE_PRECISION (integer_type_node) / width;
  1721.  
  1722.     while (1)
  1723.       {
  1724.       tryagain:
  1725.  
  1726.         c = getc (finput);
  1727.  
  1728.         if (c == '\'' || c == EOF)
  1729.           break;
  1730.  
  1731.         if (c == '\\')
  1732.           {
  1733.         int ignore = 0;
  1734.         c = readescape (&ignore);
  1735.         if (ignore)
  1736.           goto tryagain;
  1737.         if (width < HOST_BITS_PER_INT
  1738.             && (unsigned) c >= (1 << width))
  1739.           pedwarn ("escape sequence out of range for character");
  1740.           }
  1741.         else if (c == '\n')
  1742.           {
  1743.         if (pedantic)
  1744.           pedwarn ("ANSI C forbids newline in character constant");
  1745.         lineno++;
  1746.           }
  1747.  
  1748.         num_chars++;
  1749.         if (num_chars > maxtoken - 4)
  1750.           extend_token_buffer (token_buffer);
  1751.  
  1752.         token_buffer[num_chars] = c;
  1753.  
  1754.         /* Merge character into result; ignore excess chars.  */
  1755.         if (num_chars < max_chars + 1)
  1756.           {
  1757.         if (width < HOST_BITS_PER_INT)
  1758.           result = (result << width) | (c & ((1 << width) - 1));
  1759.         else
  1760.           result = c;
  1761.           }
  1762.       }
  1763.  
  1764.     token_buffer[num_chars + 1] = '\'';
  1765.     token_buffer[num_chars + 2] = 0;
  1766.  
  1767.     if (c != '\'')
  1768.       error ("malformatted character constant");
  1769.     else if (num_chars == 0)
  1770.       error ("empty character constant");
  1771.     else if (num_chars > max_chars)
  1772.       {
  1773.         num_chars = max_chars;
  1774.         error ("character constant too long");
  1775.       }
  1776.     /* Apple C doesn't mind multi-character constants, in fact things
  1777.        like resource IDs are preferred that way, so don't warn here. */
  1778.     else if (num_chars != 1 && ! flag_traditional && ! flag_apple)
  1779.       warning ("multi-character character constant");
  1780.  
  1781.     /* If char type is signed, sign-extend the constant.  */
  1782.     if (! wide_flag)
  1783.       {
  1784.         int num_bits = num_chars * width;
  1785.         if (TREE_UNSIGNED (char_type_node)
  1786.         || ((result >> (num_bits - 1)) & 1) == 0)
  1787.           yylval.ttype
  1788.         = build_int_2 (result & ((unsigned HOST_WIDE_INT) ~0
  1789.                      >> (HOST_BITS_PER_WIDE_INT - num_bits)),
  1790.                    0);
  1791.         else
  1792.           yylval.ttype
  1793.         = build_int_2 (result | ~((unsigned HOST_WIDE_INT) ~0
  1794.                       >> (HOST_BITS_PER_WIDE_INT - num_bits)),
  1795.                    -1);
  1796.       }
  1797.     else
  1798.       {
  1799. #ifdef MULTIBYTE_CHARS
  1800.         /* Set the initial shift state and convert the next sequence.  */
  1801.         result = 0;
  1802.         /* In all locales L'\0' is zero and mbtowc will return zero,
  1803.            so don't use it.  */
  1804.         if (num_chars > 1
  1805.         || (num_chars == 1 && token_buffer[1] != '\0'))
  1806.           {
  1807.         wchar_t wc;
  1808.         (void) mbtowc (NULL_PTR, NULL_PTR, 0);
  1809.         if (mbtowc (& wc, token_buffer + 1, num_chars) == num_chars)
  1810.           result = wc;
  1811.         else
  1812.           warning ("Ignoring invalid multibyte character");
  1813.           }
  1814. #endif
  1815.         yylval.ttype = build_int_2 (result, 0);
  1816.       }
  1817.  
  1818.     TREE_TYPE (yylval.ttype) = integer_type_node;
  1819.     value = CONSTANT;
  1820.     break;
  1821.       }
  1822.  
  1823.     case '"':
  1824.     string_constant:
  1825.       {
  1826.     /* Flag to detect strings beginning with backslash-p. */
  1827.     int pascalstring = FALSE;
  1828.     c = getc (finput);
  1829.     p = token_buffer + 1;
  1830.  
  1831.     while (c != '"' && c >= 0)
  1832.       {
  1833.         /* ignore_escape_flag is set for reading the filename in #line.  */
  1834.         if (!ignore_escape_flag && c == '\\')
  1835.           {
  1836.         int ignore = 0;
  1837.         c = readescape (&ignore);
  1838.         /* readescape returns a -2 to indicate it saw backslash-p.
  1839.            Change the apparent returned char to NUL so that later
  1840.            code won't be puzzled by a negative char. */
  1841.         if (flag_apple && c == -2)
  1842.           {
  1843.             pascalstring = TRUE;
  1844.             c = '\0';
  1845.           }
  1846.         if (ignore)
  1847.           goto skipnewline;
  1848.         if (!wide_flag
  1849.             && TYPE_PRECISION (char_type_node) < HOST_BITS_PER_INT
  1850.             && c >= (1 << TYPE_PRECISION (char_type_node)))
  1851.           pedwarn ("escape sequence out of range for character");
  1852.           }
  1853.         else if (c == '\n')
  1854.           {
  1855.         if (pedantic)
  1856.           pedwarn ("ANSI C forbids newline in string constant");
  1857.         lineno++;
  1858.           }
  1859.  
  1860.         if (p == token_buffer + maxtoken)
  1861.           p = extend_token_buffer (p);
  1862.         *p++ = c;
  1863.  
  1864.       skipnewline:
  1865.         c = getc (finput);
  1866.       }
  1867.     *p = 0;
  1868.     /* If we saw a backslash-p, jam the length in, subtracting 2 first
  1869.        (don't count length char, don't count 0 at end).  I have no idea
  1870.        what should happen if this string has wide chars in it. */
  1871.     if (flag_apple && pascalstring)
  1872.       {
  1873.         token_buffer[1] = p - token_buffer - 2;
  1874.         if (wide_flag)
  1875.           warning("long string constants here; backslash-p probably garbled.");
  1876.       }
  1877.  
  1878.     /* We have read the entire constant.
  1879.        Construct a STRING_CST for the result.  */
  1880.  
  1881.     if (wide_flag)
  1882.       {
  1883.         /* If this is a L"..." wide-string, convert the multibyte string
  1884.            to a wide character string.  */
  1885.         char *widep = (char *) alloca ((p - token_buffer) * WCHAR_BYTES);
  1886.         int len;
  1887.  
  1888. #ifdef MULTIBYTE_CHARS
  1889.         len = mbstowcs ((wchar_t *) widep, token_buffer + 1, p - token_buffer);
  1890.         if ((unsigned) len >= (p - token_buffer))
  1891.           {
  1892.         warning ("Ignoring invalid multibyte string");
  1893.         len = 0;
  1894.           }
  1895.         bzero (widep + (len * WCHAR_BYTES), WCHAR_BYTES);
  1896. #else
  1897.         {
  1898.           union { long l; char c[sizeof (long)]; } u;
  1899.           int big_endian;
  1900.           char *wp, *cp;
  1901.  
  1902.           /* Determine whether host is little or big endian.  */
  1903.           u.l = 1;
  1904.           big_endian = u.c[sizeof (long) - 1];
  1905.           wp = widep + (big_endian ? WCHAR_BYTES - 1 : 0);
  1906.  
  1907.           bzero (widep, (p - token_buffer) * WCHAR_BYTES);
  1908.           for (cp = token_buffer + 1; cp < p; cp++)
  1909.         *wp = *cp, wp += WCHAR_BYTES;
  1910.           len = p - token_buffer - 1;
  1911.         }
  1912. #endif
  1913.         yylval.ttype = build_string ((len + 1) * WCHAR_BYTES, widep);
  1914.         TREE_TYPE (yylval.ttype) = wchar_array_type_node;
  1915.       }
  1916.     else
  1917.       {
  1918.         yylval.ttype = build_string (p - token_buffer, token_buffer + 1);
  1919.         TREE_TYPE (yylval.ttype) = char_array_type_node;
  1920.       }
  1921.  
  1922.     *p++ = '"';
  1923.     *p = 0;
  1924.  
  1925.     value = STRING; break;
  1926.       }
  1927.  
  1928.     case '+':
  1929.     case '-':
  1930.     case '&':
  1931.     case '|':
  1932.     case '<':
  1933.     case '>':
  1934.     case '*':
  1935.     case '/':
  1936.     case '%':
  1937.     case '^':
  1938.     case '!':
  1939.     case '=':
  1940.       {
  1941.     register int c1;
  1942.  
  1943.       combine:
  1944.  
  1945.     switch (c)
  1946.       {
  1947.       case '+':
  1948.         yylval.code = PLUS_EXPR; break;
  1949.       case '-':
  1950.         yylval.code = MINUS_EXPR; break;
  1951.       case '&':
  1952.         yylval.code = BIT_AND_EXPR; break;
  1953.       case '|':
  1954.         yylval.code = BIT_IOR_EXPR; break;
  1955.       case '*':
  1956.         yylval.code = MULT_EXPR; break;
  1957.       case '/':
  1958.         yylval.code = TRUNC_DIV_EXPR; break;
  1959.       case '%':
  1960.         yylval.code = TRUNC_MOD_EXPR; break;
  1961.       case '^':
  1962.         yylval.code = BIT_XOR_EXPR; break;
  1963.       case LSHIFT:
  1964.         yylval.code = LSHIFT_EXPR; break;
  1965.       case RSHIFT:
  1966.         yylval.code = RSHIFT_EXPR; break;
  1967.       case '<':
  1968.         yylval.code = LT_EXPR; break;
  1969.       case '>':
  1970.         yylval.code = GT_EXPR; break;
  1971.       }
  1972.  
  1973.     token_buffer[1] = c1 = getc (finput);
  1974.     token_buffer[2] = 0;
  1975.  
  1976.     if (c1 == '=')
  1977.       {
  1978.         switch (c)
  1979.           {
  1980.           case '<':
  1981.         value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
  1982.           case '>':
  1983.         value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
  1984.           case '!':
  1985.         value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
  1986.           case '=':
  1987.         value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
  1988.           }
  1989.         value = ASSIGN; goto done;
  1990.       }
  1991.     else if (c == c1)
  1992.       switch (c)
  1993.         {
  1994.         case '+':
  1995.           value = PLUSPLUS; goto done;
  1996.         case '-':
  1997.           value = MINUSMINUS; goto done;
  1998.         case '&':
  1999.           value = ANDAND; goto done;
  2000.         case '|':
  2001.           value = OROR; goto done;
  2002.         case '<':
  2003.           c = LSHIFT;
  2004.           goto combine;
  2005.         case '>':
  2006.           c = RSHIFT;
  2007.           goto combine;
  2008.         }
  2009.     else if ((c == '-') && (c1 == '>'))
  2010.       { value = POINTSAT; goto done; }
  2011.     ungetc (c1, finput);
  2012.     token_buffer[1] = 0;
  2013.  
  2014.     if ((c == '<') || (c == '>'))
  2015.       value = ARITHCOMPARE;
  2016.     else value = c;
  2017.     goto done;
  2018.       }
  2019.  
  2020.     case 0:
  2021.       /* Don't make yyparse think this is eof.  */
  2022.       value = 1;
  2023.       break;
  2024.  
  2025.     default:
  2026.       value = c;
  2027.     }
  2028.  
  2029. done:
  2030. /*  yylloc.last_line = lineno; */
  2031.  
  2032.   return value;
  2033. }
  2034.  
  2035. /* Sets the value of the 'yydebug' variable to VALUE.
  2036.    This is a function so we don't have to have YYDEBUG defined
  2037.    in order to build the compiler.  */
  2038.  
  2039. void
  2040. set_yydebug (value)
  2041.      int value;
  2042. {
  2043. #if YYDEBUG != 0
  2044.   yydebug = value;
  2045. #else
  2046.   warning ("YYDEBUG not defined.");
  2047. #endif
  2048. }
  2049.