Tooling
Compiler — fern
Section titled “Compiler — fern”fern [-target arm64|arm64-darwin|x86-64|wasm] [-o OUTPUT] [--run] FILE.fernfern -fmt [-w | -d] FILE.fernfern -interp FILE.fernfern -replCommon flags
Section titled “Common flags”| Flag | Default | Meaning |
|---|---|---|
-target | arm64 | Backend: arm64, arm64-darwin, x86-64, wasm. |
-o | stdout | Output binary path. Without it, assembly prints to stdout. |
--run | off | Compile + execute the produced binary. Returns its exit code. |
-cc | cc | Linker for native targets (gcc, clang, …). |
-qemu | none | Path to a qemu-* binary for cross-arch execution under --run. |
-fmt | off | Format the source. -w writes back; -d prints a diff. |
-interp | off | Run the AST interpreter (skips codegen entirely). |
Formatter
Section titled “Formatter”fern -fmt rewrites a file to the canonical style: two-space
indent, one statement per line, trailing newline at EOF. Comments
survive the round trip in their original position.
fern -fmt -w foo.fern # rewrite in placefern -fmt -d foo.fern # show the diff insteadThe formatter is idempotent: fern -fmt | fern -fmt produces
identical output.
Language server — fern-lsp
Section titled “Language server — fern-lsp”Speaks LSP over stdin/stdout. Spawn it from any editor with a generic LSP client. Features:
- Diagnostics — parser + type-check errors, routed per-file in multi-module programs.
- Hover — types for variables, parameters, fields, methods, cross-module references.
- Goto-definition — across files in workspace mode.
- Completion — locals, params, top-level decls, variants,
keywords. Triggered on
.and Ctrl/Cmd-Space. - Signature help — function signatures with active-parameter highlighting.
- Inlay hints — inferred types for
var x = …. - Document symbols — outline view (Cmd-Shift-O in VS Code).
- Semantic tokens — type-aware syntax highlighting.
- Find references + rename — workspace-wide, including method calls / struct fields / enum variants.
- Format on save — runs the formatter via
textDocument/formatting.
VS Code extension
Section titled “VS Code extension”Lives at editors/vscode/. Install with:
cd editors/vscodenpm installnpm run compilenpx @vscode/vsce packagecode --install-extension fern-vscode-0.1.0.vsixSet fern.serverPath if fern-lsp isn’t on your $PATH.
fern -repl> var x = 7;> x * 214State persists across lines. Multi-line forms (an if block,
function decl, etc.) are one logical input — the REPL reads until
braces balance.
Running tests
Section titled “Running tests”Fern’s pure-Fern test runner lives in std/test.
Tests are ordinary .fern files — run them with -interp (or
compile + execute the produced binary):
fern -interp my_test.fern # AST interpreterfern my_test.fern -o my_test --run # compile + runOutput is TAP-13. Exit code is 0
when every case passes and 1 on any failure, so any TAP-aware CI
runner (prove, tape, tap-junit) works without further config.
See the Testing tutorial for the authoring shape and assertion catalogue.