Usage#

eb takes a subcommand:

eb <command> [options] <files>

run

compile and execute

build

compile but do not run

check

lex, parse, and run semantic analysis

repl

interactive session — reserved, not implemented

Commands#

eb run <files> compiles and executes a program. It accepts .eb source files or a pre-compiled .ebc file:

eb run model.eb
eb run model.ebc

eb build <files> [--target <triple>] [--format <fmt>] [-o <output>] compiles without running. If no output file is given, the first input file’s name without its extension is used. Multiple input files compile to a single artifact:

eb build model.eb --format ebc -o model.ebc
eb build common.eb finance.eb main.eb --format ebc -o portfolio.ebc

--format selects ebc (bytecode for the VM) or native. --target sets the target triple for native builds, defaulting to the host.

NOT YET IMPLEMENTED

--format native is the documented default but reports native builds are not yet implemented in this version; use --format ebc and exits. Native and GPU emitters are reserved. The VM with --format ebc is the supported path.

eb check [--lex|--parse] <file> reports errors without compiling or running:

eb check model.eb
eb check --lex model.eb      # stop after lexing; print the token stream
eb check --parse model.eb    # stop after parsing; print the AST

eb repl [file] is reserved. It currently reports repl is not yet implemented in this version.

eb --version (or -V) prints one line and exits 0:

eb 0.4.0 (.ebc format 3)

It takes no other arguments and is not a modifier on a command.

The two numbers are independent and both are reported because they answer different questions. The release version (from Cargo.toml) says which build of the compiler this is. The .ebc format version says which bytecode files it can load: eb run model.ebc rejects any file whose format version differs, since the same opcodes can change meaning between formats. A bugfix release bumps the first and not the second; a change to the serialized layout bumps the second and need not bump the first. Tying them together would force a meaningless release bump on every format change, or — worse — imply compatibility between builds that do not share a format.

Optimization flags#

-O0, -O1, -O2, and -O3 are accepted by run and build, and -O0 is the default.

NOT YET IMPLEMENTED

The level is parsed into the compiler configuration and never read. All four flags currently produce identical output. They are accepted so that build scripts written against them keep working when the optimizer lands.

Output and diagnostics#

Program output goes to stdout. Diagnostics go to stderr in the form:

[Error type], pos [line/col]: [message]

Runtime errors and whole-program errors — a missing run(), for instance — carry no position and omit the pos field:

[Error type]: [message]

The full catalog of messages is in eb-errors.rst.

Exit codes:

0   success
1   runtime error
2   compile error