now (+) in the abstract syntax works, i.e. it knows how to deal with partial sums

This commit is contained in:
kr.angelov
2014-10-31 14:16:11 +00:00
parent 9b0f354c7c
commit b1e6a21c56
7 changed files with 322 additions and 26 deletions

View File

@@ -32,6 +32,8 @@ data Instr
| DROP {-# UNPACK #-} !Int
| JUMP {-# UNPACK #-} !CodeLabel
| FAIL
| PUSH_ACCUM Literal
| POP_ACCUM
| ADD
data IVal
@@ -71,6 +73,8 @@ ppInstr (TUCK v n ) = text "TUCK " <+> ppIVal v <+> int n
ppInstr (DROP n ) = text "DROP " <+> int n
ppInstr (JUMP l ) = text "JUMP " <+> ppLabel l
ppInstr (FAIL ) = text "FAIL"
ppInstr (PUSH_ACCUM lit) = text "PUSH_ACCUM " <+> ppLit lit
ppInstr (POP_ACCUM ) = text "POP_ACCUM"
ppInstr (ADD ) = text "ADD"
ppIVal (HEAP n) = text "hp" <> parens (int n)