]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
genieparser: Allow comma-separated identifiers in definition of enums
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 5 Jan 2017 11:17:21 +0000 (12:17 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 17 Feb 2017 19:39:25 +0000 (20:39 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=776833

vala/valagenieparser.vala

index a72dead8475dac4d26882185d8c4af197f75652d..df4f66e9b608462c2847a619c46989ea22cb9998 100644 (file)
@@ -124,6 +124,14 @@ public class Vala.Genie.Parser : CodeVisitor {
                return false;
        }
 
+       inline bool accept_separator () {
+               if (current () == TokenType.COMMA || current () == TokenType.EOL) {
+                       next ();
+                       return true;
+               }
+               return false;
+       }
+
        inline bool accept_terminator () {
                if (current () == TokenType.SEMICOLON || current () == TokenType.EOL) {
                        next ();
@@ -165,6 +173,16 @@ public class Vala.Genie.Parser : CodeVisitor {
                throw new ParseError.SYNTAX ("expected %s but got %s with previous %s", type.to_string (), cur.to_string (), pre.to_string());
        }
 
+       inline bool expect_separator () throws ParseError {
+               if (accept_separator ()) {
+                       return true;
+               }
+
+               TokenType cur = current ();
+
+               throw new ParseError.SYNTAX ("expected line end or comma but got %s", cur.to_string());
+       }
+
        inline bool expect_terminator () throws ParseError {
                if (accept_terminator ()) {
                        return true;
@@ -318,8 +336,10 @@ public class Vala.Genie.Parser : CodeVisitor {
                        }
                        break;
                default:
-                       throw new ParseError.SYNTAX ("expected identifier");
-               }       
+                       break;
+               }
+
+               throw new ParseError.SYNTAX ("expected identifier");
        }
 
        string parse_identifier () throws ParseError {
@@ -3452,7 +3472,9 @@ public class Vala.Genie.Parser : CodeVisitor {
                        set_attributes (ev, value_attrs);
 
                        en.add_value (ev);
-                       expect (TokenType.EOL);
+                       if (expect_separator ()) {
+                               accept (TokenType.EOL);
+                       }
                } while (true);
                
                expect (TokenType.DEDENT);