projects
/
TinyThreePassCompiler
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
cca4b9f
)
appropiate printing for the printer function in the case of immidiate values
author
Oscar J Rodriguez
<jrpc@google.com>
Fri, 5 May 2023 03:35:09 +0000
(20:35 -0700)
committer
Oscar J Rodriguez
<jrpc@google.com>
Fri, 5 May 2023 03:35:09 +0000
(20:35 -0700)
compiler.go
patch
|
blob
|
history
diff --git
a/compiler.go
b/compiler.go
index 6cd94fd9c70a8003efb97fbc030955e9a4228291..e5907076fb3dbd24b7b1f72008a4f00719a9cdf9 100644
(file)
--- 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}}
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)
//value := []rune(input)
variables, program := extractVariables(input)
@@
-52,7
+52,8
@@
func main() {
func printer(tree *AST) {
switch {
case tree.Op == imm:
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:
case tree.Op == arg:
fmt.Printf("%c", tree.Value)
default: