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
This commit is contained in:
William S Fulton 2017-08-26 14:00:44 +01:00
commit c9d425604c

View file

@ -1591,7 +1591,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
/* Misc */ /* Misc */
%type <id> identifier; %type <id> identifier;
%type <dtype> initializer cpp_const exception_specification cv_ref_qualifier; %type <dtype> initializer cpp_const exception_specification cv_ref_qualifier qualifiers_exception_specification;
%type <id> storage_class extern_string; %type <id> storage_class extern_string;
%type <pl> parms ptail rawparms varargs_parms ; %type <pl> parms ptail rawparms varargs_parms ;
%type <pl> templateparameters templateparameterstail; %type <pl> templateparameters templateparameterstail;
@ -3276,30 +3276,14 @@ initializer : def_args {
$$.throwf = 0; $$.throwf = 0;
$$.nexcept = 0; $$.nexcept = 0;
} }
| cv_ref_qualifier def_args { | qualifiers_exception_specification def_args {
$$ = $2; $$ = $2;
$$.qualifier = $1.qualifier; $$.qualifier = $1.qualifier;
$$.refqualifier = $1.refqualifier; $$.refqualifier = $1.refqualifier;
$$.throws = 0;
$$.throwf = 0;
$$.nexcept = 0;
}
| exception_specification def_args {
$$ = $2;
$$.qualifier = 0;
$$.refqualifier = 0;
$$.throws = $1.throws; $$.throws = $1.throws;
$$.throwf = $1.throwf; $$.throwf = $1.throwf;
$$.nexcept = $1.nexcept; $$.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; } 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; $$.throws = 0;
$$.throwf = 0; $$.throwf = 0;
$$.nexcept = 0; $$.nexcept = 0;
@ -6705,6 +6689,11 @@ cpp_const : cv_ref_qualifier {
$$.qualifier = $1.qualifier; $$.qualifier = $1.qualifier;
$$.refqualifier = $1.refqualifier; $$.refqualifier = $1.refqualifier;
} }
;
cpp_const : qualifiers_exception_specification {
$$ = $1;
}
| empty { | empty {
$$.throws = 0; $$.throws = 0;
$$.throwf = 0; $$.throwf = 0;