From c9d425604c58a9c862b562ffffd260f6647b08c2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 26 Aug 2017 14:00:44 +0100 Subject: [PATCH] Re-organise parser grammar for declarator and initializer rules Step 1 to make these closer to the definitions used in the standard. The initializer rule should not include qualifiers and exception specification. - split cpp_const into add qualifiers_exception_specification and empty rules - simplify initializer to use new qualifiers_exception_specification rule --- Source/CParse/parser.y | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 3e0fd3282..4c73b8a25 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1591,7 +1591,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier) /* Misc */ %type identifier; -%type initializer cpp_const exception_specification cv_ref_qualifier; +%type initializer cpp_const exception_specification cv_ref_qualifier qualifiers_exception_specification; %type storage_class extern_string; %type parms ptail rawparms varargs_parms ; %type templateparameters templateparameterstail; @@ -3268,38 +3268,22 @@ c_decl_tail : SEMI { } ; -initializer : def_args { - $$ = $1; +initializer : def_args { + $$ = $1; $$.qualifier = 0; $$.refqualifier = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } - | cv_ref_qualifier def_args { - $$ = $2; - $$.qualifier = $1.qualifier; - $$.refqualifier = $1.refqualifier; - $$.throws = 0; - $$.throwf = 0; - $$.nexcept = 0; - } - | exception_specification def_args { - $$ = $2; - $$.qualifier = 0; - $$.refqualifier = 0; + | qualifiers_exception_specification def_args { + $$ = $2; + $$.qualifier = $1.qualifier; + $$.refqualifier = $1.refqualifier; $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; } - | cv_ref_qualifier exception_specification def_args { - $$ = $3; - $$.qualifier = $1.qualifier; - $$.refqualifier = $1.refqualifier; - $$.throws = $2.throws; - $$.throwf = $2.throwf; - $$.nexcept = $2.nexcept; - } ; cpp_alternate_rettype : primitive_type { $$ = $1; } @@ -6688,7 +6672,7 @@ exception_specification : THROW LPAREN parms RPAREN { } ; -cpp_const : cv_ref_qualifier { +qualifiers_exception_specification : cv_ref_qualifier { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; @@ -6705,6 +6689,11 @@ cpp_const : cv_ref_qualifier { $$.qualifier = $1.qualifier; $$.refqualifier = $1.refqualifier; } + ; + +cpp_const : qualifiers_exception_specification { + $$ = $1; + } | empty { $$.throws = 0; $$.throwf = 0;