Compact grammar
Compact language version 0.21.0.
Notational note: In the grammar below, terminals are in monospaced font. Non-terminals 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 ;.
end-of-file (eof)
End of file.
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 or nat.nat or nat.nat.nat, e.g., 1.2 or 1.2.3, representing major, minor, and bugfix versions.
Compact (program)
| program | ⟶ | pelt … pelt eof |
Program-element (pelt)
| pelt | ⟶ | pragma-form |
| | | module-definition | |
| | | import-form | |
| | | export-form | |
| | | include-form | |
| | | struct-declaration | |
| | | enum-declaration | |
| | | contract-declaration | |
| | | type-alias-declaration | |
| | | ledger-declaration | |
| | | witness-declaration | |
| | | constructor-definition | |
| | | circuit-definition |