From 8af07570cd55281afefec11b14381ad4a9257a2e Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 12 Apr 2020 14:40:57 +1200 Subject: [PATCH] node: implement UnaryPlus/UnaryMinus --- node.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/node.go b/node.go index 94c65f0..13816e8 100644 --- a/node.go +++ b/node.go @@ -1275,6 +1275,22 @@ func (this *conversionState) convertNoFreeFloating(n_ node.Node) (string, error) return v + "++", nil + case *expr.UnaryMinus: + v, err := this.convert(n.Expr) + if err != nil { + return "", parseErr{n, err} + } + + return "-(" + v + ")", nil + + case *expr.UnaryPlus: + v, err := this.convert(n.Expr) + if err != nil { + return "", parseErr{n, err} + } + + return "+(" + v + ")", nil + case *expr.MethodCall: // Foo->Bar(Baz) parent, err := this.convert(n.Variable)