widl: Allow empty strings as attributes

Dan Hipschman dsh at linux.ucla.edu
Mon Jul 24 19:07:18 CDT 2006


MIDL allows empty strings where attributes should be.  In particular, we
should allow a trailing comma.  This patch covers the general case.  Also
note that we didn't support empty attribute lists before, and this doesn't
change that, but it at least also adds a more helpful message than "syntax
error".

ChangeLog:
* Support extraneous commas in attribute lists
---
 tools/widl/parser.y |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 7257bd8..9a3b596 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -341,12 +341,18 @@ m_attributes:					{ $$ = NULL; }
 	;
 
 attributes:
-	  '[' attrib_list ']'			{ $$ = $2; }
+	  '[' attrib_list ']'			{ if (! ($$ = $2))
+						    yyerror("empty attribute lists unsupported");
+						}
 	;
 
 attrib_list: attribute
-	| attrib_list ',' attribute		{ LINK($3, $1); $$ = $3; }
-	| attrib_list ']' '[' attribute		{ LINK($4, $1); $$ = $4; }
+	| attrib_list ',' attribute		{ if ($3) { LINK($3, $1); $$ = $3; }
+						  else { $$ = $1; }
+						}
+	| attrib_list ']' '[' attribute		{ if ($4) { LINK($4, $1); $$ = $4; }
+						  else { $$ = $1; }
+						}
 	;
 
 attribute:
@@ -419,6 +425,7 @@ attribute:
 	| tVERSION '(' version ')'		{ $$ = make_attrv(ATTR_VERSION, $3); }
 	| tWIREMARSHAL '(' type ')'		{ $$ = make_attrp(ATTR_WIREMARSHAL, type_ref($3)); }
 	| pointer_type				{ $$ = make_attrv(ATTR_POINTERTYPE, $1); }
+	|	/* empty */			{ $$ = NULL; }
 	;
 
 callconv:



More information about the wine-patches mailing list