Compact language version 0.22.0.
Notational note: In the grammar below, keywords and punctuation are in monospaced font. Terminal and nonterminal names are in emphasized font. Alternation is indicated by a vertical bar (|). Optional items are indicated by the superscript opt. Repetition is specified by ellipses. The notation X ⋯ X, where X is a grammar symbol, represents zero or more occurrences of X. The notation X , ⋯ , X, where X is a grammar symbol and , is a literal comma, represents zero or more occurrences of X separated by commas. In either case, when the ellipsis is marked with the superscript 1, the notation represents a sequence containing at least one X. When such a sequence is followed by ,opt, an optional trailing comma is allowed, but only if there is at least one X. For example, id ⋯ id represents zero or more ids, and expr , ⋯¹, expr ,opt represents one or more comma-separated exprs possibly followed by an extra comma. The rules involving commas apply equally to semicolons, i.e., apply when , is replaced by ;.
identifier
id, module-name, function-name, struct-name, enum-name, contract-name, tvar-name, type-name
Identifiers have the same syntax as Typescript identifiers.
field-literal
nat
A field literal is 0 or a natural number formed from a sequence of digits starting with 1-9, e.g. 723, whose value does not exceed the maximum field value.
string-literal
str, file
A string literal has the same syntax as a Typescript string.
version-literal
version
A version literal takes the form nat.nat representing major and minor versions or nat.nat.nat representing major, minor, and bugfix versions. Where version literals are allowed, a plain nat representing just the major version is also allowed.
Compact
Program-element
Pragma
Version-expression
Version-expression0
Version-Term
Version-atom
Include
| | |
|---|
| include-form | ⟶ | include file ; |
Module-definition
Generic-parameter-list
Generic-parameter
Import-declaration
Import-selection
Import-element
Import-name
Import-prefix
Generic-argument-list
Generic-argument
Export-declaration
| | |
|---|
| export-form | ⟶ | export { id , ⋯ , id ,opt } ;opt |
Ledger-declaration
| | |
|---|
| ledger-declaration | ⟶ | exportopt sealedopt ledger id : type ; |
Witness-declaration
Constructor
Circuit-definition
Structure-declaration
Enum-declaration
| | |
|---|
| enum-declaration | ⟶ | exportopt enum enum-name { id , ⋯¹ , id ,opt } ;opt |
External-contract-declaration
External-contract-circuit
Type-declaration
Typed-identifier
Simple-parameter-list
Typed-pattern
Pattern-parameter-list
Type
Type-reference
Type-size
Block
Statement
Statement0
Pattern
Pattern-struct-element
Expression-sequence
Expression
Expression0
Expression1
Expression2
Expression3
Expression4
Expression5
Expression6
Expression7
Expression8
Expression9
| | |
|---|
| expr9 | ⟶ | fun ( expr , ⋯ , expr ,opt ) |
| | | map ( fun , expr , ⋯¹ , expr ,opt ) |
| | | fold ( fun , expr , expr , ⋯¹ , expr ,opt ) |
| | | slice < tsize > ( expr , expr ) |
| | | [ tuple-arg , ⋯ , tuple-arg ,opt ] |
| | | Bytes [ bytes-arg , ⋯ , bytes-arg ,opt ] |
| | | tref { struct-arg , ⋯ , struct-arg ,opt } |
| | | assert ( expr , str ) |
| | | disclose ( expr ) |
| | | term |
Term
Tuple-argument
Structure-argument
Function
Return-type
Optionally-typed-pattern
Const-Binding
Arrow-parameter-list