Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
DQNEO committed Aug 29, 2019
1 parent d36aa77 commit 0b8462d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,20 @@ func parse() *Expr {
return expr
}

func generate(expr *Expr) {
func generateExpr(expr *Expr) {
fmt.Printf(" movq $%d, %%rax\n", expr.intval)
}

func generateCode(expr *Expr) {
fmt.Printf(" .global main\n")
fmt.Printf("main:\n")
fmt.Printf(" movq $%d, %%rax\n", expr.intval)
generateExpr(expr)
fmt.Printf(" ret\n")
}

func main() {
source, _ = ioutil.ReadFile("/dev/stdin")
tokens = tokenize()
expr := parse()
generate(expr)
generateCode(expr)
}

0 comments on commit 0b8462d

Please sign in to comment.