Grammar
The grammar of Omegyu's expressions, from the constructs that extend as far as they can to the atoms and the imports.
In the grammar below, '…' is the text of a token, ? marks an optional
part, * and + mark repetitions, and | separates alternatives.
Operators gives the precedence of operator,
and programs and lexical structure describes
the tokens.
expression ::= '\' parameter+ '->' expression
| 'forall' binders+ '->' expression
| 'exists' binders+ '*' expression
| definition+ 'in' expression
| 'if' expression 'then' expression 'else' expression
| 'assert' ':' expression
| 'do' selector? '{' statement (';' statement)* ';'? '}'
| operators '->' expression
| operators ':' expression
| operators
definition ::= 'let' name (':' expression)? '=' expression
statement ::= name (':' expression)? '<-' expression
| definition
| expression
parameter ::= name | binders
binders ::= '(' name+ (':' expression)? ')'
| '{' name+ (':' expression)? '}'
operators ::= operators operator operators | application
application ::= selector argument*
| 'merge' selector selector ('otherwise' selector)? argument*
| selector update+
argument ::= selector | '@' selector
update ::= 'with' name ('.' name)* '=' operators
| 'without' name
selector ::= atom ('.' name | '.' '{' (name (',' name)*)? '}' | '.' ('1' | '2'))*
atom ::= name | '_' | number | text | import
| '(' expression (',' expression)* ')'
| '[' (expression (',' expression)*)? ']'
| '{' '}' | '{' '=' '}'
| '{' field (',' field)* (',' spread)? '}'
| '{' spread '}'
| '<' (alternative ('|' alternative)* ('|' spread)? | spread)? '>'
| '(|' (entry (',' entry)* (',' spread)? | spread)? '|)'
field ::= name '=' expression | name ':' expression | name
alternative ::= name (':' expression)?
entry ::= name ':' expression
spread ::= '...' expression
text ::= '"' (characters | '${' expression '}')* '"'
import ::= (location | 'import' selector) ('sha256:' hex64)?
location ::= path | 'std:' name | 'env:' name | urlThe fields of a record are all of one kind: values, written with
=or as a bare name, or types, written with:.{ ...r }is a record type.An operand of an operator may be a record update, as in
r with a = 1, but the value of an update may not, so a chain of updates reads from left to right.In a
doblock, the last statement is an expression: the result of the block. A definition followed byinis an expression too.An alternative without a payload is not named after a builtin type of data, unless its name is written between backticks (unions).