From 1d2a7df53f9b3eac6aa6d881e39ab58f87706377 Mon Sep 17 00:00:00 2001 From: Rashid Al Muhairi Date: Fri, 24 Feb 2023 23:05:35 +0400 Subject: [PATCH 1/3] format: Change EBNF codeblock syntax highlighting to `ebnf` GitHub supports syntax highlighting for the ebnf format --- design/mvp/WIT.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/design/mvp/WIT.md b/design/mvp/WIT.md index 20b456c7..67eff44f 100644 --- a/design/mvp/WIT.md +++ b/design/mvp/WIT.md @@ -566,7 +566,7 @@ or codepoints that Unicode officially deprecates or strongly discourages. The current structure of tokens are: -```wit +```ebnf token ::= whitespace | comment | operator @@ -582,7 +582,7 @@ here. A `whitespace` token in `wit` is a space, a newline, a carriage return, or a tab character: -```wit +```ebnf whitespace ::= ' ' | '\n' | '\r' | '\t' ``` @@ -593,7 +593,7 @@ ends at the next newline (`\n`) character or it's a block comment which starts with `/*` and ends with `*/`. Note that block comments are allowed to be nested and their delimiters must be balanced -```wit +```ebnf comment ::= '//' character-that-isnt-a-newline* | '/*' any-unicode-character* '*/' ``` @@ -604,7 +604,7 @@ newline (`\n`) character or it's a block comment which starts with `/**` and end with `*/`. Note that block comments are allowed to be nested and their delimiters must be balanced -```wit +```ebnf doc-comment ::= '///' character-that-isnt-a-newline* | '/**' any-unicode-character* '*/' ``` @@ -615,7 +615,7 @@ There are some common operators in the lexical structure of `wit` used for various constructs. Note that delimiters such as `{` and `(` must all be balanced. -```wit +```ebnf operator ::= '=' | ',' | ':' | ';' | '(' | ')' | '{' | '}' | '<' | '>' | '*' | '->' ``` @@ -625,7 +625,7 @@ Certain identifiers are reserved for use in `wit` documents and cannot be used bare as an identifier. These are used to help parse the format, and the list of keywords is still in flux at this time but the current set is: -```wit +```ebnf keyword ::= 'use' | 'type' | 'resource' @@ -663,7 +663,7 @@ come one after another and it's recommended to separate them with newlines for readability but this isn't required. Concretely, the structure of a `wit` document is: -``` +```ebnf wit-document ::= (interface-item | world-item)* ``` @@ -673,7 +673,7 @@ Worlds define a [componenttype](https://github.com/WebAssembly/component-model/b Concretely, the structure of a world is: -```wit +```ebnf world-item ::= 'default'? 'world' id '{' world-items* '}' world-items ::= export-item | import-item | use-item | typedef-item @@ -697,7 +697,7 @@ sequence of items and functions. Specifically interfaces have the structure: -```wit +```ebnf interface-item ::= 'default'? 'interface' id '{' interface-items* '}' interface-items ::= typedef-item @@ -741,7 +741,7 @@ use my-dependency.document.other-type Specifically the structure of this is: -```wit +```ebnf use-item ::= 'use' use-path '.' '{' use-names-list '}' use-names-list ::= use-names-item @@ -774,7 +774,7 @@ type my-complicated-tuple = tuple Specifically the structure of this is: -```wit +```ebnf type-item ::= 'type' id '=' ty ``` @@ -799,7 +799,7 @@ record person { Specifically the structure of this is: -```wit +```ebnf record-item ::= 'record' id '{' record-fields '}' record-fields ::= record-field @@ -824,7 +824,7 @@ flags properties { Specifically the structure of this is: -```wit +```ebnf flags-items ::= 'flags' id '{' flags-fields '}' flags-fields ::= id @@ -853,7 +853,7 @@ variant filter { Specifically the structure of this is: -```wit +```ebnf variant-items ::= 'variant' id '{' variant-cases '}' variant-cases ::= variant-case @@ -882,7 +882,7 @@ enum color { Specifically the structure of this is: -```wit +```ebnf enum-items ::= 'enum' id '{' enum-cases '}' enum-cases ::= id @@ -905,7 +905,7 @@ union configuration { Specifically the structure of this is: -```wit +```ebnf union-items ::= 'union' id '{' union-cases '}' union-cases ::= ty @@ -927,7 +927,7 @@ type headers = list Specifically the following types are available: -```wit +```ebnf ty ::= 'u8' | 'u16' | 'u32' | 'u64' | 's8' | 's16' | 's32' | 's64' | 'float32' | 'float64' @@ -990,7 +990,7 @@ resource is destroyed. In contrast, a borrowed handle represents a temporary loan of a handle from the caller to the callee for the duration of the call. The syntax for handles is: -``` +```ebnf handle ::= id | 'borrow' '<' id '>' ``` From 8803b54027b71f3147a2d9184ec1f08eaa12a310 Mon Sep 17 00:00:00 2001 From: Rashid Al Muhairi Date: Fri, 24 Feb 2023 23:08:51 +0400 Subject: [PATCH 2/3] format: Make comments as whitespace As comments are separate from doc-comments it would be safe to do so, and we can still access comments from the CST if needed --- design/mvp/WIT.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/design/mvp/WIT.md b/design/mvp/WIT.md index 67eff44f..979d7d77 100644 --- a/design/mvp/WIT.md +++ b/design/mvp/WIT.md @@ -568,7 +568,6 @@ The current structure of tokens are: ```ebnf token ::= whitespace - | comment | operator | keyword | identifier @@ -579,11 +578,11 @@ here. ### Whitespace -A `whitespace` token in `wit` is a space, a newline, a carriage return, or a -tab character: +A `whitespace` token in `wit` is a space, a newline, a carriage return, a +tab character, or a comment: ```ebnf -whitespace ::= ' ' | '\n' | '\r' | '\t' +whitespace ::= ' ' | '\n' | '\r' | '\t' | comment ``` ### Comments From 778ab60c697da086ce4309ac7ef6cf1e57c09009 Mon Sep 17 00:00:00 2001 From: Rashid Al Muhairi Date: Fri, 24 Feb 2023 23:11:51 +0400 Subject: [PATCH 3/3] format: Relax reserved keywords Builtin types, and the word `as` do not need to be reserved, as such, we can safely remove them --- design/mvp/WIT.md | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/design/mvp/WIT.md b/design/mvp/WIT.md index 979d7d77..0787c613 100644 --- a/design/mvp/WIT.md +++ b/design/mvp/WIT.md @@ -629,26 +629,13 @@ keyword ::= 'use' | 'type' | 'resource' | 'func' - | 'u8' | 'u16' | 'u32' | 'u64' - | 's8' | 's16' | 's32' | 's64' - | 'float32' | 'float64' - | 'char' | 'record' | 'enum' | 'flags' | 'variant' | 'union' - | 'bool' - | 'string' - | 'option' - | 'list' - | 'result' - | 'as' | 'static' | 'interface' - | 'tuple' - | 'future' - | 'stream' | 'world' | 'import' | 'export'