[vala/wip/ricotz/lsp-rev: 5/9] parser: Make parse_argument_list/parse_initializer more robust
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/ricotz/lsp-rev: 5/9] parser: Make parse_argument_list/parse_initializer more robust
- Date: Tue, 21 Jan 2020 14:38:09 +0000 (UTC)
commit e0342dfa13057154de43e8e75b85903168aefa19
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Jan 18 20:03:37 2020 +0100
parser: Make parse_argument_list/parse_initializer more robust
vala/valaparser.vala | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 832eeff16..e862458be 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -579,7 +579,18 @@ public class Vala.Parser : CodeVisitor {
var list = new ArrayList<Expression> ();
if (current () != TokenType.CLOSE_PARENS) {
do {
- list.add (parse_argument ());
+ try {
+ list.add (parse_argument ());
+ } catch (ParseError e) {
+ if (current () == TokenType.CLOSE_PARENS) {
+ prev ();
+ report_parse_error (new ParseError.SYNTAX ("incomplete
argument list"));
+ } else if (context.keep_going) {
+ report_parse_error (e);
+ } else {
+ throw e;
+ }
+ }
} while (accept (TokenType.COMMA));
}
expect (TokenType.CLOSE_PARENS);
@@ -2732,7 +2743,18 @@ public class Vala.Parser : CodeVisitor {
expect (TokenType.OPEN_BRACE);
var initializer = new InitializerList (get_src (begin));
while (current () != TokenType.CLOSE_BRACE) {
- initializer.append (parse_argument ());
+ try {
+ initializer.append (parse_argument ());
+ } catch (ParseError e) {
+ if (current () == TokenType.CLOSE_BRACE) {
+ prev ();
+ report_parse_error (new ParseError.SYNTAX ("incomplete initializer"));
+ } else if (context.keep_going) {
+ report_parse_error (e);
+ } else {
+ throw e;
+ }
+ }
if (!accept (TokenType.COMMA)) {
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]