Skip to content

Commit f4351e4

Browse files
committed
a
0 parents  commit f4351e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+11982
-0
lines changed

.cursor/rules.mdc

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: true
5+
---
6+
# Cursor AI Rules for CURSED Language Development
7+
8+
The following rules are derived from studying the rust-hosted-langs/book repository, which provides guidance on implementing interpreters in Rust. These rules should be applied when assisting with the CURSED language implementation.
9+
10+
## Memory Management
11+
12+
1. **Use Custom Allocators**: For optimal performance and control, implement custom allocators rather than relying on Rust's standard collections.
13+
- Follow the Sticky Immix pattern for efficient memory management
14+
- Implement bump allocation for fast allocation paths
15+
- Support block-based memory management for better locality
16+
17+
2. **Safe Wrappers Over Unsafe Code**: Always create safe abstractions over unsafe memory operations.
18+
- Encapsulate unsafe pointer operations in safe APIs
19+
- Use proper lifetime annotations to prevent memory errors
20+
- Implement RAII patterns for resource management
21+
22+
3. **Tagged Pointers**: Utilize tagged pointers for efficient memory representation.
23+
- Store type information in unused pointer bits
24+
- Implement proper bit masking operations
25+
- Ensure alignment requirements are met
26+
27+
## Interpreter Design
28+
29+
4. **Bytecode VM Architecture**: Implement a bytecode virtual machine for better performance.
30+
- Design a compact instruction set
31+
- Use efficient instruction dispatch methods
32+
- Consider register vs. stack-based approaches
33+
34+
5. **Multi-Stage Compilation**: Follow a clear pipeline from parsing to execution.
35+
- Lexing → Parsing → AST → Bytecode → Execution
36+
- Keep each stage modular and testable
37+
- Consider adding optimization passes
38+
39+
6. **Error Handling**: Implement robust error handling throughout the compiler and runtime.
40+
- Use Result types consistently
41+
- Provide meaningful error messages with location information
42+
- Support error recovery where appropriate
43+
44+
## Code Organization
45+
46+
7. **Modular Component Design**: Structure code with clear module boundaries.
47+
- Separate the allocator from the interpreter
48+
- Use Rust modules to organize related functionality
49+
- Define clear APIs between components
50+
51+
8. **Testing Strategy**: Implement comprehensive testing at multiple levels.
52+
- Unit tests for individual components
53+
- Integration tests for the full pipeline
54+
- Regression tests for fixed bugs
55+
- Fuzzing for parser robustness
56+
57+
9. **Documentation**: Document code thoroughly, especially for unsafe operations.
58+
- Explain the "why" behind complex algorithms
59+
- Document invariants and assumptions
60+
- Include examples in public API documentation
61+
62+
## Rust-Specific Practices
63+
64+
10. **Unsafe Code Minimization**: Contain unsafe code to the smallest possible scope.
65+
- Use unsafe blocks only when necessary
66+
- Validate all preconditions before unsafe operations
67+
- Document safety requirements extensively
68+
69+
11. **Performance Considerations**: Be mindful of Rust-specific performance patterns.
70+
- Avoid unnecessary allocations and cloning
71+
- Use references instead of owned values where appropriate
72+
- Consider inlining critical paths
73+
74+
12. **Gen Z Slang Consistent Implementation**: Ensure consistency in the translation of Go-like syntax to Gen Z slang.
75+
- Maintain a comprehensive mapping table between Go keywords and CURSED equivalents
76+
- Apply consistent naming conventions throughout the codebase
77+
- Keep slang usage authentic to Gen Z terminology
78+
79+
## Building Process
80+
81+
13. **Use Make for Build Commands**: Always use Make as the primary build interface.
82+
- Use `make build` instead of direct `cargo build` commands
83+
- Use `make test` instead of direct `cargo test` commands
84+
- Keep the Makefile up to date with all necessary build tasks
85+
86+
14. **Maintain Specs**: Keep specs documentation current with implementation.
87+
- Update specs when language features change
88+
- Ensure examples in specs are valid and tested
89+
- Cross-reference specs with implementation
90+
91+
15. **Bootstrapping Process**: Follow the defined bootstrapping stages.
92+
- Stage 0: Environment setup
93+
- Stage 1: Bootstrap compiler in Rust
94+
- Stage 2: Full compiler in CURSED
95+
- Stage 3: Self-compiled compiler
96+
97+
16. **Implementation Status**: As the compiler is implemented
98+
- Study IMPLEMENTATION_STATUS.md to determine next steps
99+
- Update IMPLEMENTATION_STATUS.md when a step is complete
100+
- Use IMPLEMENTATION_STATUS.md to track what you need to do next

.envrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export DIRENV_WARN_TIMEOUT=20s
2+
3+
eval "$(devenv direnvrc)"
4+
5+
use devenv

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/target
2+
3+
# Devenv
4+
.devenv*
5+
devenv.local.nix
6+
7+
# direnv
8+
.direnv
9+
10+
# pre-commit
11+
.pre-commit-config.yaml

0 commit comments

Comments
 (0)