[vala/wip/ricotz/lsp-rev: 9/12] parser: Make parse_embedded_statement_without_block more robust



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

    parser: Make parse_embedded_statement_without_block more robust
    
    ... when --keep-going was passed

 vala/valaparser.vala | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index e862458be..5ff367809 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -1734,8 +1734,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]