[vala/wip/ricotz/lsp: 4/13] langserver: handle if_statement bad syntax
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/ricotz/lsp: 4/13] langserver: handle if_statement bad syntax
- Date: Thu, 9 Jan 2020 17:53:05 +0000 (UTC)
commit 706103a5d2b103b81ee5eb8ce443773b18e4ef56
Author: Princeton Ferro <princetonferro gmail com>
Date: Wed Dec 25 14:47:37 2019 -0500
langserver: handle if_statement bad syntax
vala/valaparser.vala | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index d44b61154..79aa98713 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -1756,8 +1756,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; // rethrow
+ }
+ }
block.source_reference.end = get_last_src ().end;
return block;
@@ -1969,7 +1977,13 @@ public class Vala.Parser : CodeVisitor {
expect (TokenType.IF);
expect (TokenType.OPEN_PARENS);
var condition = parse_expression ();
- expect (TokenType.CLOSE_PARENS);
+ if (context.keep_going) {
+ if (!accept (TokenType.CLOSE_PARENS)) {
+ report_parse_error (new ParseError.SYNTAX ("expected %s".printf
(TokenType.CLOSE_PARENS.to_string ())), false);
+ }
+ } else {
+ expect (TokenType.CLOSE_PARENS);
+ }
var src = get_src (begin);
var true_stmt = parse_embedded_statement ("if", false);
Block false_stmt = null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]