Syntax
Grammar
- annotate-expression →
(
expression::
type)
Annotate an expression with a type.
- apply-expression →
(
expression.
expression)
Function application using the
.
operator. - as-expression →
(
expressionas
type)
Convert a value of one type to a value of a different type.
- assignment →
(
pattern:
expression)
Assign a value to a pattern.
- attribute → (attribute |
(
(
name)
:
attribute-value)
)An attribute.
- attribute-value → (name | number | text)
An attribute value.
- binary-operator-expression → (
(
expressionto
expression)
|(
expressionby
expression)
|(
expression^
expression)
|(
expression*
expression)
|(
expression/
expression)
|(
expression%
expression)
|(
expression+
expression)
|(
expression-
expression)
|(
expression<
expression)
|(
expression<=
expression)
|(
expression>
expression)
|(
expression>=
expression)
|(
expression=
expression)
|(
expression/=
expression)
|(
expressionand
expression)
|(
expressionor
expression)
)An expression involving a binary operator.
- block-expression →
{
statement ...}
A block expression.
- block-type → (
{
type ...}
)A type whose value is computed from a block expression.
- call-expression →
(
expression ...)
Call a function with at least one input.
- collection-expression →
(
expression,
...)
A collection.
- constant-declaration →
(
(
name)
::
((
type-function=>
type)
| type))
A constant declaration.
- declared-type → (name |
(
name type ...)
)A declared type, optionally with parameters.
- destructure-pattern →
{
(
(
name)
:
pattern)
...}
A pattern that matches the fields of a structure.
- do-expression →
(
do
expression)
Call an intrinsic function provided by the runtime.
- equal-type →
(
type=
type)
Use two types in the place of one.
- expression → (annotate-expression | name-expression | number-expression | text-expression | apply-expression | binary-operator-expression | as-expression | is-expression | when-expression | intrinsic-expression | tuple-expression | collection-expression | structure-expression | block-expression | function-expression | do-expression | call-expression)
An expression.
- function-expression →
(
((
pattern ...)
| function-inputs)->
expression)
A function expression.
- function-type →
(
((
type ...)
| function-inputs)->
type)
A function type.
- instance →
(
name type ...)
An instance.
- instance-declaration → (
(
((
type-function=>
(
default
instance
instance)
)
|(
default
instance
instance)
):
expression)
| ((
type-function=>
(
default
instance
instance)
)
|(
default
instance
instance)
))A default instance declaration.
- instance-declaration → (
(
((
type-function=>
(
instance
instance)
)
|(
instance
instance)
):
expression)
| ((
type-function=>
(
instance
instance)
)
|(
instance
instance)
))An instance declaration.
- intrinsic-expression →
(
intrinsic
text expression ...)
Call an intrinsic function provided by the runtime.
- intrinsic-type →
intrinsic
An intrinsic type provided by the runtime.
- is-expression →
(
expressionis
pattern)
Check if a value matches a pattern.
- message-type → (text |
(
text type ...)
)A type-level piece of text used to generate compiler errors.
- mutate-pattern →
(
name!
)
A pattern that changes the value of an existing variable.
- name-expression → name
A name.
- number-expression → number
A number.
- number-pattern → number
A pattern that matches a number.
- or-pattern →
(
patternor
pattern)
A pattern that matches either one of its subpatterns.
- pattern → (wildcard-pattern | number-pattern | text-pattern | destructure-pattern | tuple-pattern | or-pattern | mutate-pattern | variant-pattern | annotate-pattern)
A pattern.
- placeholder-type → _
An inferred type.
- statement → (syntax-declaration | type-declaration | trait-declaration | instance-declaration | instance-declaration | constant-declaration | assignment | statement)
A statement.
- structure-expression →
{
(
(
name)
:
expression)
...}
A structure.
- syntax-declaration →
(
intrinsic
text)
A syntax declaration.
- text-expression → text
A piece of text.
- text-pattern → text
A pattern that matches a piece of text.
- top-level → (
{
}
|{
statement ...}
)A file or code box.
- trait-declaration →
(
(
name)
:
((
trait
)
|(
trait
type)
|(
type-function=>
((
trait
)
|(
trait
type)
))
))
A trait declaration.
- tuple-expression →
(
expression;
...)
A tuple.
- tuple-pattern →
(
pattern;
...)
A pattern that matches a tuple.
- tuple-type →
(
type;
...)
A tuple type.
- type → (placeholder-type | function-type | tuple-type | block-type | intrinsic-type | message-type | equal-type | declared-type)
A type.
- type-declaration →
(
(
name)
:
((
type
)
|(
type
type-representation)
|(
type-function=>
(
type
)
)
|(
type-function=>
(
type
type-representation)
)
))
A type declaration.
- type-function → (
(
type-parameter ...)
|(
((
_)
|(
type-parameter ...)
)where
(
instance ...)
)
)Provides generic type parameters and bounds to a declaration.
- type-parameter → (name |
(
infer
name)
|(
((
name)
|(
infer
name)
):
type)
)A type parameter.
- type-representation → (
{
((
(
name)
::
type)
|(
name type ...)
) ...}
| type)A set of fields or variants in a type.
- variant-pattern → (name |
(
name pattern ...)
)A pattern that matches a variant or binds to a variable.
- when-arm →
(
pattern->
expression)
An arm in a
when
expression. - when-expression →
(
when
expression{
when-arm ...}
)
Match a value against a set of patterns.
- wildcard-pattern → _
A pattern that matches any value.