improve error handling, fixes bug 528431
authorJuerg Billeter <j@bitron.ch>
Wed, 16 Apr 2008 16:24:46 +0000 (16:24 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Wed, 16 Apr 2008 16:24:46 +0000 (16:24 +0000)
2008-04-16  Juerg Billeter  <j@bitron.ch>

* vala/valaparser.vala: improve error handling, fixes bug 528431

svn path=/trunk/; revision=1246

ChangeLog
vala/valaparser.vala

index 29d9e15..ff26c1c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2008-04-16  Jürg Billeter  <j@bitron.ch>
 
+       * vala/valaparser.vala: improve error handling, fixes bug 528431
+
+2008-04-16  Jürg Billeter  <j@bitron.ch>
+
        * gobject/valaccodegeneratorinvocationexpression.vala:
 
          Fix generated C code when calling struct methods
index ce25605..4add7b8 100644 (file)
@@ -468,6 +468,11 @@ public class Vala.Parser : CodeVisitor {
                                found = false;
                                break;
                        }
+
+                       if (expr == null) {
+                               // workaround for current limitation of exception handling
+                               throw new ParseError.SYNTAX ("syntax error in primary expression");
+                       }
                }
 
                return expr;
@@ -1074,6 +1079,10 @@ public class Vala.Parser : CodeVisitor {
                                next ();
                                var rhs = parse_expression ();
                                expr = context.create_assignment (expr, rhs, operator, get_src (begin));
+                               if (expr == null) {
+                                       // workaround for current limitation of exception handling
+                                       throw new ParseError.SYNTAX ("syntax error in assignment");
+                               }
                        } else if (current () == TokenType.OP_GT) { // >>=
                                char* first_gt_pos = tokens[index].begin.pos;
                                next ();
@@ -1082,6 +1091,10 @@ public class Vala.Parser : CodeVisitor {
                                        next ();
                                        var rhs = parse_expression ();
                                        expr = context.create_assignment (expr, rhs, AssignmentOperator.SHIFT_RIGHT, get_src (begin));
+                                       if (expr == null) {
+                                               // workaround for current limitation of exception handling
+                                               throw new ParseError.SYNTAX ("syntax error in assignment");
+                                       }
                                } else {
                                        prev ();
                                        break;