Go to file
2026-01-13 10:39:08 +09:00
test add import feature 2026-01-13 10:32:47 +09:00
vm add import feature 2026-01-13 10:32:47 +09:00
.gitignore Initial commit 2024-11-03 06:23:29 +09:00
asm.c can run fibonacci sequence, nqueen 2024-11-04 02:11:36 +09:00
assert.c add import feature 2026-01-13 10:32:47 +09:00
com.c can run fibonacci sequence, nqueen 2024-11-04 02:11:36 +09:00
dat.h add || && 2024-11-03 16:28:52 +09:00
decl.c first commit 2024-11-03 06:24:26 +09:00
dis.c can run fibonacci sequence, nqueen 2024-11-04 02:11:36 +09:00
exports.c add import feature 2026-01-13 10:32:47 +09:00
file.c can run fibonacci sequence, nqueen 2024-11-04 02:11:36 +09:00
fn.h can run fibonacci sequence, nqueen 2024-11-04 02:11:36 +09:00
gen.c can run fibonacci sequence, nqueen 2024-11-04 02:11:36 +09:00
isa.h can run fibonacci sequence, nqueen 2024-11-04 02:11:36 +09:00
lex.c can run fibonacci sequence, nqueen 2024-11-04 02:11:36 +09:00
main.c can run fibonacci sequence, nqueen 2024-11-04 02:11:36 +09:00
makefile can run fibonacci sequence, nqueen 2024-11-04 02:11:36 +09:00
node.c first commit 2024-11-03 06:24:26 +09:00
parse.c add import feature 2026-01-13 10:32:47 +09:00
README.md update readme 2026-01-13 10:39:08 +09:00
test.sh update readme 2026-01-13 10:39:08 +09:00
type.c first commit 2024-11-03 06:24:26 +09:00
yo.h first commit 2024-11-03 06:24:26 +09:00

yo

A bytecode compiler and stack-based VM for a statically-typed language.

Inspired by Inferno OS's Limbo language and Dis virtual machine.

Features

  • Static type system: int, bool, struct, array, slice, pointer
  • Go/Limbo-style syntax: fn, :=, for, if
  • Recursion, slicing, struct literals
  • Module system with package, import, export

Build

make

Run

Compile a single package:

./com ./test/fib
./vm/run obj

Test

Run the full test with package imports:

./com ./test/fib && cp exported obj ./test/fib/
./com ./test/nqueen && cp exported obj ./test/nqueen/
./com ./test && ./vm/run obj
# result 147

Example

// test/fib/fib.yo
package fib

export fn fib(n int) int {
    if n <= 1 { return n; };
    return fib(n-1) + fib(n-2);
};
// test/main.yo
package main

import "./test/fib"
import "./test/nqueen"

fn main() int {
    return fib.fib(10) + nqueen.solve(8);
};

See test/ for full examples including N-Queens solver with slices.

Architecture

Five-stage compilation pipeline:

VM execution:

  • vm/vm.c: stack-based VM with activation frames
  • vm/dec.c: bytecode decoder

Files

lex.c       lexical analyzer
parse.c     syntax parser
node.c      AST node construction
type.c      type system
decl.c      declaration and scope management
gen.c       instruction generation
com.c       expression compiler
asm.c       assembly output
dis.c       bytecode emitter
vm/         virtual machine

References