@@ -566,9 +566,8 @@ or codepoints that Unicode officially deprecates or strongly discourages.
566566
567567The current structure of tokens are:
568568
569- ``` wit
569+ ``` ebnf
570570token ::= 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
593592with ` /* ` and ends with ` */ ` . Note that block comments are allowed to be nested
594593and their delimiters must be balanced
595594
596- ``` wit
595+ ``` ebnf
597596comment ::= '//' 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
604603with ` */ ` . Note that block comments are allowed to be nested and their delimiters
605604must be balanced
606605
607- ``` wit
606+ ``` ebnf
608607doc-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
615614various constructs. Note that delimiters such as ` { ` and ` ( ` must all be
616615balanced.
617616
618- ``` wit
617+ ``` ebnf
619618operator ::= '=' | ',' | ':' | ';' | '(' | ')' | '{' | '}' | '<' | '>' | '*' | '->'
620619```
621620
@@ -625,31 +624,18 @@ Certain identifiers are reserved for use in `wit` documents and cannot be used
625624bare as an identifier. These are used to help parse the format, and the list of
626625keywords is still in flux at this time but the current set is:
627626
628- ``` wit
627+ ``` ebnf
629628keyword ::= '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
663649readability but this isn't required.
664650
665651Concretely, the structure of a ` wit ` document is:
666- ```
652+ ``` ebnf
667653wit-document ::= (interface-item | world-item)*
668654```
669655
@@ -673,7 +659,7 @@ Worlds define a [componenttype](https://github.com/WebAssembly/component-model/b
673659
674660Concretely, the structure of a world is:
675661
676- ``` wit
662+ ``` ebnf
677663world-item ::= 'default'? 'world' id '{' world-items* '}'
678664
679665world-items ::= export-item | import-item | use-item | typedef-item
@@ -697,7 +683,7 @@ sequence of items and functions.
697683
698684Specifically interfaces have the structure:
699685
700- ``` wit
686+ ``` ebnf
701687interface-item ::= 'default'? 'interface' id '{' interface-items* '}'
702688
703689interface-items ::= typedef-item
@@ -741,7 +727,7 @@ use my-dependency.document.other-type
741727
742728Specifically the structure of this is:
743729
744- ``` wit
730+ ``` ebnf
745731use-item ::= 'use' use-path '.' '{' use-names-list '}'
746732
747733use-names-list ::= use-names-item
@@ -774,7 +760,7 @@ type my-complicated-tuple = tuple<u32, s32, string>
774760
775761Specifically the structure of this is:
776762
777- ``` wit
763+ ``` ebnf
778764type-item ::= 'type' id '=' ty
779765```
780766
@@ -799,7 +785,7 @@ record person {
799785
800786Specifically the structure of this is:
801787
802- ``` wit
788+ ``` ebnf
803789record-item ::= 'record' id '{' record-fields '}'
804790
805791record-fields ::= record-field
@@ -824,7 +810,7 @@ flags properties {
824810
825811Specifically the structure of this is:
826812
827- ``` wit
813+ ``` ebnf
828814flags-items ::= 'flags' id '{' flags-fields '}'
829815
830816flags-fields ::= id
@@ -853,7 +839,7 @@ variant filter {
853839
854840Specifically the structure of this is:
855841
856- ``` wit
842+ ``` ebnf
857843variant-items ::= 'variant' id '{' variant-cases '}'
858844
859845variant-cases ::= variant-case
@@ -882,7 +868,7 @@ enum color {
882868
883869Specifically the structure of this is:
884870
885- ``` wit
871+ ``` ebnf
886872enum-items ::= 'enum' id '{' enum-cases '}'
887873
888874enum-cases ::= id
@@ -905,7 +891,7 @@ union configuration {
905891
906892Specifically the structure of this is:
907893
908- ``` wit
894+ ``` ebnf
909895union-items ::= 'union' id '{' union-cases '}'
910896
911897union-cases ::= ty
@@ -927,7 +913,7 @@ type headers = list<string>
927913
928914Specifically the following types are available:
929915
930- ``` wit
916+ ``` ebnf
931917ty ::= '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
990976loan of a handle from the caller to the callee for the duration of the call.
991977
992978The syntax for handles is:
993- ```
979+ ``` ebnf
994980handle ::= id
995981 | 'borrow' '<' id '>'
996982```
0 commit comments