From b86883a7cce7d982c3f0d0069332dd490331e630 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 11 Aug 2015 14:32:54 +0100 Subject: Extend WebIDL parsing to cope with second edition IDL static interface elements --- src/webidl-parser.y | 106 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 92 insertions(+), 14 deletions(-) (limited to 'src/webidl-parser.y') diff --git a/src/webidl-parser.y b/src/webidl-parser.y index 9cfd84e..14385d6 100644 --- a/src/webidl-parser.y +++ b/src/webidl-parser.y @@ -150,10 +150,13 @@ webidl_error(YYLTYPE *locp, struct webidl_node **winbind_ast, const char *str) %type CallbackRestOrInterface %type Attribute +%type AttributeRest %type AttributeOrOperation %type StringifierAttributeOrOperation %type Const +%type StaticMember +%type StaticMemberRest %type Operation %type SpecialOperation %type Specials @@ -412,13 +415,15 @@ InterfaceMembers: /* [10] * SE[10] * Second edition actually splits up AttributeOrOperation completely - * here we "just" add Iterable as thats what the specs use + * here we "just" add Iterable and static member as thats what the specs use */ InterfaceMember: Const | AttributeOrOperation | + StaticMember + | Iterable ; @@ -690,28 +695,97 @@ StringifierAttributeOrOperation: } ; - /* [32] */ + /* [32] + * Modified for SE to use AttributeRest + */ Attribute: - Inherit ReadOnly TOK_ATTRIBUTE Type TOK_IDENTIFIER ';' + Inherit ReadOnly AttributeRest { - struct webidl_node *attribute; + struct webidl_node *attribute; - attribute = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, NULL, $5); + attribute = $3; - /* add attributes type */ - attribute = webidl_node_prepend(attribute, $4); + /* deal with inherit modifier */ + if ($1) { + attribute = webidl_node_new(WEBIDL_NODE_TYPE_MODIFIER, + attribute, + (void *)WEBIDL_TYPE_MODIFIER_INHERIT); + } - /* deal with readonly modifier */ - if ($2) { - attribute = webidl_node_new(WEBIDL_NODE_TYPE_MODIFIER, attribute, (void *)WEBIDL_TYPE_MODIFIER_READONLY); - } + /* deal with readonly modifier */ + if ($2) { + attribute = webidl_node_new(WEBIDL_NODE_TYPE_MODIFIER, + attribute, + (void *)WEBIDL_TYPE_MODIFIER_READONLY); + } + + $$ = webidl_node_new(WEBIDL_NODE_TYPE_ATTRIBUTE, + NULL, + attribute); + } + ; + + +/* SE[37] */ +StaticMember: + TOK_STATIC StaticMemberRest + { + $$ = $2; + } + ; + + +/* SE[38] */ +StaticMemberRest: + ReadOnly AttributeRest + { + struct webidl_node *attribute; + + attribute = webidl_node_new(WEBIDL_NODE_TYPE_MODIFIER, + $2, (void *)WEBIDL_TYPE_MODIFIER_STATIC); + + /* deal with readonly modifier */ + if ($1) { + attribute = webidl_node_new(WEBIDL_NODE_TYPE_MODIFIER, + attribute, + (void *)WEBIDL_TYPE_MODIFIER_READONLY); + } + + $$ = webidl_node_new(WEBIDL_NODE_TYPE_ATTRIBUTE, + NULL, + attribute); + } + | + ReturnType OperationRest + { + struct webidl_node *operation; + + /* add static modifier */ + operation = webidl_node_new(WEBIDL_NODE_TYPE_MODIFIER, + $2, (void *)WEBIDL_TYPE_MODIFIER_STATIC); + + /* put return type on the operation */ + operation = webidl_node_prepend($1, operation); - $$ = webidl_node_new(WEBIDL_NODE_TYPE_ATTRIBUTE, NULL, attribute); + $$ = webidl_node_new(WEBIDL_NODE_TYPE_OPERATION, + NULL, + operation); + } + ; + + /* SE[42] */ +AttributeRest: + TOK_ATTRIBUTE Type TOK_IDENTIFIER ';' + { + $$ = webidl_node_new(WEBIDL_NODE_TYPE_IDENT, $2, $3); } ; - /* [33] */ + +/* [33] + * SE[45] + */ Inherit: /* empty */ { @@ -724,7 +798,10 @@ Inherit: } ; - /* [34] */ + +/* [34] + * SE[46] + */ ReadOnly: /* empty */ { @@ -737,6 +814,7 @@ ReadOnly: } ; + /* SE[47] */ Operation: ReturnType OperationRest -- cgit v1.2.3