[vala] parser: -val is now parsed as a literal instead of unary expression
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] parser: -val is now parsed as a literal instead of unary expression
- Date: Sun, 21 Jun 2015 13:09:07 +0000 (UTC)
commit 3b9c095fa3018029818cf19b4c9fcbe8bec34c72
Author: Luca Bruno <lucabru src gnome org>
Date: Sun Jun 21 15:07:23 2015 +0200
parser: -val is now parsed as a literal instead of unary expression
Fixes bug 643612
tests/Makefile.am | 1 +
vala/valaparser.vala | 8 ++++++++
2 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 343da51..03b228d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,6 +28,7 @@ TESTS = \
basic-types/bug596637.vala \
basic-types/bug596785.vala \
basic-types/bug632322.vala \
+ basic-types/bug643612.vala \
basic-types/bug644046.vala \
basic-types/bug647222.vala \
basic-types/bug648364.vala \
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 247a85c..e25eef8 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -1039,6 +1039,14 @@ public class Vala.Parser : CodeVisitor {
if (operator != UnaryOperator.NONE) {
next ();
var op = parse_unary_expression ();
+ var lit = op as IntegerLiteral;
+ if (lit != null) {
+ if (operator == UnaryOperator.PLUS) {
+ return lit;
+ } else if (operator == UnaryOperator.MINUS) {
+ return new IntegerLiteral ("-"+lit.value, get_src (begin));
+ }
+ }
return new UnaryExpression (operator, op, get_src (begin));
}
switch (current ()) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]