widl: Allow trailing commas in attribute lists, take 2
Dan Hipschman
dsh at linux.ucla.edu
Tue Jul 25 14:00:49 CDT 2006
MIDL allows extraneous commas in attribute lists such as:
[][,][,,version(1.0),][,,][uuid(...)]
coclass Foo {...}
presumably to ease the job of code generators. In particular, the file
attached to this posting
<http://www.winehq.org/pipermail/wine-devel/2006-June/048307.html>
contains an attribute list with a trailing comma which currently trips
up widl. With this patch the file will compile. (Although another bug
prevents widl from generating a typelib from it, it can at least now
generate a header.)
ChangeLog:
* Allow extraneous commas in attribute lists (MIDL feature)
---
tools/widl/parser.y | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index a7b1269..1790985 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -343,16 +343,23 @@ m_attributes: { $$ = NULL; }
;
attributes:
- '[' attrib_list ']' { $$ = $2; }
+ '[' attrib_list ']' { $$ = $2;
+ if (!$$)
+ 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:
- tAGGREGATABLE { $$ = make_attr(ATTR_AGGREGATABLE); }
+attribute: { $$ = NULL; }
+ | tAGGREGATABLE { $$ = make_attr(ATTR_AGGREGATABLE); }
| tAPPOBJECT { $$ = make_attr(ATTR_APPOBJECT); }
| tASYNC { $$ = make_attr(ATTR_ASYNC); }
| tAUTOHANDLE { $$ = make_attr(ATTR_AUTO_HANDLE); }
More information about the wine-patches
mailing list