This guide is for coding agents working in this repository.
Baa (باء) is an Arabic-first compiled systems language written in C11 (GNU11).
Pipeline: Lexer -> Parser -> Semantic Analysis -> IR -> Optimizer -> Backend (ISel/RegAlloc/Emit) -> host GCC/Clang link
Targets:
x86_64-windows(COFF + Windows x64 ABI)x86_64-linux(ELF + SystemV AMD64 ABI)
- Compiler sources:
src/*.c - Public declarations:
src/baa.h - Integration tests:
tests/integration/**/*.baa - Negative tests:
tests/neg/*.baa - Stress tests:
tests/stress/*.baa - Keep docs synchronized with behavior changes:
README.mddocs/LANGUAGE.mdROADMAP.mdCHANGELOG.md
cmake -B build -G "MinGW Makefiles"
cmake --build build
cmake --build build --clean-first
cmake --build build --verbosecmake -B build-linux -DCMAKE_BUILD_TYPE=Release
cmake --build build-linux -j
./build-linux/baa --versionBuild notes:
- If you add a new source file, update
SOURCESinCMakeLists.txt. src/updater.cis Windows-only; non-Windows builds usesrc/updater_stub.c.- Warnings options:
BAA_ENABLE_WARNINGS(default ON)BAA_WARNINGS_AS_ERRORS(default OFF)
There is no separate linter; use a warning-clean build.
cmake -B build -G "MinGW Makefiles" -DBAA_WARNINGS_AS_ERRORS=ON
cmake --build buildcmake -B build-linux -DCMAKE_BUILD_TYPE=Release -DBAA_WARNINGS_AS_ERRORS=ON
cmake --build build-linux -jpython scripts/qa_run.py --mode quick
python scripts/qa_run.py --mode full
python scripts/qa_run.py --mode stressMode summary:
quick: integration suite (tests/test.py)full: quick + regression/negative + verify smoke + multifile smokestress: full + stress suite + fuzz-lite
python tests/test.py
python tests/regress.pyWindows:
build\baa.exe -O2 --verify tests\integration\backend\backend_test.baa -o build\backend_test.exe
build\backend_test.exeLinux:
./build-linux/baa -O2 --verify tests/integration/backend/backend_test.baa -o build-linux/backend_test
./build-linux/backend_test./build-linux/baa -O2 --verify tests/integration/ir/ir_test.baa -o build-linux/ir_testWindows:
build\baa.exe -O1 tests\neg\semantic_deref_non_pointer.baa -o build\neg_tmp.exeLinux:
./build-linux/baa -O1 tests/neg/semantic_deref_non_pointer.baa -o build-linux/neg_tmpThen confirm stderr includes the test // EXPECT: marker text.
// RUN:contract (expect-pass,expect-fail,runtime,compile-only,skip)// EXPECT:required diagnostic substring(s)// FLAGS:extra flags for that specific test file
- Optimization:
-O0,-O1,-O2 - Validation:
--verify,--verify-ir,--verify-ssa,--verify-gate - Target:
--target=x86_64-windows|x86_64-linux - Output:
-S(assembly),-c(object) - Code model:
-fPIC,-fPIE,-mcmodel=small - Stack protector (ELF):
-fstack-protector,-fstack-protector-allCross-target note: currently supported for assembly generation (-S) only.
- C11 + GNU extensions (
-std=gnu11) - 4-space indentation, no tabs
- K&R brace style
- Keep lines near 100 columns when practical
- Prefer small focused helpers over very large functions
- Write comments and Doxygen blocks in Arabic (UTF-8)
- Keep user-facing diagnostics Arabic-first Example:
/**
* @brief وصف مختصر
*/- Own module header first (if present)
- Then project headers (
"...") - Then system headers (
<...>) - Keep include blocks stable and minimal
- Functions/local vars:
snake_case(often module-prefixed) - Types/typedef structs:
PascalCase - Enums/macros/constants:
UPPER_SNAKE_CASE - Filenames:
snake_case.c/snake_case.h
- Use fixed-width integers (
int64_t,uint32_t, etc.) for width-sensitive logic - Use
boolfor predicates - Be explicit about signed/unsigned behavior and casts
- Keep pointer-type metadata consistent across parser/semantic/IR
- Validate pointers before dereference
- Prefer early returns for invalid states
- Do not silently swallow parser/semantic/IR errors
- Use centralized diagnostics APIs where applicable:
error_report(...)warning_report(...)
- Free what you allocate (
malloc,strdup,reallocpaths) - Preserve existing ownership patterns and cleanup flow
- IR core uses arena allocation; avoid ad-hoc frees of arena-owned objects
- Assembly syntax is AT&T (GAS)
- Special machine vregs:
-1=> RBP-2=> ABI return register (usually RAX)-3=> RSP-10..=> ABI integer argument registers (target-dependent)
- Before large changes, read
ROADMAP.mdanddocs/INTERNALS.md - Keep docs/changelog/roadmap synchronized with behavior changes
- Add/update tests with each semantic/backend feature change
- Prefer minimal, surgical edits; avoid unrelated refactors
- Never revert unrelated local changes in a dirty worktree
Checked paths:
.cursor/rules/.cursorrules.github/copilot-instructions.mdCurrent status: no Cursor/Copilot rule files were found in this repository.