[vala/wip/ricotz/lsp-rev: 2/8] parser: Walkover certain missing expected tokens to continue parsing



commit c1b0825038fab3af4134be63d9077c4350ac1c69
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Jan 18 20:03:37 2020 +0100

    parser: Walkover certain missing expected tokens to continue parsing

 vala/valaparser.vala | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index a030d24f2..e927020d2 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -126,7 +126,21 @@ public class Vala.Parser : CodeVisitor {
                        return true;
                }
 
-               throw new ParseError.SYNTAX ("expected %s", type.to_string ());
+               var e = new ParseError.SYNTAX ("expected %s", type.to_string ());
+
+               switch (type) {
+               case TokenType.SEMICOLON:
+                       prev ();
+                       report_parse_error (e);
+                       return true;
+               case TokenType.CLOSE_PARENS:
+               case TokenType.CLOSE_BRACKET:
+                       report_parse_error (e);
+                       prev ();
+                       return true;
+               default:
+                       throw e;
+               }
        }
 
        inline SourceLocation get_location () {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]