Skip to content

Commit 4a5b493

Browse files
authored
Merge pull request #156 from r-muhairi/wit/whitespace-comments-and-modify-reserved
format: EBNF Syntax Highlighting, comments as whitespace, relax some reserved keywords
2 parents c366536 + 778ab60 commit 4a5b493

File tree

1 file changed

+21
-35
lines changed

1 file changed

+21
-35
lines changed

Diff for: design/mvp/WIT.md

+21-35
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,8 @@ or codepoints that Unicode officially deprecates or strongly discourages.
566566

567567
The current structure of tokens are:
568568

569-
```wit
569+
```ebnf
570570
token ::= whitespace
571-
| comment
572571
| operator
573572
| keyword
574573
| identifier
@@ -579,11 +578,11 @@ here.
579578

580579
### Whitespace
581580

582-
A `whitespace` token in `wit` is a space, a newline, a carriage return, or a
583-
tab character:
581+
A `whitespace` token in `wit` is a space, a newline, a carriage return, a
582+
tab character, or a comment:
584583

585-
```wit
586-
whitespace ::= ' ' | '\n' | '\r' | '\t'
584+
```ebnf
585+
whitespace ::= ' ' | '\n' | '\r' | '\t' | comment
587586
```
588587

589588
### Comments
@@ -593,7 +592,7 @@ ends at the next newline (`\n`) character or it's a block comment which starts
593592
with `/*` and ends with `*/`. Note that block comments are allowed to be nested
594593
and their delimiters must be balanced
595594

596-
```wit
595+
```ebnf
597596
comment ::= '//' character-that-isnt-a-newline*
598597
| '/*' any-unicode-character* '*/'
599598
```
@@ -604,7 +603,7 @@ newline (`\n`) character or it's a block comment which starts with `/**` and end
604603
with `*/`. Note that block comments are allowed to be nested and their delimiters
605604
must be balanced
606605

607-
```wit
606+
```ebnf
608607
doc-comment ::= '///' character-that-isnt-a-newline*
609608
| '/**' any-unicode-character* '*/'
610609
```
@@ -615,7 +614,7 @@ There are some common operators in the lexical structure of `wit` used for
615614
various constructs. Note that delimiters such as `{` and `(` must all be
616615
balanced.
617616

618-
```wit
617+
```ebnf
619618
operator ::= '=' | ',' | ':' | ';' | '(' | ')' | '{' | '}' | '<' | '>' | '*' | '->'
620619
```
621620

@@ -625,31 +624,18 @@ Certain identifiers are reserved for use in `wit` documents and cannot be used
625624
bare as an identifier. These are used to help parse the format, and the list of
626625
keywords is still in flux at this time but the current set is:
627626

628-
```wit
627+
```ebnf
629628
keyword ::= 'use'
630629
| 'type'
631630
| 'resource'
632631
| 'func'
633-
| 'u8' | 'u16' | 'u32' | 'u64'
634-
| 's8' | 's16' | 's32' | 's64'
635-
| 'float32' | 'float64'
636-
| 'char'
637632
| 'record'
638633
| 'enum'
639634
| 'flags'
640635
| 'variant'
641636
| 'union'
642-
| 'bool'
643-
| 'string'
644-
| 'option'
645-
| 'list'
646-
| 'result'
647-
| 'as'
648637
| 'static'
649638
| 'interface'
650-
| 'tuple'
651-
| 'future'
652-
| 'stream'
653639
| 'world'
654640
| 'import'
655641
| 'export'
@@ -663,7 +649,7 @@ come one after another and it's recommended to separate them with newlines for
663649
readability but this isn't required.
664650

665651
Concretely, the structure of a `wit` document is:
666-
```
652+
```ebnf
667653
wit-document ::= (interface-item | world-item)*
668654
```
669655

@@ -673,7 +659,7 @@ Worlds define a [componenttype](https://github.com/WebAssembly/component-model/b
673659

674660
Concretely, the structure of a world is:
675661

676-
```wit
662+
```ebnf
677663
world-item ::= 'default'? 'world' id '{' world-items* '}'
678664
679665
world-items ::= export-item | import-item | use-item | typedef-item
@@ -697,7 +683,7 @@ sequence of items and functions.
697683

698684
Specifically interfaces have the structure:
699685

700-
```wit
686+
```ebnf
701687
interface-item ::= 'default'? 'interface' id '{' interface-items* '}'
702688
703689
interface-items ::= typedef-item
@@ -741,7 +727,7 @@ use my-dependency.document.other-type
741727

742728
Specifically the structure of this is:
743729

744-
```wit
730+
```ebnf
745731
use-item ::= 'use' use-path '.' '{' use-names-list '}'
746732
747733
use-names-list ::= use-names-item
@@ -774,7 +760,7 @@ type my-complicated-tuple = tuple<u32, s32, string>
774760

775761
Specifically the structure of this is:
776762

777-
```wit
763+
```ebnf
778764
type-item ::= 'type' id '=' ty
779765
```
780766

@@ -799,7 +785,7 @@ record person {
799785

800786
Specifically the structure of this is:
801787

802-
```wit
788+
```ebnf
803789
record-item ::= 'record' id '{' record-fields '}'
804790
805791
record-fields ::= record-field
@@ -824,7 +810,7 @@ flags properties {
824810

825811
Specifically the structure of this is:
826812

827-
```wit
813+
```ebnf
828814
flags-items ::= 'flags' id '{' flags-fields '}'
829815
830816
flags-fields ::= id
@@ -853,7 +839,7 @@ variant filter {
853839

854840
Specifically the structure of this is:
855841

856-
```wit
842+
```ebnf
857843
variant-items ::= 'variant' id '{' variant-cases '}'
858844
859845
variant-cases ::= variant-case
@@ -882,7 +868,7 @@ enum color {
882868

883869
Specifically the structure of this is:
884870

885-
```wit
871+
```ebnf
886872
enum-items ::= 'enum' id '{' enum-cases '}'
887873
888874
enum-cases ::= id
@@ -905,7 +891,7 @@ union configuration {
905891

906892
Specifically the structure of this is:
907893

908-
```wit
894+
```ebnf
909895
union-items ::= 'union' id '{' union-cases '}'
910896
911897
union-cases ::= ty
@@ -927,7 +913,7 @@ type headers = list<string>
927913

928914
Specifically the following types are available:
929915

930-
```wit
916+
```ebnf
931917
ty ::= 'u8' | 'u16' | 'u32' | 'u64'
932918
| 's8' | 's16' | 's32' | 's64'
933919
| 'float32' | 'float64'
@@ -990,7 +976,7 @@ resource is destroyed. In contrast, a borrowed handle represents a temporary
990976
loan of a handle from the caller to the callee for the duration of the call.
991977

992978
The syntax for handles is:
993-
```
979+
```ebnf
994980
handle ::= id
995981
| 'borrow' '<' id '>'
996982
```

0 commit comments

Comments
 (0)