Conventions¶
WebAssembly is a programming language that has multiple concrete representations (its binary format and the text format). Both map to a common structure. For conciseness, this structure is described in the form of an abstract syntax. All parts of this specification are defined in terms of this abstract syntax.
Grammar Notation¶
The following conventions are adopted in defining grammar rules for abstract syntax.
Terminal symbols (atoms) are written in sans-serif font or in symbolic form:
.Nonterminal symbols are written in italic font:
. is a sequence of iterations of . is a possibly empty sequence of iterations of . (This is a shorthand for used where is not relevant.) is a non-empty sequence of iterations of . (This is a shorthand for where .) is an optional occurrence of . (This is a shorthand for where .)Productions are written
.Large productions may be split into multiple definitions, indicated by ending the first one with explicit ellipses,
, and starting continuations with ellipses, .Some productions are augmented with side conditions in parentheses, “
”, that provide a shorthand for a combinatorial expansion of the production into many separate cases.If the same meta variable or non-terminal symbol appears multiple times in a production, then all those occurrences must have the same instantiation. (This is a shorthand for a side condition requiring multiple different variables to be equal.)
Auxiliary Notation¶
When dealing with syntactic constructs the following notation is also used:
denotes the empty sequence. denotes the length of a sequence . denotes the -th element of a sequence , starting from . denotes the sub-sequence of a sequence . denotes the same sequence as , except that the -th element is replaced with . denotes the same sequence as , except that the sub-sequence is replaced with . denotes the flat sequence formed by concatenating all sequences in .
Moreover, the following conventions are employed:
The notation
, where is a non-terminal symbol, is treated as a meta variable ranging over respective sequences of (similarly for , , ).When given a sequence
, then the occurrences of in a sequence written are assumed to be in point-wise correspondence with (similarly for , , ). This implicitly expresses a form of mapping syntactic constructions over a sequence.
Productions of the following form are interpreted as records that map a fixed set of fields
The following notation is adopted for manipulating such records:
denotes the contents of the component of . denotes the same record as , except that the contents of the component is replaced with . denotes the composition of two records with the same fields of sequences by appending each sequence point-wise: denotes the composition of a sequence of records, respectively; if the sequence is empty, then all fields of the resulting record are empty.
The update notation for sequences and records generalizes recursively to nested components accessed by “paths”
is short for , is short for ,
where
Vectors¶
Vectors are bounded sequences of the form