@@ -566,9 +566,8 @@ or codepoints that Unicode officially deprecates or strongly discourages.
566
566
567
567
The current structure of tokens are:
568
568
569
- ``` wit
569
+ ``` ebnf
570
570
token ::= whitespace
571
- | comment
572
571
| operator
573
572
| keyword
574
573
| identifier
@@ -579,11 +578,11 @@ here.
579
578
580
579
### Whitespace
581
580
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 :
584
583
585
- ``` wit
586
- whitespace ::= ' ' | '\n' | '\r' | '\t'
584
+ ``` ebnf
585
+ whitespace ::= ' ' | '\n' | '\r' | '\t' | comment
587
586
```
588
587
589
588
### Comments
@@ -593,7 +592,7 @@ ends at the next newline (`\n`) character or it's a block comment which starts
593
592
with ` /* ` and ends with ` */ ` . Note that block comments are allowed to be nested
594
593
and their delimiters must be balanced
595
594
596
- ``` wit
595
+ ``` ebnf
597
596
comment ::= '//' character-that-isnt-a-newline*
598
597
| '/*' any-unicode-character* '*/'
599
598
```
@@ -604,7 +603,7 @@ newline (`\n`) character or it's a block comment which starts with `/**` and end
604
603
with ` */ ` . Note that block comments are allowed to be nested and their delimiters
605
604
must be balanced
606
605
607
- ``` wit
606
+ ``` ebnf
608
607
doc-comment ::= '///' character-that-isnt-a-newline*
609
608
| '/**' any-unicode-character* '*/'
610
609
```
@@ -615,7 +614,7 @@ There are some common operators in the lexical structure of `wit` used for
615
614
various constructs. Note that delimiters such as ` { ` and ` ( ` must all be
616
615
balanced.
617
616
618
- ``` wit
617
+ ``` ebnf
619
618
operator ::= '=' | ',' | ':' | ';' | '(' | ')' | '{' | '}' | '<' | '>' | '*' | '->'
620
619
```
621
620
@@ -625,31 +624,18 @@ Certain identifiers are reserved for use in `wit` documents and cannot be used
625
624
bare as an identifier. These are used to help parse the format, and the list of
626
625
keywords is still in flux at this time but the current set is:
627
626
628
- ``` wit
627
+ ``` ebnf
629
628
keyword ::= 'use'
630
629
| 'type'
631
630
| 'resource'
632
631
| 'func'
633
- | 'u8' | 'u16' | 'u32' | 'u64'
634
- | 's8' | 's16' | 's32' | 's64'
635
- | 'float32' | 'float64'
636
- | 'char'
637
632
| 'record'
638
633
| 'enum'
639
634
| 'flags'
640
635
| 'variant'
641
636
| 'union'
642
- | 'bool'
643
- | 'string'
644
- | 'option'
645
- | 'list'
646
- | 'result'
647
- | 'as'
648
637
| 'static'
649
638
| 'interface'
650
- | 'tuple'
651
- | 'future'
652
- | 'stream'
653
639
| 'world'
654
640
| 'import'
655
641
| 'export'
@@ -663,7 +649,7 @@ come one after another and it's recommended to separate them with newlines for
663
649
readability but this isn't required.
664
650
665
651
Concretely, the structure of a ` wit ` document is:
666
- ```
652
+ ``` ebnf
667
653
wit-document ::= (interface-item | world-item)*
668
654
```
669
655
@@ -673,7 +659,7 @@ Worlds define a [componenttype](https://github.com/WebAssembly/component-model/b
673
659
674
660
Concretely, the structure of a world is:
675
661
676
- ``` wit
662
+ ``` ebnf
677
663
world-item ::= 'default'? 'world' id '{' world-items* '}'
678
664
679
665
world-items ::= export-item | import-item | use-item | typedef-item
@@ -697,7 +683,7 @@ sequence of items and functions.
697
683
698
684
Specifically interfaces have the structure:
699
685
700
- ``` wit
686
+ ``` ebnf
701
687
interface-item ::= 'default'? 'interface' id '{' interface-items* '}'
702
688
703
689
interface-items ::= typedef-item
@@ -741,7 +727,7 @@ use my-dependency.document.other-type
741
727
742
728
Specifically the structure of this is:
743
729
744
- ``` wit
730
+ ``` ebnf
745
731
use-item ::= 'use' use-path '.' '{' use-names-list '}'
746
732
747
733
use-names-list ::= use-names-item
@@ -774,7 +760,7 @@ type my-complicated-tuple = tuple<u32, s32, string>
774
760
775
761
Specifically the structure of this is:
776
762
777
- ``` wit
763
+ ``` ebnf
778
764
type-item ::= 'type' id '=' ty
779
765
```
780
766
@@ -799,7 +785,7 @@ record person {
799
785
800
786
Specifically the structure of this is:
801
787
802
- ``` wit
788
+ ``` ebnf
803
789
record-item ::= 'record' id '{' record-fields '}'
804
790
805
791
record-fields ::= record-field
@@ -824,7 +810,7 @@ flags properties {
824
810
825
811
Specifically the structure of this is:
826
812
827
- ``` wit
813
+ ``` ebnf
828
814
flags-items ::= 'flags' id '{' flags-fields '}'
829
815
830
816
flags-fields ::= id
@@ -853,7 +839,7 @@ variant filter {
853
839
854
840
Specifically the structure of this is:
855
841
856
- ``` wit
842
+ ``` ebnf
857
843
variant-items ::= 'variant' id '{' variant-cases '}'
858
844
859
845
variant-cases ::= variant-case
@@ -882,7 +868,7 @@ enum color {
882
868
883
869
Specifically the structure of this is:
884
870
885
- ``` wit
871
+ ``` ebnf
886
872
enum-items ::= 'enum' id '{' enum-cases '}'
887
873
888
874
enum-cases ::= id
@@ -905,7 +891,7 @@ union configuration {
905
891
906
892
Specifically the structure of this is:
907
893
908
- ``` wit
894
+ ``` ebnf
909
895
union-items ::= 'union' id '{' union-cases '}'
910
896
911
897
union-cases ::= ty
@@ -927,7 +913,7 @@ type headers = list<string>
927
913
928
914
Specifically the following types are available:
929
915
930
- ``` wit
916
+ ``` ebnf
931
917
ty ::= 'u8' | 'u16' | 'u32' | 'u64'
932
918
| 's8' | 's16' | 's32' | 's64'
933
919
| 'float32' | 'float64'
@@ -990,7 +976,7 @@ resource is destroyed. In contrast, a borrowed handle represents a temporary
990
976
loan of a handle from the caller to the callee for the duration of the call.
991
977
992
978
The syntax for handles is:
993
- ```
979
+ ``` ebnf
994
980
handle ::= id
995
981
| 'borrow' '<' id '>'
996
982
```
0 commit comments