Skip to content

Repository files navigation

Elf

Elf is a small, bytecode-interpreted scripting language designed to complement C. It combines familiar control flow and zero-based indexing with table-centered data, closures, and a compact native embedding API.

Elf is currently 0.2.0-dev. The language is useful in my own projects, but its syntax, API, and module model are still evolving. It should be treated as experimental rather than production-ready.

numbers := {10, 20, 30}
make_adder := fun(base) {
ret fun(value) {
ret base + value
}
}
add_ten := make_adder(10)
for number := numbers[...] ? {
print(add_ten(number))
}

Why Elf?

C remains the host language. Elf handles the parts of a native program that benefit from dynamic values and short iteration cycles: configuration, build descriptions, automation, strings, and nested data.

The project currently provides:

  • a lexer and parser with source-located diagnostics;
  • AST-to-IR lowering and a bytecode backend;
  • a slot-based virtual machine with first-class functions and closures;
  • one table representation for array, map, and record-like data;
  • a stack-based C API for embedding and native functions; and
  • optional filesystem, path, process, environment, serialization, random, and time libraries.

Bob uses Elf as its build-description language, and Orbiter uses Elf programs for its build and game-library configuration.

Documentation

Building

The supported build environment is Windows x64. You need:

  • Git;
  • clang-cl; and
  • Microsoft's lib.exe librarian.

Clone the repository with its platform-layer submodule:

git clone --recursive https://github.com/MicroRJ/elf.git
cd elf

If the repository is already cloned, initialize the submodule with:

git submodule update --init --recursive

The repository includes a Windows x64 Bob bootstrap executable, so Bob does not need to be installed separately.

build.bat build
build.bat test

Additional entries build the static libraries or run optimized benchmarks:

build.bat lib
build.bat benchmark

Build products are written beneath build/. Passing no entry to build.bat uses Bob's default entry.

Repository layout

  • include/ — public C headers
  • src/compiler/ — lexer, parser, AST, IR, and bytecode generation
  • src/core/ — runtime values, tables, strings, VM, GC, and core libraries
  • src/batteries/ — optional host-facing libraries
  • test/ — C unit tests and end-to-end Elf programs
  • tools/ — runner, bytecode inspector, and benchmarks

License

Elf is available under the MIT License.

About

Small bytecode-interpreted language that gives C programs a familiar, table-centered layer for dynamic data and automation.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages