Conventions — WebAssembly 2.0 (Draft 2025-04-25) (original) (raw)

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.

Auxiliary Notation

When dealing with syntactic constructs the following notation is also used:

Moreover, the following conventions are employed:

Productions of the following form are interpreted as records that map a fixed set of fields \(\mathsf{field}_i\) to “values” \(A_i\), respectively:

\[\mathit{r} ~::=~ \{ \mathsf{field}_1~A_1, \mathsf{field}_2~A_2, \dots \}\]

The following notation is adopted for manipulating such records:

The update notation for sequences and records generalizes recursively to nested components accessed by “paths” \(\mathit{pth} ::= ([\dots] \;| \;.\mathsf{field})^+\):

where \(r \href{../syntax/conventions.html#notation-replace}{\mathrel{\mbox{with}}}~.\mathsf{field} = A\) is shortened to \(r \href{../syntax/conventions.html#notation-replace}{\mathrel{\mbox{with}}} \mathsf{field} = A\).

Vectors

Vectors are bounded sequences of the form \(A^n\) (or \(A^\ast\)), where the \(A\) can either be values or complex constructions. A vector can have at most \(2^{32}-1\) elements.

\[\begin{split}\begin{array}{lllll} \def\mathdef2441#1{{}}\mathdef2441{vector} & \href{../syntax/conventions.html#syntax-vec}{\mathit{vec}}(A) &::=& A^n & (\mathrel{\mbox{if}} n < 2^{32})\\ \end{array}\end{split}\]