Renderingen-US

Experimental through version 1. Version 0 was alpha. This is the first language release: the interface is relatively stable, not frozen. Nothing is promised stable until version 2.

Programs, regions & imports

Keyword spelling

A Faber source file is a program. The compiler reads it from the top: an optional frontmatter header, an optional module region, then the declarations, imports, tests, and the entry point that starts it. A file may also be split by whole-line section markers (+++ toml, +++ faber, +++ faber test, and stream sections such as +++ text stdout); the compiler reads only the program section. There is no hidden wrapper around those declarations and no separate "program" object to construct.

The words on this page are the ones that give the file its shape. Imports bring a name in from another file or a library (import from). main is the ordinary entry; async_main is the one that may await. Tests are ordinary declarations in the same file — describe names a suite, test names a case — not a second language and not a second compilation target.

A file that does one thing:

fn salve(string nomen) → string {
    let string msg ← "Salve, §!"(nomen)
    return msg
}

main {
    let string m ← salve("munde")
    print m
}

faber check accepts that file. faber run prints Salve, munde!.

Tests sit beside the code they exercise:

fn saturate(i32 x) → i32 {
    if x ≺ 0 then return 0
    if x ≻ 255 then return 255
    return x
}

describe "saturate" {
    test "clamps low" {
        assert saturate(-1) ≡ 0
    }
    test "clamps high" {
        assert saturate(300) ≡ 255
    }
}

Return to the grammar overview.

Terms#

These are the words you write in this part of the language. Each links to its page. The second column names the grammar rule the word belongs to.

TermGrammar rule
fnnondum_functio_decl
importimporta_record
fromex_field
asut_field
allomnia_field
from, importimporta_sugar
publicpublica
asnamed_import
aswildcard_import
constselective_import
asimport_value_binding
args, exitentry_header
mainincipit_stmt
async_mainincipiet_stmt
describeprobandum_decl
testproba_stmt
expect_failure, flaky, todo, bench, skip, repeat, only, only_in, tag, timeoutproba_modifier
all, teardown, async_teardown, setup, async_setuppraepara_block

Formal grammar#

The rules for this part of the language are the parser's own definition of it. They are written for models and tools, so this page does not repeat them; the full list is at every production.