Skip to main content

Crate jzero

Crate jzero 

Source
Expand description

§jzero

A compiler and bytecode VM for Jzero — a small subset of Java.

Jzero supports classes, methods, control flow, basic types (int, double, boolean, String), arrays, string concatenation, and System.out.println.

§Quick start

use jzero::Compiler;

let output = Compiler::new()
    .source("public class hello {
        public static void main(String argv[]) {
            System.out.println(\"hello, jzero!\");
        }
    }")
    .run(&[])
    .unwrap();

assert_eq!(output.stdout, "hello, jzero!\n");

§Pipeline

source code
    → parse_tree()       [jzero-parser]
    → analyze()          [jzero-semantic]
    → generate()         [jzero-codegen]  → TAC IR
    → compile_bytecode() [jzero-codegen]  → .j0 binary
    → run()              [jzero-vm]       → stdout

Structs§

BytecodeOutput
Result of the bytecode compilation step.
CodegenContext
All codegen state that lives outside the AST and symbol table.
CompileOutput
The result of compiling to bytecode without executing.
Compiler
The Jzero compiler.
JzeroError
A Jzero compilation or runtime error.
RunOutput
The result of a full compile + execute run.
SemanticResult
The result of semantic analysis.