Skip to content

Instantly share code, notes, and snippets.

Created February 25, 2015 05:00
Show Gist options
  • Save anonymous/e702772595bb749953af to your computer and use it in GitHub Desktop.
Save anonymous/e702772595bb749953af to your computer and use it in GitHub Desktop.
> (define e (let-values (((tokenVal currentToken) (getToken)))
(readExpr tokenVal currentToken)))
12 + 3 - 4
> e
'((right (val . 4) (op . NUM))
(left
(right (val . 3) (op . NUM))
(left (val . 12) (op . NUM))
(op . PLUS_OP))
(op . MINUS_OP))
> (Codes e '())
'(((opcode . SUB))
((opcode . PUSH) (operand . 4))
((opcode . ADD))
((opcode . PUSH) (operand . 3))
((opcode . PUSH) (operand . 12)))
> (compileExpr e)
'#(((opcode . PUSH) (operand . 12))
((opcode . PUSH) (operand . 3))
((opcode . ADD))
((opcode . PUSH) (operand . 4))
((opcode . SUB)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment