From: Oscar J Rodriguez Date: Fri, 5 May 2023 03:35:09 +0000 (-0700) Subject: appropiate printing for the printer function in the case of immidiate values X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=f2939533b515bfcbaf37f4e6fec4799ca63a3585;p=TinyThreePassCompiler%2F.git appropiate printing for the printer function in the case of immidiate values --- 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: