Documentation Index
Fetch the complete documentation index at: https://docs.brim-lang.com/llms.txt
Use this file to discover all available pages before exploring further.
This page summarizes type and literal grammar from grammar.ebnf.
Type expressions
type_expr = reference_type
| function_type
| tuple_type
| generic_type
| type_path ;
reference_type = "&" lifetime_identifier? "mut"? type_expr ;
function_type = "fn" param_type_list "->" type_expr ;
tuple_type = paren_open type_entries paren_close ;
generic_type = type_path generic_args ;
Type paths and generics
type_path = type_path_segment { "." type_path_segment } ;
type_path_segment = identifier | type_identifier ;
generic_args = angle_open type_arg_entries? angle_close ;
type_arg = type_expr | lifetime_identifier ;
Literals
literal = int_literal
| float_literal
| string_literal
| raw_string_literal
| multiline_string_literal
| byte_string_literal
| char_literal
| bool_literal
| unit_literal
| keyword_atom ;
Integer forms:
decimal_int = digit { digit | "_" } ;
hex_int = "0x" hex_digit { hex_digit | "_" } ;
binary_int = "0b" binary_digit { binary_digit | "_" } ;
octal_int = "0o" octal_digit { octal_digit | "_" } ;
String/interpolation forms include escaped, raw, multiline, and byte strings.
Operators (selected)
operator = "+"
| "-"
| "*"
| "/"
| "%"
| "=="
| "!="
| "<"
| "<="
| ">"
| ">="
| "&&"
| "||"
| "!"
| "="
| ":="
| "<-"
| "->"
| "=>"
| "|>"
| ".."
| "..="
| "&"
| "." ;
Reserved keywords
The grammar currently reserves keywords including:
module, import, imports, export, package, local, fn, type,
data, trait, impl, where, const, if, else, match, for,
while, loop, return, when, unless, guard, ensure, using,
do, try, view, mut, own, move, as, is, todo, never,
true, false.
Future-reserved names are also listed in the grammar for planned syntax space.