wasm-wave 0.261.0

WebAssembly Value Encoding
Documentation
# WAVE EBNF

A WAVE value is defined by the `value` rule below. Many applications may allow
whitespace around the value, equivalent to the `value-ws` rule.

> Note that Bool, Variant, Enum, Option and Result values are combined under
> the `variant-case` rule because these cannot be distinguished without type
> information.

```ebnf
value ::= number
        | char
        | string
        | multiline-string
        | variant-case
        | tuple
        | list
        | flags
        | record

value-ws ::= ws value ws
ws ::= ([ \t\n\r] | comment)*
comment ::= '//' [^\n]*

number ::= number_finite
         | 'nan'
         | 'inf'
         | '-inf'
number_finite ::= integer number-fraction? number-exponent?
integer ::= unsigned-integer
          | '-' unsigned-integer
unsigned-integer ::= '0'
                   | [1-9] [0-9]*
number-fraction ::= '.' [0-9]+
number-exponent ::= [eE] [+-]? [0-9]+

char ::= ['] char-char [']
char-char ::= common-char | '"'

string ::= '"' string-char* '"'
string-char ::= common-char | [']

multiline-string ::= '"""' line-break multiline-string-line* [ ]* '"""'
multiline-string-line ::= [ ]* multiline-string-char* line-break
multiline-string-char ::= common-char | ['"]

line-break ::= '\r\n' | '\n'

common-char ::= <any Unicode Scalar Value except ['"\n\\]>
              | '\' escape
escape ::= ['"tnr\\] | escape-unicode
escape-unicode ::= 'u{' [0-9a-fA-F]+ '}'

variant-case ::= label ws variant-case-payload?
variant-case-payload ::= '(' value-ws ')'

tuple ::= '(' values-seq ','? ws ')'

list ::= '[' ws ']'
       | '[' values-seq ','? ws ']'

values-seq ::= value-ws
             | values-seq ',' value-ws

flags ::= '{' ws '}'
        | '{' flags-seq ','? ws '}'
flags-seq ::= ws label ws
            | flags-seq ',' ws label ws

record ::= '{' ws ':' ws '}'
         | '{' record-fields ','? ws '}'
record-fields ::= ws record-field ws
                | record-fields ',' ws record-field ws
record-field ::= label ws ':' ws value

label ::= '%'? first-word ('-' word)*
first-word ::= [a-z][a-z0-9]*
             | [A-Z][A-Z0-9]*
word ::= [a-z0-9]+
       | [A-Z0-9]+
```

* "`Unicode scalar value`" is defined by Unicode
* `escape-unicode` must identify a valid Unicode scalar value, using 1 to 6 hexadecimal digits.
* `multiline-string-line` must not contain `"""`
* See [README.md#multiline-strings]./README.md#multiline-strings for the indentation and decoding rules that constrain `multiline-string`.