]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: accept empty tuple for parameters without initializer
authorJürg Billeter <j@bitron.ch>
Wed, 28 Aug 2013 15:07:11 +0000 (17:07 +0200)
committerJürg Billeter <j@bitron.ch>
Wed, 28 Aug 2013 15:07:11 +0000 (17:07 +0200)
vala/valagirparser.vala

index fde6b68fba0a8967bddfa156ebe89b918bd7aff1..3ad733568ae96d34f795067133c173d9a4a22430 100644 (file)
@@ -427,6 +427,14 @@ public class Vala.GirParser : CodeVisitor {
                                        expr = new MemberAccess (expr, get_string (), get_current_src ());
                                }
                                return expr;
+                       case TokenType.OPEN_PARENS:
+                               // empty tuple => no expression
+                               if (next () != TokenType.CLOSE_PARENS) {
+                                       Report.error (get_current_src (), "expected `)', got %s".printf (current.to_string ()));
+                                       break;
+                               }
+                               expr = new Tuple (src);
+                               break;
                        default:
                                Report.error (src, "expected literal or symbol got %s".printf (current.to_string ()));
                                break;
@@ -2278,6 +2286,11 @@ public class Vala.GirParser : CodeVisitor {
                                }
                        }
                        param.initializer = metadata.get_expression (ArgumentType.DEFAULT);
+
+                       // empty tuple used for parameters without initializer
+                       if (param.initializer is Tuple) {
+                               param.initializer = null;
+                       }
                }
                end_element ("parameter");
                return param;