A small, efficient, highly modular interpreted scripting language built around typed source code, an in-memory module image, and a deterministic VM runtime.
Galfus Script is a programming language validating a compact, modular, VM-first scripting model. The compiler pipeline and VM interpreter are fully implemented and verified.
- Status
- Core Features
- Memory Philosophy
- Repository Layout
- Virtual Standard Library
- Running and Testing Locally
- Design Goals
- Name Inspiration
- License
The entire core execution pipeline is complete. You can parse, typecheck, compile, and run Galfus Script projects using the local VM runner.
.gfs Source Files (Workspace)
└── Lexer & AST Parser
└── Resolver (Scope & Name Resolution)
└── Type Checker & Semantic Analyzer
└── Ownership Check
└── MIR Lowering (Structured IR)
└── Bytecode Emitter
└── Galfus Module Image (in-memory)
└── VM Interpreter ExecutionGalfus Script implements a robust set of modern language features:
- Type Safety: Fully typed syntax with static type inference, validation of assignments, function calls, member accesses, and expression statements.
- Encapsulated Builtins: Strictly prevents user projects from referencing or declaring
__builtin_*compiler intrinsics directly. These are visible only inside compiler-trusted builtin scopes. - Structs: Rich struct declarations supporting inline initialization, member field access, and typed layouts.
- Dynamic Array Spreads: Array literal spread operators (
[...arr1, ...arr2]) computed dynamically at runtime using customLenandCopyArrayVM instructions. - Control Flow: Conditionals (
if/else), loop jumps, and comparison operators. - Workspace Linking: Cross-module resolution supporting local file imports, named imports, and exported declarations across multiple files.
- Deterministic Memory: Implementation of the custom anchor/edge ownership graph model.
Galfus Script does not rely on a traditional global garbage collector or manual raw memory management. Instead, it utilizes an ownership model built on:
- Anchors: Roots that preserve value lifetime.
- Edges: Hard references connecting reachable values.
- Weak Observers: Non-owning references that are safely invalidated when the target value is released.
Values live as long as they are reachable from anchors through edges. When anchors or edges are removed, the affected graph fragments are released deterministically and cycle-safely at runtime.
Galfus Script is structured as a cargo workspace containing the following crates:
galfus-script/
├── crates/
│ ├── galfus-core/ # Shared IDs, diagnostics, spans, and primitive metadata
│ ├── galfus-frontend/ # Lexer, parser, resolver, checker, and semantic validation
│ ├── galfus-ir/ # MIR representation and VM lowering code
│ ├── galfus-image/ # Bytecode format, validation, and in-memory module image layouts
│ ├── galfus-runtime/ # Concurrency runtime, threads, loader, and registry
│ ├── galfus-vm/ # Virtual Machine interpreter and ownership graph engine
│ ├── galfus-jit/ # Just-in-Time compilation engine skeleton
│ ├── galfus-target/ # Low-level target capabilities provider interface
│ ├── galfus-builtins/ # Standard library builtins and rich_builtins files
│ ├── galfus-runner/ # Workspace compilation pipeline and linker
│ └── galfus-cli/ # CLI interface (Command Line Interface)
└── examples/
└── project/ # Sample workspace project with local main.gfs and configA minimal virtual standard library is available to user scripts, including:
Offers basic console input/output interface:
fn print(text: [u8]): null: Output a slice of u8 characters directly to the standard output.
Ensure you have the latest Rust toolchain installed:
rustup updateCompile the workspace and CLI runner:
cargo buildExecute the sample workspace containing structures, array spreads, and control flow:
cargo run -- run examples/projectExpected output:
Hello Galfus!
Idade maior que 20
Program exited successfully with value: NullCheck the syntax and type checks of a single file:
cargo run -- check examples/project/src/main.gfsValidate type-safety and semantics across the entire workspace directory:
cargo run -- check-workspace examples/projectVisualize AST nodes, scopes, references, and symbol tables:
cargo run -- graph examples/project/src/main.gfsRun all unit and integration tests across the workspace:
cargo test --workspaceEnsure clippy checks and formattings are strictly clean:
cargo clippy --workspace --all-targets
cargo fmt --checkGalfus Script is designed from the ground up to be:
- VM-First: Bytecode and interpreter structures dictate the design, making the VM highly portable.
- Host-Friendly: Designed to easily embed in larger native applications (like game engines or databases).
- Deterministic: Standardized memory behavior, integer arithmetic, and strict execution paths.
- Explicit: Avoids magic conventions; imports, exports, and structures must be declared explicitly.
The name Galfus comes from Galafus, a figure from Pernambuco folklore associated with will-o'-the-wisp phenomena. The wandering flame represents a runtime that is:
- Small & Portable
- Present where needed
- Lightweight by default
- Able to float across hosts and environments
MIT
