aboutsummaryrefslogtreecommitdiff
path: root/Source/CParse
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2018-01-05 07:58:25 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2018-01-05 07:58:25 +0000
commitef378407d064142672ccb55cbff47723a14f162c (patch)
tree4606bf2226c125d15428f91127d3a4d742b1e10b /Source/CParse
parentcd9b7c3c34def07db975a2b706e425afc6500adb (diff)
downloadswig-ef378407d064142672ccb55cbff47723a14f162c.tar.gz
Fix parsing of default argument expressions containing ->.
Diffstat (limited to 'Source/CParse')
-rw-r--r--Source/CParse/parser.y30
1 files changed, 28 insertions, 2 deletions
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 857cecd0e..0c8d95ecd 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -1604,7 +1604,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
%type <type> type rawtype type_right anon_bitfield_type decltype ;
%type <bases> base_list inherit raw_inherit;
%type <dtype> definetype def_args etype default_delete deleted_definition explicit_default;
-%type <dtype> expr exprnum exprcompound valexpr;
+%type <dtype> expr exprnum exprcompound valexpr exprmem;
%type <id> ename ;
%type <id> less_valparms_greater;
%type <str> type_qualifier;
@@ -6266,7 +6266,33 @@ expr : valexpr { $$ = $1; }
}
;
-valexpr : exprnum { $$ = $1; }
+/* simple member access expressions */
+exprmem : ID ARROW ID {
+ $$.val = NewStringf("%s->%s", $1, $3);
+ $$.type = 0;
+ }
+ | exprmem ARROW ID {
+ $$ = $1;
+ Printf($$.val, "->%s", $3);
+ }
+/* This generates a shift-reduce
+ | ID PERIOD ID {
+ $$.val = NewStringf("%s.%s", $1, $3);
+ $$.type = 0;
+ }
+*/
+ | exprmem PERIOD ID {
+ $$ = $1;
+ Printf($$.val, ".%s", $3);
+ }
+ ;
+
+valexpr : exprnum {
+ $$ = $1;
+ }
+ | exprmem {
+ $$ = $1;
+ }
| string {
$$.val = $1;
$$.type = T_STRING;