For the complete documentation index, see llms.txt
Compact grammar
Compact language version 0.23.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 | ⟶ | program-element ⋯ program-element |
Program-element
Pragma
| pragma-form | ⟶ | pragma id version-expr ; |
Version-expression
| version-expr | ⟶ | version-expr || version-expr0 |
| | | version-expr0 |
Version-expression0
| version-expr0 | ⟶ | version-expr0 && version-term |
| | | version-term |
Version-Term
| version-term | ⟶ | version-atom |
| | | ! version-atom | |
| | | < version-atom | |
| | | <= version-atom | |
| | | >= version-atom | |
| | | > version-atom | |
| | | ( version-expr ) |
Version-atom
Include
| include-form | ⟶ | include file ; |
Module-definition
| module-definition | ⟶ | exportopt module module-name gparamsopt { program-element ⋯ program-element } |
Generic-parameter-list
| gparams | ⟶ | < generic-param , ⋯ , generic-param ,opt > |
Generic-parameter
| generic-param |