[vala/staging] parser: Make parse_embedded_statement_without_block more robust



commit a8c1babc5562c1db14c959cdd89e21c4b77f0d07
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 aaae5a25a..5f9bd3464 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]