Contributing — First PR
Contributing — Your First PR
Getting Started
1. Fork and Clone
git clone https://github.com/YOUR_USERNAME/thagore.gitcd thagore2. Set Up Prerequisites
Ensure you have:
- LLVM 21.x — installed and on PATH
- Stage1 seed — downloaded from the latest release
- Python 3.x — for build scripts (optional)
See Prerequisites for detailed installation instructions.
3. Bootstrap the Compiler
# Windowscmd /c scripts\bootstrap.bat
# Linux/macOSbash scripts/bootstrap.sh4. Verify Your Setup
stage2.exe build examples/hello.tg -o hello.exe.\hello.exe# Should output: Hello Self-Hosted World!Making Changes
Source Code Structure
| Directory | Contains |
|---|---|
src/ | Compiler source code (Thagore .tg files) |
lib/ | Standard library modules |
std/ | Core primitives and data structures |
examples/ | Example programs |
tests/ | Test suite |
scripts/ | Build and automation scripts |
docs/ | Documentation |
Development Workflow
-
Create a feature branch:
Terminal window git checkout -b feature/my-change -
Make your changes to the
.tgsource files -
Self-host test — verify the compiler can still compile itself:
Terminal window stage2.exe build src/thagore.tg -o stage2b.exe -
Run tests:
Terminal window stage2.exe test --workspace -
Build sample programs to verify nothing is broken:
Terminal window stage2.exe build examples/hello.tg -o hello.exestage2.exe build examples/fib.tg -o fib.exe
Code Style Guidelines
- Indentation: Use 4 spaces (no tabs)
- Line endings: Unix-style LF (not CRLF)
- File encoding: UTF-8
- Naming conventions:
- Functions:
snake_case—parse_enum_name,validate_source - Structs:
PascalCase—ProgramAstNative,CoreProgram - Constants:
UPPER_SNAKE_CASE(when applicable) - Private/internal functions: prefix with
_—_trim,_next_line_pos
- Functions:
- Comments: Use
#for comments,//is also supported - Function signatures: Always include explicit return type
Example
# Calculate the dot product of two 2D vectorsfunc dot_product(ax: i32, ay: i32, bx: i32, by: i32) -> i32: return ax * bx + ay * by
func _validate_input(n: i32) -> i32: if (n < 0): return 1 return 0Submitting a PR
PR Checklist
Before submitting:
- Code compiles successfully
- Self-host test passes (
stage2 → stage2b) - Existing tests still pass
- New tests added for new functionality
- No C++ fallback introduced
- Code follows style guidelines
CI Requirements
Your PR must pass all three CI pipelines with 3 consecutive green runs:
- ✅ CI — build and test
- ✅ Selfhost Matrix — self-hosting on all platforms
- ✅ Release (dry-run) — release artifact generation
Where to Contribute
Good First Issues
- Add new examples to
examples/ - Improve documentation in
docs/starlight/ - Add test cases to
tests/ - Improve error messages in the compiler
Intermediate
- Add new standard library functions to
lib/ - Improve the autofix engine rules
- Enhance the CLI with new commands
Advanced
- Work on the lowering pipeline
- Implement new language features (tracked by feature counters)
- Optimize the LLVM IR emission
- Port to new platforms