[vala/wip/ricotz/lsp-rev: 14/15] parser: Make parse_embedded_statement_without_block more robust



commit 40a2131f4545bd4bcaa79a0ac4270cb18863a821
Author: Princeton Ferro <princetonferro gmail com>
Date:   Sat Jan 18 20:03:37 2020 +0100

    parser: Make parse_embedded_statement_without_block more robust

 vala/valaparser.vala | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 7bce26aed..2f9cbb0f2 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -1744,8 +1744,16 @@ public class Vala.Parser : CodeVisitor {
 
                var block = new Block (get_src (get_location ()));
 
-               var stmt = parse_embedded_statement_without_block (statement_name, accept_empty_body);
-               block.add_statement (stmt);
+               try {
+                       var stmt = parse_embedded_statement_without_block (statement_name, accept_empty_body);
+                       block.add_statement (stmt);
+               } catch (ParseError e) {
+                       if (context.keep_going) {
+                               report_parse_error (e);
+                       } else {
+                               throw e;
+                       }
+               }
                block.source_reference.end = get_last_src ().end;
 
                return block;


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