The Lispex VM runs bytecode that Native compiles from a rule and checks before running it.
Here you build a heading placement rule into a Core IR file, compile that file to bytecode, and run it with the input 1 to get next-page.
You will also tell the compiled files apart from the inspection and comparison reports.
Use the Native CLI.
Prepare the source and input
Save the complete rule as heading-core.lspx.
(define (place-heading lines-left)
(if (< lines-left 2) 'next-page 'keep))
(place-heading input)The rule returns next-page when fewer than two lines remain below the heading and keep otherwise.
Save the input value as request.lspx.
1The command that runs the bytecode supplies this value to input.
Core IR and bytecode record the requirement as explicit-input.
Build the Core IR file
Core IR is the intermediate representation the compiler works from. It records which variable each name refers to before execution.
lispex core-ir build --source heading-core.lspx --out heading-core.lpxirThe command creates heading-core.lpxir, prints a JSON build report, and exits 0.
These fields are an excerpt from the report.
{
"authority": "integrity-only",
"core_ir_build": "lispex.core-ir-build/v1",
"execution": "not-run"
}The report also contains source and file identifiers, the language profile, and table counts.
The compiler writes the lispex.core-ir/v1 file separately from this report.
Use a new destination path. If the file already exists, the command exits 3 and leaves that file unchanged.
Check the Core IR file
lispex core-ir inspect --ir heading-core.lpxir
lispex core-ir validate --ir heading-core.lpxirBoth commands exit 0 and print JSON.
inspect lists each name, the input requirement, and each top-level expression with its line and column.
Read the names and source positions in the Core IR Reference explains these fields for this file.
The validation report contains core_ir_validation: "lispex.core-ir-validation/v1" and valid: true.
None of the three Core IR commands runs the rule.
The build and inspection reports show execution: "not-run" and authority: "integrity-only", so they describe the file and its integrity.
Validation checks the size and count limits, the JSON shape, and the schema, profile, and builtin registry identifiers. It also checks source positions, references, and tail-call positions. It checks captures too, which are outer variable cells used by a function. The reader accepts one prescribed byte representation and rejects a file whose field order or whitespace has changed.
To use standard streams, set --source - or --out -.
With --out -, stdout contains only Core IR bytes and diagnostics go to stderr.
Save those bytes directly, without adding a JSON report or changing their encoding.
Compile the file to bytecode
lispex bytecode build --ir heading-core.lpxir --out heading-core.lpxbcThe command reads heading-core.lpxir, writes heading-core.lpxbc, and exits 0.
Its JSON report has bytecode_build: "lispex.bytecode-build/v1" and execution: "not-run".
An existing destination file makes the command exit 3.
Inspect and validate
lispex bytecode inspect --bytecode heading-core.lpxbc
lispex bytecode validate --bytecode heading-core.lpxbcBoth commands exit 0. inspect prints a JSON report containing the following values.
| Report field | Value for this example |
|---|---|
artifact.schema | lispex.bytecode/v1 |
artifact.counts.instructions | 22 |
artifact.counts.roots | 2 |
requirements | ["explicit-input"] |
source_map_coverage.complete | true |
execution | not-run |
The report also lists source, Core IR, and bytecode identifiers, instruction counts by kind, and source positions.
All 22 instructions have a source position.
validate prints a report with bytecode_validation: "lispex.bytecode-validation/v1" and valid: true.
Run with the input
lispex bytecode run --bytecode heading-core.lpxbc --input request.lspxnext-pageThe command exits 0. One remaining line is less than two, so the result is next-page.
Native validates the entire bytecode file before creating VM state or using the input.
| File or output | Used by |
|---|---|
heading-core.lspx | core-ir build |
heading-core.lpxir | Bytecode compiler |
heading-core.lpxbc | VM |
request.lspx | Input reader, which reads exactly one datum |
| Build, inspection, and validation JSON | People and automation |
next-page on stdout | Caller receiving the program result |
For this example, omitting --input produces E300 for the unbound variable input and exits 1.
Supplying input to bytecode with no input requirement exits 2.
Lispex Bytecode and VM Reference lists the verification rules and limits.
A single standard-input stream can carry either bytecode or the input value. This command exits 2 and prints the diagnostic below to stderr.
lispex bytecode run --bytecode - --input -lispex bytecode run: bytecode and input cannot both read stdinUse a named file for one of them.
Run directly from source
For source execution and engine comparison, save this self-contained variant as rule.lspx.
It supplies 1 inside the program and prints the decision with display and newline.
(define (place-heading lines-left)
(if (< lines-left 2) 'next-page 'keep))
(display (place-heading 1))
(newline)lispex run --backend rust --engine vm rule.lspx
lispex run --backend rust --engine tree rule.lspxEach command prints next-page followed by a newline and exits 0.
tree is the default Lispex engine.
vm compiles and verifies the program in memory before execution.
An explicit vm selection keeps compilation, verification, resource, and execution failures on that engine.
It does not retry through tree.
The --engine option works only with --backend rust.
Combining it with an external backend registry is a usage error and exits 2. See Lispex Interpreter and Lispex VM for current execution methods.
Read an engine comparison
lispex compare-engines --receipt tree-vm.json rule.lspxNative creates tree-vm.json, prints this summary, and exits 0.
{
"all_agree": true,
"receipt": "tree-vm.json",
"schema": "lispex.compare-engines-summary/v1",
"semantic_mismatch_axes": []
}Both engines record next-page\n in stdout and complete successfully.
all_agree: true means the checked semantic results agree.
The empty semantic_mismatch_axes array lists no differences.
Open tree-vm.json to read observations.tree, observations.vm, and semantic_mismatch_axes.
The report also records source, Core IR, and bytecode identifiers, VM resource measurements, and fallback counts.
Native writes the complete report to a new path in one step.
If tree-vm.json already exists, the command exits 3 and leaves it unchanged.
This JSON is a comparison report. Pass the .lpxbc file to the VM.
Continue with Lispex Vouch
Lispex Bytecode and VM Reference describes the verifier checks and the Lispex VM comparison. Native can also produce a Meaning Graph from Core IR. Core IR Reference lists those commands and formats.
Lispex Vouch accepts source in csk.checked-profile/v1 for its compiled container.
The heading placement source above does not follow that profile, and vouch compiled build rejects it with exit 1.
Follow the separate Vouch example in Lispex Bytecode and VM Reference to prepare a compatible source and container.