Checking and running
Before you build a native binary you usually check the code,
and often run it on the reference interpreter. beansc also exposes each
compiler stage so you can see what it produced.
beansc check
Section titled “beansc check”Type-checks one file without building anything.
beansc check app.b- On success it prints
<file>: ok. - On failure it prints errors as
file:line:col: error: ...and exits 1.
check accepts --target, --cpu, --features, and --runtime, so you can
check that code is valid for a specific target and runtime profile without
building. A capability a runtime profile lacks is refused here, at check time,
by name. See targets.
beansc run
Section titled “beansc run”Checks the file and then runs it on the reference interpreter. No native build happens.
beansc run app.bForward arguments to your program after --:
beansc run app.b -- --verbose input.txtIf the program panics on the interpreter, run exits 3. See Exit codes and
troubleshooting.
Inspecting the stages
Section titled “Inspecting the stages”These commands dump one stage of the compiler. They are for understanding and debugging, not for a normal workflow.
| Command | What it prints |
|---|---|
beansc lex <file.b>... | The token stream. |
beansc parse <file.b>... | The parsed AST. |
beansc mir <file.b> | The checked, ownership-planned MIR. |
beansc llvm <file.b> | The LLVM IR that native builds use. |
beansc parse app.bbeansc mir app.bbeansc llvm app.blex and parse take one or more files. mir and llvm take one file.