From f2939533b515bfcbaf37f4e6fec4799ca63a3585 Mon Sep 17 00:00:00 2001 From: Oscar J Rodriguez Date: Thu, 4 May 2023 20:35:09 -0700 Subject: [PATCH] appropiate printing for the printer function in the case of immidiate values --- compiler.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler.go b/compiler.go index 6cd94fd..e590707 100644 --- a/compiler.go +++ b/compiler.go @@ -29,7 +29,7 @@ type AST struct { func main() { //a := &AST{Op: imm, N: 5 //b := &AST{Op: plus, A: a, B: &AST{Op: arg, N: 0}} - input := "[ a b ] (a*a) + (b*b)" + input := "[ a b ] (a*a) + (5*b)" //value := []rune(input) variables, program := extractVariables(input) @@ -52,7 +52,8 @@ func main() { func printer(tree *AST) { switch { case tree.Op == imm: - fmt.Print(tree.Value - 48) + fmt.Print(tree.Value) + //fmt.Print(tree.Value - 48) case tree.Op == arg: fmt.Printf("%c", tree.Value) default: -- 2.25.1