Guji is a statically typed, compiled, functional-first language with first-class text processing. Regex literals and PEG grammars are language features rather than library additions.
This repository contains the Guji-written compiler and interpreter, their maintained C runtime, the Perl conformance harness, language fixtures, and the language specification. It intentionally does not contain the retired Go implementation.
Guji is under active development. guji-spec.md is the
language definition.
Building the native tools requires Bash, a C compiler available as cc,
sha256sum, and standard Unix utilities. The conformance harness additionally requires Perl 5 and uses
only core Perl modules.
The current build and test scripts are exercised on Linux x86-64.
From the repository root:
bash selfhost/build_toolchain.shThis creates the following local artifacts under dist/:
guji— interpreterguji2c— compiler launcherguji2c.bin— self-hosted compiler
The checked-in generated C seed under bootstrap/ is used only to enter the
self-hosting chain. The build verifies its recorded SHA-256 digest and requires
the reproduced compiler generations to match.
Interpret a source file:
./dist/guji program.gujiCompile a source file to a native executable:
./dist/guji2c program.guji program selfhost/rt/runtime_prologue.c
./programThe compiler emits C and invokes the system C compiler.
sub main(): Int {
$name = "world"
print("hello, $name")
@nums = [1, 2, 3, 4, 5]
$even = @nums.filter({ $_ % 2 == 0 }).map({ $_ * 2 })
print("sum: { $even.sum() }")
0
}
Output:
hello, world
sum: 12
The harness tests do not require a built Guji toolchain:
prove -v conform/tAfter building Guji, fixtures can be checked against both the compiler and interpreter:
GUJI=dist/guji \
GUJI2C=dist/guji2c \
GUJI_RUNTIME=selfhost/rt/runtime_prologue.c \
conform/gujiconform --engine both conform/fixtures| Path | Contents |
|---|---|
selfhost/lexer.guji |
Shared front end, evaluator, and compiler implementation |
selfhost/compile_driver.guji |
Native compiler entry point |
selfhost/eval_driver.guji |
Interpreter entry point |
selfhost/rt/ |
Maintained C runtime sources |
bootstrap/ |
Digest-pinned generated C bootstrap seed |
conform/ |
Perl conformance harness and fixtures |
tests/ |
Guji programs and expected outputs |
guji-spec.md |
Language specification |
Guji was created by Toby.
See LICENSE-APACHE and LICENSE-MIT.