This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch 1/8] Remove Yacc support


There is no longer any front end that requires gengtype to process the
Yacc union.  In fact, the only front end that still has a yacc-based
parser is treelang, and it doesn't have any GTY-tagged types or roots
at all in its parser.

	* gengtype-lex.l: Remove all rules and states relating to yacc
        input files.
	* gengtype-yacc.y: Similarly.
	* gengtype.c (note_yacc_type): Delete function.
	* gengtype.h: Update prototypes.

Index: S-vn-gtsmall/gcc/gengtype-lex.l
===================================================================
--- S-vn-gtsmall.orig/gcc/gengtype-lex.l	2007-03-17 16:05:49.000000000 -0700
+++ S-vn-gtsmall/gcc/gengtype-lex.l	2007-03-17 16:08:30.000000000 -0700
@@ -57,7 +57,7 @@
 IWORD	short|long|(un)?signed|char|int|HOST_WIDE_INT|HOST_WIDEST_INT|bool|size_t|BOOL_BITFIELD
 ITYPE	{IWORD}({WS}{IWORD})*
 
-%x in_struct in_struct_comment in_comment in_yacc_escape
+%x in_struct in_struct_comment in_comment
 %option warn noyywrap nounput nodefault perf-report
 %option 8bit never-interactive
 %%
@@ -233,12 +233,6 @@
   return ENT_EXTERNSTATIC;
 }
 
-^"%union"{WS}"{"{WS}/"GTY" {
-  BEGIN(in_struct);
-  update_lineno (yytext, yyleng);
-  return ENT_YACCUNION;
-}
-
 ^"DEF_VEC_"[[:alnum:]_]*{WS}?"("{WS}?{ID}{WS}?(","{WS}?{ID}{WS}?)*")" {
   char *macro, *arg;
   unsigned macro_len, arg_len;
@@ -279,8 +273,6 @@
 
 "/*"				{ BEGIN(in_struct_comment); }
 
-^"%{"				{ BEGIN(in_yacc_escape); } /* } */
-
 {WS}				{ update_lineno (yytext, yyleng); }
 
 "const"/[^[:alnum:]_]		/* don't care */
@@ -342,10 +334,6 @@
   yylval.s = (const char *) xmemdup (yytext+1, yyleng-2, yyleng-1);
   return ARRAY;
 }
-^"%"{ID}			{
-  yylval.s = (const char *) xmemdup (yytext+1, yyleng-1, yyleng);
-  return PERCENT_ID;
-}
 "'"("\\".|[^\\])"'"		{
   yylval.s = (const char *) xmemdup (yytext+1, yyleng-2, yyleng);
   return CHAR;
@@ -362,11 +350,6 @@
   return yytext[0];
 }
 
-^"%%"				{
-  BEGIN(INITIAL);
-  return PERCENTPERCENT;
-}
-
 "#define"[^\n]*\n		{lexer_line.line++;}
 
 .				{
@@ -391,19 +374,6 @@
 <in_comment>"*/"	{ BEGIN(INITIAL); } 
 <in_struct_comment>"*/"	{ BEGIN(in_struct); }
 
-<in_yacc_escape>{
-\n		{ lexer_line.line++; }
-[^%]{16}	|
-[^%]		/* do nothing */
-"%"/[^}]	/* do nothing */
-"%}"		{ BEGIN(in_struct); }
-"%"		{
-  error_at_line (&lexer_line, 
-		 "unterminated %%{; unexpected EOF");
-}
-}
-
-
 ["/]    		|
 <in_struct_comment,in_comment>"*"	{
   error_at_line (&lexer_line, 
Index: S-vn-gtsmall/gcc/gengtype-yacc.y
===================================================================
--- S-vn-gtsmall.orig/gcc/gengtype-yacc.y	2007-03-17 16:05:49.000000000 -0700
+++ S-vn-gtsmall/gcc/gengtype-yacc.y	2007-03-17 16:08:30.000000000 -0700
@@ -38,7 +38,6 @@
 %token <t>ENT_TYPEDEF_STRUCT
 %token <t>ENT_STRUCT
 %token ENT_EXTERNSTATIC
-%token ENT_YACCUNION
 %token GTY_TOKEN
 %token UNION
 %token STRUCT
@@ -47,15 +46,13 @@
 %token NESTED_PTR
 %token <s>PARAM_IS
 %token NUM
-%token PERCENTPERCENT "%%"
 %token <t>SCALAR
 %token <s>ID
 %token <s>STRING
 %token <s>ARRAY
-%token <s>PERCENT_ID
 %token <s>CHAR
 
-%type <p> struct_fields yacc_ids yacc_typematch
+%type <p> struct_fields
 %type <t> type lasttype
 %type <o> optionsopt options option optionseq optionseqopt
 %type <s> type_option stringseq
@@ -65,7 +62,7 @@
 start: /* empty */
        | typedef_struct start
        | externstatic start
-       | yacc_union start
+       | start
        ;
 
 typedef_struct: ENT_TYPEDEF_STRUCT options '{' struct_fields '}' ID
@@ -116,72 +113,6 @@
 	   | '='
 	   ;
 
-yacc_union: ENT_YACCUNION options struct_fields '}' yacc_typematch
-	    PERCENTPERCENT
-	      {
-	        note_yacc_type ($2, $3, $5, &lexer_line);
-	      }
-	    ;
-
-yacc_typematch: /* empty */
-		   { $$ = NULL; }
-		| yacc_typematch PERCENT_ID yacc_ids
-		   {
-		     pair_p p;
-		     for (p = $3; p->next != NULL; p = p->next)
-		       {
-		         p->name = NULL;
-			 p->type = NULL;
-		       }
-		     p->name = NULL;
-		     p->type = NULL;
-		     p->next = $1;
-		     $$ = $3;
-		   }
-		| yacc_typematch PERCENT_ID '<' ID '>' yacc_ids
-		   {
-		     pair_p p;
-		     type_p newtype = NULL;
-		     if (strcmp ($2, "type") == 0)
-		       newtype = (type_p) 1;
-		     for (p = $6; p->next != NULL; p = p->next)
-		       {
-		         p->name = $4;
-		         p->type = newtype;
-		       }
-		     p->name = $4;
-		     p->next = $1;
-		     p->type = newtype;
-		     $$ = $6;
-		   }
-		;
-
-yacc_ids: /* empty */
-	{ $$ = NULL; }
-     | yacc_ids ID
-        {
-	  pair_p p = XCNEW (struct pair);
-	  p->next = $1;
-	  p->line = lexer_line;
-	  p->opt = XNEW (struct options);
-	  p->opt->name = "tag";
-	  p->opt->next = NULL;
-	  p->opt->info = (char *)$2;
-	  $$ = p;
-	}
-     | yacc_ids CHAR
-        {
-	  pair_p p = XCNEW (struct pair);
-	  p->next = $1;
-	  p->line = lexer_line;
-	  p->opt = XNEW (struct options);
-	  p->opt->name = "tag";
-	  p->opt->next = NULL;
-	  p->opt->info = xasprintf ("'%s'", $2);
-	  $$ = p;
-	}
-     ;
-
 struct_fields: { $$ = NULL; }
 	       | type optionsopt ID bitfieldopt ';' struct_fields
 	          {
Index: S-vn-gtsmall/gcc/gengtype.c
===================================================================
--- S-vn-gtsmall.orig/gcc/gengtype.c	2007-03-17 16:07:00.000000000 -0700
+++ S-vn-gtsmall/gcc/gengtype.c	2007-03-17 16:08:30.000000000 -0700
@@ -810,65 +810,6 @@
   return t;
 }
 
-/* Create a union for YYSTYPE, as yacc would do it, given a fieldlist FIELDS
-   and information about the correspondence between token types and fields
-   in TYPEINFO.  POS is used for error messages.  */
-
-void
-note_yacc_type (options_p o, pair_p fields, pair_p typeinfo,
-		struct fileloc *pos)
-{
-  pair_p p;
-  pair_p *p_p;
-
-  for (p = typeinfo; p; p = p->next)
-    {
-      pair_p m;
-
-      if (p->name == NULL)
-	continue;
-
-      if (p->type == (type_p) 1)
-	{
-	  pair_p pp;
-	  int ok = 0;
-
-	  for (pp = typeinfo; pp; pp = pp->next)
-	    if (pp->type != (type_p) 1
-		&& strcmp (pp->opt->info, p->opt->info) == 0)
-	      {
-		ok = 1;
-		break;
-	      }
-	  if (! ok)
-	    continue;
-	}
-
-      for (m = fields; m; m = m->next)
-	if (strcmp (m->name, p->name) == 0)
-	  p->type = m->type;
-      if (p->type == NULL)
-	{
-	  error_at_line (&p->line,
-			 "couldn't match fieldname `%s'", p->name);
-	  p->name = NULL;
-	}
-    }
-
-  p_p = &typeinfo;
-  while (*p_p)
-    {
-      pair_p p = *p_p;
-
-      if (p->name == NULL
-	  || p->type == (type_p) 1)
-	*p_p = p->next;
-      else
-	p_p = &p->next;
-    }
-
-  do_typedef ("YYSTYPE", new_structure ("yy_union", 1, pos, typeinfo, o), pos);
-}
 
 static void set_gc_used_type (type_p, enum gc_used_enum, type_p *);
 static void set_gc_used (pair_p);
Index: S-vn-gtsmall/gcc/gengtype.h
===================================================================
--- S-vn-gtsmall.orig/gcc/gengtype.h	2007-03-17 16:05:49.000000000 -0700
+++ S-vn-gtsmall/gcc/gengtype.h	2007-03-17 16:08:30.000000000 -0700
@@ -144,8 +144,6 @@
 extern type_p adjust_field_type (type_p, options_p);
 extern void note_variable (const char *s, type_p t, options_p o,
 			   struct fileloc *pos);
-extern void note_yacc_type (options_p o, pair_p fields,
-			    pair_p typeinfo, struct fileloc *pos);
 
 /* Lexer and parser routines, most automatically generated.  */
 extern int yylex (void);

--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]