Module: wine Branch: master Commit: 499f05433a3d2fc197dfe654f3cea951898d8754 URL: http://source.winehq.org/git/wine.git/?a=commit;h=499f05433a3d2fc197dfe654f3...
Author: Kai Tietz ktietz70@googlemail.com Date: Thu Aug 8 15:45:24 2013 +0200
widl: Add RT's namespace keyword to scanner, and parser.
---
tools/widl/parser.l | 3 ++- tools/widl/parser.y | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/tools/widl/parser.l b/tools/widl/parser.l index e806167..fb61e21 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -261,6 +261,7 @@ static const struct keyword keywords[] = { {"long", tLONG}, {"methods", tMETHODS}, {"module", tMODULE}, + {"namespace", tNAMESPACE}, {"pascal", tPASCAL}, {"properties", tPROPERTIES}, {"register", tREGISTER}, @@ -414,7 +415,7 @@ static int kw_token(const char *kw) struct keyword key, *kwp; key.kw = kw; kwp = bsearch(&key, keywords, NKEYWORDS, sizeof(keywords[0]), kw_cmp_func); - if (kwp) { + if (kwp && (do_rt_extension || kwp->token != tNAMESPACE)) { parser_lval.str = xstrdup(kwp->kw); return kwp->token; } diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 579cbc6..0b5ebe6 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -121,6 +121,7 @@ static statement_t *make_statement_typedef(var_list_t *names); static statement_t *make_statement_import(const char *str); static statement_t *make_statement_typedef(var_list_t *names); static statement_list_t *append_statement(statement_list_t *list, statement_t *stmt); +static statement_list_t *append_statements(statement_list_t *, statement_list_t *);
%} %union { @@ -202,6 +203,7 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s %token tMAYBE tMESSAGE %token tMETHODS %token tMODULE +%token tNAMESPACE %token tNOCODE tNONBROWSABLE %token tNONCREATABLE %token tNONEXTENSIBLE @@ -258,6 +260,7 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s %type <type> inherit interface interfacedef interfacedec %type <type> dispinterface dispinterfacehdr dispinterfacedef %type <type> module modulehdr moduledef +%type <type> namespacedef %type <type> base_type int_std %type <type> enumdef structdef uniondef typedecl %type <type> type @@ -315,6 +318,8 @@ input: gbl_statements { fix_incomplete(); ;
gbl_statements: { $$ = NULL; } + | gbl_statements namespacedef '{' gbl_statements '}' + { $$ = append_statements($1, $4); } | gbl_statements interfacedec { $$ = append_statement($1, make_statement_reference($2)); } | gbl_statements interfacedef { $$ = append_statement($1, make_statement_type_decl($2)); } | gbl_statements coclass ';' { $$ = $1; @@ -330,6 +335,8 @@ gbl_statements: { $$ = NULL; }
imp_statements: { $$ = NULL; } | imp_statements interfacedec { $$ = append_statement($1, make_statement_reference($2)); } + | imp_statements namespacedef '{' imp_statements '}' + { $$ = append_statements($1, $4); } | imp_statements interfacedef { $$ = append_statement($1, make_statement_type_decl($2)); } | imp_statements coclass ';' { $$ = $1; reg_type($2, $2->name, 0); } | imp_statements coclassdef { $$ = append_statement($1, make_statement_type_decl($2)); @@ -801,6 +808,9 @@ coclassdef: coclasshdr '{' coclass_ints '}' semicolon_opt { $$ = type_coclass_define($1, $3); } ;
+namespacedef: tNAMESPACE aIDENTIFIER { $$ = NULL; } + ; + coclass_ints: { $$ = NULL; } | coclass_ints coclass_int { $$ = append_ifref( $1, $2 ); } ; @@ -2784,6 +2794,14 @@ static statement_t *make_statement_typedef(declarator_list_t *decls) return stmt; }
+static statement_list_t *append_statements(statement_list_t *l1, statement_list_t *l2) +{ + if (!l2) return l1; + if (!l1 || l1 == l2) return l2; + list_move_tail (l1, l2); + return l1; +} + static statement_list_t *append_statement(statement_list_t *list, statement_t *stmt) { if (!stmt) return list;