spew.c (frob_id): New static function.
authorNathan Sidwell <nathan@codesourcery.com>
Thu, 5 Oct 2000 08:28:51 +0000 (08:28 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Thu, 5 Oct 2000 08:28:51 +0000 (08:28 +0000)
* spew.c (frob_id): New static function.
(frob_opname): Use it.
(yylex): Use it.

From-SVN: r36719

gcc/cp/ChangeLog
gcc/cp/spew.c

index 2adea2e6094cd699f5b8ba8bc28312ae86d88cb2..508cd1eaf1efb3715b991241c7d8050e00c1638b 100644 (file)
@@ -1,3 +1,9 @@
+2000-10-05  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * spew.c (frob_id): New static function.
+       (frob_opname): Use it.
+       (yylex): Use it.
+
 2000-10-01  Mark Mitchell  <mark@codesourcery.com>
 
        * decl.c (lang_mark_false_label_stack): Remove.
index d6bf7bb45864e970532819c246c6aaa1e701ce1f..56a3deed86bde6d4e25a10b856cfb16e7d2e92dd 100644 (file)
@@ -120,6 +120,7 @@ static SPEW_INLINE void feed_input PARAMS ((struct unparsed_text *));
 static SPEW_INLINE void end_input PARAMS ((void));
 static SPEW_INLINE void snarf_block PARAMS ((const char *, int));
 static tree snarf_defarg PARAMS ((void));
+static int frob_id PARAMS ((int, int, tree *));
 
 /* The list of inline functions being held off until we reach the end of
    the current class declaration.  */
@@ -776,48 +777,14 @@ yylex ()
       break;
 
     case IDENTIFIER:
+    {
+      int peek;
+      
       scan_tokens (1);
-      if (nth_token (1)->yychar == SCOPE)
-       {
-         /* Don't interfere with the setting from an 'aggr' prefix.  */
-         old_looking_for_typename = looking_for_typename;
-         looking_for_typename = 1;
-       }
-      else if (nth_token (1)->yychar == '<')
-       looking_for_template = 1;
-
-      trrr = lookup_name (nth_token (0)->yylval.ttype, -2);
-
-      if (trrr)
-       {
-         yychr = identifier_type (trrr);
-         switch (yychr)
-           {
-           case TYPENAME:
-           case SELFNAME:
-           case NSNAME:
-           case PTYPENAME:
-             lastiddecl = trrr;
-
-             /* If this got special lookup, remember it.  In these
-                cases, we know it can't be a declarator-id. */
-             if (got_scope || got_object)
-               nth_token (0)->yylval.ttype = trrr;
-             break;
-
-           case PFUNCNAME:
-           case IDENTIFIER:
-             lastiddecl = trrr;
-             break;
-
-           default:
-             my_friendly_abort (101);
-           }
-       }
-      else
-       lastiddecl = NULL_TREE;
-      got_scope = NULL_TREE;
-      /* and fall through to...  */
+      peek = nth_token (1)->yychar;
+      yychr = frob_id (yychr, peek, &nth_token (0)->yylval.ttype);
+      break;
+    }
     case IDENTIFIER_DEFN:
     case TYPENAME:
     case TYPENAME_DEFN:
@@ -938,27 +905,40 @@ yyungetc (ch, rescan)
     }
 }
 
-/* ID is an operator name. Duplicate the hackery in yylex to determine what
-   it really is.  */
+/* Lexer hackery to determine what *IDP really is.  */
 
-tree frob_opname (id)
-     tree id;
+static int
+frob_id (yyc, peek, idp)
+     int yyc;
+     int peek;
+     tree *idp;
 {
   tree trrr;
+  int old_looking_for_typename = 0;
   
-  if (yychar == '<')
+  if (peek == SCOPE)
+    {
+      /* Don't interfere with the setting from an 'aggr' prefix.  */
+      old_looking_for_typename = looking_for_typename;
+      looking_for_typename = 1;
+    }
+  else if (peek == '<')
     looking_for_template = 1;
-  trrr = lookup_name (id, -2);
+  trrr = lookup_name (*idp, -2);
   if (trrr)
     {
-      switch (identifier_type (trrr))
+      yyc = identifier_type (trrr);
+      switch(yyc)
         {
           case TYPENAME:
           case SELFNAME:
           case NSNAME:
           case PTYPENAME:
+           /* If this got special lookup, remember it.  In these
+              cases, we know it can't be a declarator-id. */
             if (got_scope || got_object)
-              id = trrr;
+              *idp = trrr;
+            /* FALLTHROUGH */
           case PFUNCNAME:
           case IDENTIFIER:
             lastiddecl = trrr;
@@ -970,8 +950,19 @@ tree frob_opname (id)
   else
     lastiddecl = NULL_TREE;
   got_scope = NULL_TREE;
-  got_object = NULL_TREE;
+  looking_for_typename = old_looking_for_typename;
   looking_for_template = 0;
+  return yyc;
+}
+
+/* ID is an operator name. Duplicate the hackery in yylex to determine what
+   it really is.  */
+
+tree frob_opname (id)
+     tree id;
+{
+  frob_id (0, yychar, &id);
+  got_object = NULL_TREE;
   return id;
 }