git clone https://github.com/jona62/mac.git
cd mac
cmake -S . -B build && cmake --build build
bash tests/run_tests.sh # 69 runtime tests
python3 tests/analyzer/run_analyzer_tests.py # 41 analyzer testsRequires CMake 3.20+ and a C++23 compiler. See the language reference for full documentation (cd docs/reference && mdbook serve).
src/— C++ source files (entry point inmain.cpp)include/— C++ headers (most implementation lives here due to templates)stdlib/prelude.mac— Standard library loaded before user codetests/— Runtime tests (run_tests.sh) and analyzer tests (analyzer/)mac-lang/— VS Code extension + LSP (thin adapter overmac --analyze)webapp/— Web GIF studio (Python)docs/reference/— mdBook language reference
Tests are .mac files with // expect: annotations:
print 2 + 2; // expect: 4
print "hi" |> upper; // expect: HI
print type(@blank "x"); // expect: instance
Place tests in tests/<category>/.
Run: bash tests/run_tests.sh
Python tests that verify --analyze JSON output (symbols, references, diagnostics, type inference, etc.). Includes snapshot regression tests.
Run: python3 tests/analyzer/run_analyzer_tests.py
Update snapshots after intentional changes: python3 tests/analyzer/run_analyzer_tests.py --update
-
Define in
include/NativeRegistry.h:{"my_func", NativeVisibility::Public, "fun(1)", "Description.", {{{"arg1"}, "ReturnType", "Overload description."}}, [] { return std::make_shared<callable::MyFunction>(); }}, -
Implement the class in
include/NativeFunctions.hextendingMacCallable. -
Write a test in
tests/to verify.
The analyzer and LSP pick up the function automatically from NativeRegistry.h.
-
Implement the pixel transform in
include/MemeEffects.h:inline void myEffect(unsigned char* pixels, int w, int h, float param) { // process RGBA pixels in-place }
-
Add dispatch in
PartialEffect::call()orDirectEffect::call()inNativeFunctions.h. -
Register in
NativeRegistry.h:{"myEffect", NativeVisibility::Public, "Meme -> Meme", "Description.", {{{"param"}, "Meme -> Meme", "..."}}, [] { return std::make_shared<callable::ParamEffectCreator>("myEffect"); }},
- Add the generator function in
tools/gen_templates.cpp. - Register the name→path mapping in
MacMeme.h'stemplateMap(). - Run
cd tools && ./gen_templatesto regenerate images.
- Create a branch from
main - Make changes
bash tests/run_tests.sh— all runtime tests must passpython3 tests/analyzer/run_analyzer_tests.py— all analyzer tests must passcd mac-lang && npx tsc --noEmit— LSP must typecheck- Commit and open a PR against
main
CI runs runtime + analyzer tests on Ubuntu and macOS, plus LSP typechecking.