[vala/staging] vala: Improve parsing of with-statement and allow it as embedded statement
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] vala: Improve parsing of with-statement and allow it as embedded statement
- Date: Thu, 17 Sep 2020 13:21:06 +0000 (UTC)
commit 69cc119d0db1b05e581647105e30875136948fa3
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Sep 17 15:16:59 2020 +0200
vala: Improve parsing of with-statement and allow it as embedded statement
tests/parser/with-embedded.vala | 8 ++++++--
vala/valaparser.vala | 2 ++
2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/tests/parser/with-embedded.vala b/tests/parser/with-embedded.vala
index c668e5afc..6f61891d1 100644
--- a/tests/parser/with-embedded.vala
+++ b/tests/parser/with-embedded.vala
@@ -1,4 +1,8 @@
void main () {
- with (10)
- assert (to_string () == "10");
+ if (true)
+ with ("foo")
+ assert (to_string () == "foo");
+
+ with (10)
+ assert (to_string () == "10");
}
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index d184a8431..216cd0a7d 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -1836,6 +1836,7 @@ public class Vala.Parser : CodeVisitor {
case TokenType.LOCK: return parse_lock_statement ();
case TokenType.UNLOCK: return parse_unlock_statement ();
case TokenType.DELETE: return parse_delete_statement ();
+ case TokenType.WITH: return parse_with_statement ();
case TokenType.VAR:
case TokenType.CONST:
throw new ParseError.SYNTAX ("embedded statement cannot be declaration ");
@@ -2646,6 +2647,7 @@ public class Vala.Parser : CodeVisitor {
case TokenType.UNLOCK:
case TokenType.VAR:
case TokenType.WHILE:
+ case TokenType.WITH:
case TokenType.YIELD:
return RecoveryState.STATEMENT_BEGIN;
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]