@@ -65,40 +65,47 @@ Programs are represented internally using a series of increasingly lower-level d
6565
6666## Project Structure
6767
68- ```
69- .
70- ├── app/ # Application entry point
71- │ └── Main.hs
72- ├── bin/ # Binary outputs
73- ├── lib/ # Main library code
74- │ ├── Halcyon.hs # Library entry point
75- │ └── Halcyon/ # Core modules
76- │ ├── Backend/ # Code generation and emission
77- │ │ ├── Codegen.hs # TACKY to Assembly conversion
78- │ │ ├── Emit.hs # Assembly to text output
79- │ │ └── ReplacePseudos.hs # Register/stack allocation
80- │ ├── Core/ # Core data types and utilities
81- │ │ ├── Assembly.hs # Assembly representation
82- │ │ ├── Ast.hs # C language AST
83- │ │ ├── Monad.hs # Compiler monad stack
84- │ │ ├── Settings.hs # Compiler settings and types
85- │ │ ├── Tacky.hs # TACKY IR definition
86- │ │ └── TackyGen.hs # AST to TACKY transformation
87- │ ├── Driver/ # Compiler driver
88- │ │ ├── Cli.hs # Command line interface
89- │ │ └── Pipeline.hs # Compilation pipeline
90- │ └── Frontend/ # Parsing and analysis
91- │ ├── Lexer.hs # Lexical analysis
92- │ ├── Parse.hs # Parsing
93- │ └── Tokens.hs # Token definitions
94- ├── test/ # Test suite
95- │ └── Main.hs
96- ├── CHANGELOG.md # Version history
97- ├── LICENSE # Project license
98- ├── README.md # Project documentation
99- ├── flake.nix # Nix build configuration
100- └── halcyon.cabal # Cabal build configuration
101- ```
68+ ```
69+ .
70+ ├── app/ # Application entry point
71+ │ └── Main.hs
72+ ├── bin/ # Binary outputs
73+ ├── lib/ # Main library code
74+ │ ├── Halcyon.hs # Library entry point
75+ │ └── Halcyon/ # Core modules
76+ │ ├── Backend/ # Code generation and emission
77+ │ │ ├── Codegen.hs # TACKY to Assembly conversion
78+ │ │ ├── Emit.hs # Assembly to text output
79+ │ │ └── ReplacePseudos.hs # Register/stack allocation
80+ │ ├── Core/ # Core data types and utilities
81+ │ │ ├── Assembly.hs # Assembly representation
82+ │ │ ├── Ast.hs # C language AST
83+ │ │ ├── Monad.hs # Compiler monad stack
84+ │ │ ├── Settings.hs # Compiler settings and types
85+ │ │ ├── Tacky.hs # TACKY IR definition
86+ │ │ └── TackyGen.hs # AST to TACKY transformation
87+ │ ├── Driver/ # Compiler driver
88+ │ │ ├── Cli.hs # Command line interface
89+ │ │ └── Pipeline.hs # Compilation pipeline
90+ │ └── Frontend/ # Parsing and analysis
91+ │ ├── Lexer.hs # Lexical analysis
92+ │ ├── Parse.hs # Parsing
93+ │ └── Tokens.hs # Token definitions
94+ ├── test/ # Test suite
95+ │ ├── Main.hs
96+ │ └── Test/
97+ │ ├── Lexer.hs
98+ │ ├── Parser.hs
99+ │ ├── Tacky.hs
100+ │ ├── Assembly.hs
101+ │ ├── Pipeline.hs
102+ │ └── Common.hs
103+ ├── CHANGELOG.md # Version history
104+ ├── LICENSE # Project license
105+ ├── README.md # Project documentation
106+ ├── flake.nix # Nix build configuration
107+ └── halcyon.cabal # Cabal build configuration
108+ ```
102109
103110### Architecture
104111
@@ -147,6 +154,37 @@ cabal run halcyon -- input.c
147154cabal run halcyon -- --lex input.c
148155```
149156
157+ ## Testing
158+
159+ Halcyon uses Hspec and Tasty for its test suite. The tests cover all stages of compilation:
160+
161+ ``` bash
162+ # Run all tests
163+ cabal test
164+
165+ # Run tests with output
166+ cabal test --test-show-details=direct
167+
168+ # Run a specific test module
169+ cabal test --test-pattern " Lexer"
170+ ```
171+
172+ The test suite includes:
173+
174+ - Unit tests for each compiler stage
175+ - Integration tests for the full pipeline
176+ - Helper utilities for building test cases
177+
178+ Tests are organized by compiler stage in ` test/Test/ ` :
179+
180+ - ` Lexer.hs ` : Token generation
181+ - ` Parser.hs ` : AST construction
182+ - ` Tacky.hs ` : TACKY IR generation
183+ - ` Assembly.hs ` : Assembly generation
184+ - ` Pipeline.hs ` : Full compilation pipeline
185+ - ` Common.hs ` : Shared test utilities
186+
187+
150188## External Dependencies
151189
152190Halcyon relies on the following system tools:
@@ -168,7 +206,7 @@ The compiler provides detailed error reporting for:
168206
169207### The Basics
170208- [x] A minimal compiler
171- - [ ] Unary operators
209+ - [x ] Unary operators
172210- [ ] Binary operators
173211- [ ] Logical and relational operators
174212- [ ] Local variables
0 commit comments