Skip to content

Commit 0dbca4b

Browse files
committed
chore: prepare v0.3.0 release
1 parent 3abecde commit 0dbca4b

File tree

3 files changed

+37
-23
lines changed

3 files changed

+37
-23
lines changed

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,19 @@
5555
- Added record syntax for multi-field data constructors
5656
- Standardized naming conventions in core types
5757
- Simplified token type names
58-
- Made qualified imports consistent across modules
58+
- Made qualified imports consistent across modules
59+
60+
## 0.3.0.0 -- 2024-11-27
61+
62+
### Added
63+
- Support for binary operators:
64+
- Addition
65+
- Subtraction
66+
- Multiplication
67+
- Division
68+
- Remainder
69+
- Precedence climbing parser for handling operator precedence
70+
- New assembly instructions for binary operations (add, sub, imul, idiv)
71+
- Proper handling of division and remainder with EAX/EDX registers
72+
- Sign extension support using cdq instruction
73+
- Updated instruction fix-up pass for binary operation constraints

README.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,50 +29,49 @@ Programs are represented internally using a series of increasingly lower-level d
2929
1. **Abstract Syntax Tree (AST)**:
3030
```haskell
3131
data Program = Program Function
32-
data Function = Function
33-
{ name :: Text
34-
, body :: Statement
35-
}
32+
data Function = Function Text Statement
3633
data Statement = Return Expr
3734
data Expr
38-
= Constant { value :: Int }
39-
| Unary { operator :: UnaryOp, operand :: Expr }
35+
= Constant Int
36+
| Unary UnaryOp Expr
37+
| Binary BinaryOp Expr Expr
4038
data UnaryOp = Complement | Negate
39+
data BinaryOp = Add | Subtract | Multiply | Divide | Remainder
4140
```
4241

4342
2. **TACKY IR**:
4443
```haskell
4544
data Program = Program Function
46-
data Function = Function
47-
{ name :: Text
48-
, body :: [Instruction]
49-
}
45+
data Function = Function Text [Instruction]
5046
data Instruction
51-
= Return { value :: Val }
52-
| Unary { operator :: UnaryOp, src :: Val, dst :: Val }
47+
= Return Val
48+
| Unary UnaryOp Val Val
49+
| Binary BinaryOp Val Val Val
5350
data Val = Constant Int | Var Text
5451
data UnaryOp = Complement | Negate
52+
data BinaryOp = Add | Subtract | Multiply | Divide | Remainder
5553
```
5654

5755
3. **Assembly AST**:
5856
```haskell
5957
data Program = Program Function
60-
data Function = Function
61-
{ name :: Text
62-
, instructions :: [Instruction]
63-
}
58+
data Function = Function Text [Instruction]
6459
data Instruction
65-
= Mov { src :: Operand, dst :: Operand }
66-
| Unary { operator :: UnaryOp, operand :: Operand }
67-
| AllocateStack { bytes :: Int }
60+
= Mov Operand Operand
61+
| Unary UnaryOp Operand
62+
| Binary BinaryOp Operand Operand
63+
| Idiv Operand
64+
| Cdq
65+
| AllocateStack Int
6866
| Ret
6967
data Operand
7068
= Imm Int
7169
| Register Reg
7270
| Pseudo Text
7371
| Stack Int
7472
data UnaryOp = Neg | Not
75-
data Reg = Ax | R10
73+
data BinaryOp = Add | Sub | Mult
74+
data Reg = Ax | DX | R10 | R11
7675
```
7776

7877

@@ -220,7 +219,7 @@ The compiler provides detailed error reporting for:
220219
### The Basics
221220
- [x] A minimal compiler
222221
- [x] Unary operators
223-
- [ ] Binary operators
222+
- [x] Binary operators
224223
- [ ] Logical and relational operators
225224
- [ ] Local variables
226225
- [ ] if statements and conditional expressions

halcyon.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.0
22
name: halcyon
3-
version: 0.2.2.0
3+
version: 0.3.0.0
44
-- synopsis:
55
-- description:
66
license: BSD-3-Clause

0 commit comments

Comments
 (0)