From d998ecfc428df28e813c5f0d62fb1b3d0ae4174c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20B=C3=A4rtschi?= Date: Thu, 23 Jan 2025 09:10:29 +0100 Subject: [PATCH] better representation of ast and tast --- ast/ast.go | 2 +- tast/tast.go | 2 +- test.tt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ast/ast.go b/ast/ast.go index a9f6fdb..35a328e 100644 --- a/ast/ast.go +++ b/ast/ast.go @@ -107,5 +107,5 @@ type BinaryExpression struct { func (be *BinaryExpression) expressionNode() {} func (be *BinaryExpression) TokenLiteral() string { return be.Token.Literal } func (be *BinaryExpression) String() string { - return fmt.Sprintf("%s %s %s", be.Lhs, be.Operator, be.Rhs) + return fmt.Sprintf("%s %s %s", be.Lhs, be.Operator.SymbolString(), be.Rhs) } diff --git a/tast/tast.go b/tast/tast.go index c7ae9a2..92a8b7c 100644 --- a/tast/tast.go +++ b/tast/tast.go @@ -89,5 +89,5 @@ func (be *BinaryExpression) Type() types.Type { } func (be *BinaryExpression) TokenLiteral() string { return be.Token.Literal } func (be *BinaryExpression) String() string { - return fmt.Sprintf("%s %s %s", be.Lhs, be.Operator, be.Rhs) + return fmt.Sprintf("(%s %s %s :> %s)", be.Lhs, be.Operator.SymbolString(), be.Rhs, be.ResultType.Name()) } diff --git a/test.tt b/test.tt index 1469b1c..c033802 100644 --- a/test.tt +++ b/test.tt @@ -1 +1 @@ -fn main() = 35 + 34; +fn main() = 3 * 3 / 3 + 1 - 1;