compiler 0.0.2-preview.1
The Zena self-hosted compiler
compiler#
The Zena compiler, written in Zena. It parses, type-checks, and compiles Zena source code to WebAssembly (Wasm GC) and WebAssembly Text (WAT).
Usage#
Parsing a Single File#
Use compiler/parser to parse Zena source text into an AST (Module):
import { parse } from 'compiler/parser';
let ast = parse('export let answer = 42;', 'example.zena');
Loading and Checking a Program#
Use compiler (createCompiler and checkCompilation) with a CompilerHost to resolve imports across a module graph and type-check a program:
import {
createCompiler, checkCompilation, buildStdlibConfig
} from 'compiler';
import { FsCompilerHost } from 'compiler/fs-host';
let stdlibRoot = '/stdlib';
let host = new FsCompilerHost(stdlibRoot);
let packages = buildStdlibConfig(stdlibRoot, 'host');
let compiler = createCompiler(host, {
stdlibRoot,
packages,
});
let result = await compiler.compile({
entry: '/workspace/main.zena',
target: 'host',
});
let checked = checkCompilation(result);
Compiling a File to WebAssembly#
Use compiler/compile-file to compile an entry file on disk to a .wasm or .wat output file:
import { compileFile } from 'compiler/compile-file';
let ok = await compileFile({
entry: 'src/main.zena',
outPath: 'out/main.wasm',
stdlibRoot: '/stdlib',
});
Libraries#
compiler/compiler/compiler— compiler entry point (Compiler,createCompiler,checkCompilation,ProgramCheckResult)compiler/compile-file— end-to-end file compilation (compileFile,CompileFileOptions)compiler/tokenizer— lexer and token definitions (tokenize,Token,TokenType)compiler/parser— recursive-descent parser (parse,Parser)compiler/ast— AST node definitions (Node,Module,Statement,Expression,TypeAnnotation)compiler/visitor— AST traversal helpers (walk,Visitor)compiler/scope— lexical scope and symbol resolution (ScopeBuilder,ScopeResult,Symbol)compiler/checker— static type checker (checkModule,CheckResult)compiler/semantic-model— semantic queries over a checked module (SemanticModel)compiler/types— compiler type representations (Type,ClassType,FunctionType,typeToString)compiler/diagnostics— compiler diagnostics and source spans (Diagnostic,DiagnosticCode,DiagnosticSeverity,SourceSpan)compiler/package-manifest—zena-package.jsonmanifest and workspace loader (loadWorkspace,loadPackageMap)compiler/module-resolver— package and relative module specifier resolution (ModuleResolver,PackageConfig)compiler/library-loader— module graph loader (LibraryLoader,CompilerHost,SourceFile)compiler/codegen/binary-generator— WebAssembly GC binary emitter (BinaryGenerator)compiler/codegen/wat-generator— WebAssembly Text (WAT) emitter (WatGenerator)
License#
MIT
| Name | Size |
|---|---|
| CLAUDE.md | 132 bytes |
| CONTEXT.md | 96.3 KiB |
| async.zena | 106.8 KiB |
| blockmerge.zena | 18.9 KiB |
| builder.zena | 17.4 KiB |
| census.zena | 8.5 KiB |
| cfg.zena | 9.7 KiB |
| component-adapters.zena | 25.2 KiB |
| contracts.zena | 2.0 KiB |
| control-flow.zena | 165.7 KiB |
| dce.zena | 4.4 KiB |
| deadfields.zena | 11.1 KiB |
| deadslots.zena | 11.2 KiB |
| devirt.zena | 9.7 KiB |
| emit.zena | 96.6 KiB |
| equality.zena | 65.0 KiB |
| escape.zena | 8.2 KiB |
| existential.zena | 9.2 KiB |
| explode.zena | 66.6 KiB |
| fold.zena | 10.7 KiB |
| generators.zena | 62.6 KiB |
| gvn.zena | 6.6 KiB |
| harvest.zena | 7.7 KiB |
| inline.zena | 29.9 KiB |
| intrinsics.zena | 34.5 KiB |
| ir.zena | 56.8 KiB |
| licm.zena | 9.4 KiB |
| lowering-context.zena | 91.3 KiB |
| lowering.zena | 533.8 KiB |
| operators.zena | 47.4 KiB |
| patterns.zena | 43.3 KiB |
| printer.zena | 10.0 KiB |
| propagate.zena | 37.7 KiB |
| scaffold.zena | 16.5 KiB |
| sccp.zena | 14.8 KiB |
| simplify.zena | 21.7 KiB |
| specialize.zena | 10.4 KiB |
| sroa.zena | 10.5 KiB |
| template.zena | 51.8 KiB |
| templates.zena | 23.1 KiB |
| thread.zena | 12.4 KiB |
| typeprune.zena | 6.3 KiB |
| verifier.zena | 10.1 KiB |
- zena-lang:wit-parser wit-parser.zena-lang.pkg.zena-lang.dev ~0.0.1-preview.1
| Version | Published | Dependencies | Approved by |
|---|---|---|---|
| 0.0.2-preview.1 | 2026-11-19 |
|
|