Skip to content
CodeTeasePublic

About

Compiler for the Vaca programming language

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Vaca compiler 🐄

PUBLIC DEVELOPMENT

CodSpeed

vacac is a handwritten, statically compiled compiler for Vaca 🐮. It parses and checks source in Rust, generates native LLVM object code with Inkwell, then invokes cc to link an ELF executable.

This compiler currently supports Linux only. For Windows/macOS, please use Docker or WSL2.

A CodeTease project.

Requirements

  • Rust and Cargo
  • LLVM 23
  • A C linker available as cc

Quick start

Build with:

cargo build --release

Compile a Vaca source file (the object file is retained next to the executable):

target/release/vacac examples/factorial.vca -o factorial
./factorial

For a quick compile-and-run without leaving build artifacts:

target/release/vacac examples/factorial.vca --run

Run the lexer, parser, and semantic checker without producing build artifacts:

target/release/vacac examples/factorial.vca --check

Write the verified LLVM IR module to a text file without linking an executable:

target/release/vacac examples/factorial.vca --emit-llvm factorial.ll

Select emitted-code optimization with -O0, -O1, -O2, or -O3:

target/release/vacac examples/factorial.vca -O2 -o factorial

The precise non-moving mark/sweep garbage collector is enabled by default. Use --gc=off for the legacy leak-until-exit allocation mode:

target/release/vacac examples/factorial.vca -O3 -o factorial
target/release/vacac examples/factorial.vca --gc=off -O3 -o factorial-legacy

The precise collector uses a non-moving generational nursery and sliced major cycles while preserving pins and raw-pointer addresses; VACA_GC_GENERATIONAL=0 and VACA_GC_INCREMENTAL=0 select the legacy full-major fallback. See Precise garbage collection for thresholds, generation and slice controls, stress testing, std::gc statistics, and native pinning.

Documentation

Start at the documentation index.

  • Using the compiler — build, CLI modes, linker inputs, and output-path safety.
  • Diagnostics — parser recovery and human-readable/JSON error formats.
  • Examples — complete programs to check, compile, and run.
  • Testing — Rust tests, the example runner, and the adversarial corpus.
  • Standard library — prelude Option/Result, std::* modules, strings, vectors, math, I/O, files, environment, time, random, debug helpers, traits, maps, sets, and deques.
  • C FFI — scalar, string, and raw-pointer extern "C" declarations and native linking.
  • Language reference — Vaca types, values, and statements, with links to the rest of the language guide.

Examples

The examples/ directory contains complete programs that can be checked or compiled with vacac:

target/release/vacac examples/enum_match.vca --check
target/release/vacac examples/enum_match.vca -o enum_match
./enum_match

See Examples for the full list, including traits, modules, arrays, structs, closures, and C FFI.

Testing

Run the Rust unit and integration tests with:

cargo test

See Testing for the example runner, the deterministic adversarial corpus, and the precise-GC benchmark harness.

About

Compiler for the Vaca programming language

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages