| 1 |
# WAVE EBNF |
| 2 |
|
| 3 |
A WAVE value is defined by the `value` rule below. Many applications may allow |
| 4 |
whitespace around the value, equivalent to the `value-ws` rule. |
| 5 |
|
| 6 |
> Note that Bool, Variant, Enum, Option and Result values are combined under |
| 7 |
> the `variant-case` rule because these cannot be distinguished without type |
| 8 |
> information. |
| 9 |
|
| 10 |
```ebnf |
| 11 |
value ::= number |
| 12 |
| char |
| 13 |
| string |
| 14 |
| variant-case |
| 15 |
| tuple |
| 16 |
| list |
| 17 |
| flags |
| 18 |
| record |
| 19 |
|
| 20 |
value-ws ::= ws value ws |
| 21 |
ws ::= ([ \t\n\r]* comment?)* |
| 22 |
comment ::= '//' [^\n]* |
| 23 |
|
| 24 |
number ::= number_finite |
| 25 |
| 'nan' |
| 26 |
| 'inf' |
| 27 |
| '-inf' |
| 28 |
number_finite ::= integer number-fraction? number-exponent? |
| 29 |
integer ::= unsigned-integer |
| 30 |
| '-' unsigned-integer |
| 31 |
unsigned-integer ::= '0' |
| 32 |
| [1-9] [0-9]* |
| 33 |
number-fraction ::= '.' [0-9]+ |
| 34 |
number-exponent ::= [eE] [+-]? unsigned-integer |
| 35 |
|
| 36 |
char ::= ['] char-char ['] |
| 37 |
char-char ::= common-char | '"' |
| 38 |
|
| 39 |
string ::= '"' string-char* '"' |
| 40 |
string-char ::= common-char | ['] |
| 41 |
|
| 42 |
multiline-string ::= '"""' line-break multiline-string-line* [ ]* '"""' |
| 43 |
multiline-string-line ::= [ ]* multiline-string-char* line-break |
| 44 |
multiline-string-char ::= common-char | ['"] |
| 45 |
|
| 46 |
line-break ::= '\r\n' | '\n' |
| 47 |
|
| 48 |
common-char ::= <any Unicode Scalar Value except ['"\n\\]> |
| 49 |
| '\' escape |
| 50 |
escape ::= ['"tnr\\] | escape-unicode |
| 51 |
escape-unicode ::= 'u{' [0-9a-fA-F]+ '}' |
| 52 |
|
| 53 |
variant-case ::= label ws variant-case-payload? |
| 54 |
variant-case-payload ::= '(' value-ws ')' |
| 55 |
|
| 56 |
tuple ::= '(' values-seq ','? ws ')' |
| 57 |
|
| 58 |
list ::= '[' ws ']' |
| 59 |
| '[' values-seq ','? ws ']' |
| 60 |
|
| 61 |
values-seq ::= value-ws |
| 62 |
| values ',' values-ws |
| 63 |
|
| 64 |
flags ::= '{' ws '}' |
| 65 |
| '{' flags-seq ','? ws '}' |
| 66 |
flags-seq ::= ws label ws |
| 67 |
| flags-seq ',' label |
| 68 |
|
| 69 |
record ::= '{' ws ':' ws '}' |
| 70 |
| '{' record-fields ','? ws '}' |
| 71 |
record-fields ::= ws record-field ws |
| 72 |
| record-fields ',' record-field |
| 73 |
record-field ::= label ws ':' ws value |
| 74 |
|
| 75 |
label ::= '%'? inner-label |
| 76 |
inner-label ::= word |
| 77 |
| inner-label '-' word |
| 78 |
word ::= [a-z][a-z0-9]* |
| 79 |
| [A-Z][A-Z0-9]* |
| 80 |
``` |
| 81 |
|
| 82 |
* "`Unicode scalar value`" is defined by Unicode |
| 83 |
* `escape-unicode` must identify a valid Unicode scalar value. |
| 84 |
* `multiline-string-line` must not contain `"""` |