[PATCH 02/11] widl: Add RT's namespace keyword to scanner, and parser.

Kai Tietz ktietz70 at googlemail.com
Thu Aug 8 10:54:20 CDT 2013


Hi,

this patch adds the keyword-scanning of "namespace" keyword dependent
on the --rt option.  Additional it adds to parser the ablility to
handle nested namespaces ...
Here is still a nit to be done for MS special syntax 'namespace
<name1>.<name2>.<name3> { <...> }', which needs to be handled in a
later patch.

Ok for apply?

Kai

>From 21a397df461ecd14af41dc080d8df7b55590c7f7 Mon Sep 17 00:00:00 2001
From: Kai Tietz <ktietz70 at googlemail.com>
Date: Thu, 8 Aug 2013 15:45:24 +0200
Subject: [PATCH 02/11] 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..0748f9c 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;
-- 
1.7.9



More information about the wine-patches mailing list