aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJJ2023-07-25 05:34:50 +0000
committerJJ2023-07-25 05:49:03 +0000
commit1fa5634540667e0431fe6e157b278dc294dd9db1 (patch)
tree32223f92eba0ec9d1b6111216de66aa04889965b /docs
parentf2a8b4607de5d8832ba97be7d0222ed8e2ebea89 (diff)
docs: forgot about generics
Diffstat (limited to 'docs')
-rw-r--r--docs/SYNTAX.md41
1 files changed, 22 insertions, 19 deletions
diff --git a/docs/SYNTAX.md b/docs/SYNTAX.md
index 5090d33..8f6edb2 100644
--- a/docs/SYNTAX.md
+++ b/docs/SYNTAX.md
@@ -52,7 +52,7 @@ PRINT ::= LETTER | DIGIT | OPR |
### Values
```
-VALUE ::= INT_LIT | STRING | CHAR |
+VALUE ::= INT_LIT | STRING | CHAR | LIST_DECL | ARRAY_DECL | TUPLE_DECL | STRUCT_DECL
LIST_DECL ::= '[' (EXPR (',' EXPR)*)? ']'
ARRAY_DECL ::= '[' (EXPR (',' EXPR)*)? ']'
TUPLE_DECL ::= '(' (IDENT '=')? EXPR (',' (IDENT '=')? EXPR)* ')'
@@ -62,31 +62,33 @@ STRUCT_DECL ::= '{' IDENT '=' EXPR (',' IDENT '=' EXPR)* '}'
### Variables
```
-DECL ::= LET_DECL | VAR_DECL | CONST_DECL
-LET_DECL ::= 'let' GROUP (':' TYPE_DESC)? '=' EXPR
-VAR_DECL ::= 'var' GROUP (':' TYPE_DESC)? ('=' EXPR)?
-CONST_DECL ::= 'pub'? 'const' GROUP (':' TYPE_DESC)? '=' EXPR
+DECL ::= LET_DECL | VAR_DECL | CONST_DECL | FUNC_DECL | TYPE_DECL
+LET_DECL ::= 'let' GROUP ANNOTATION? '=' EXPR
+VAR_DECL ::= 'var' GROUP ANNOTATION? ('=' EXPR)?
+CONST_DECL ::= 'pub'? 'const' GROUP ANNOTATION? '=' EXPR
GROUP ::= ('(' IDENT (',' IDENT)* ')') | IDENT
```
-## Types and Functions
+### Functions
```
-FUNC_DECL ::= SIGNATURE '=' (EXPR | STMT)
-SIGNATURE ::= 'pub'? ('pure' | 'yeet' | IDENT)? 'func' IDENT
- ('(' (PARAMETER (',' PARAMETER)?)? ')')?
- (':' TYPE_DESC)?
-PARAMETER ::= (IDENT (':' ('var' | 'static')? TYPE_DESC)?
+FUNC_DECL ::= SIGNATURE '=' (EXPR | STMT)
+SIGNATURE ::= 'pub'? ('pure' | 'yeet' | IDENT)? 'func' IDENT GENERICS? PARAMETERS?
+PARAMETERS ::= '(' (PARAMETER (',' PARAMETER)?)? ')'
+PARAMETER ::= ('var' | 'static')? IDENT ANNOTATION?
+GENERICS ::= '[' IDENT ANNOTATION? (',' IDENT ANNOTATION?)* ']'
+ANNOTATION ::= ':' TYPE_DESC
```
+### Types
```
-TYPE_DECL ::= 'pub'? 'type' IDENT '=' 'ref'? 'distinct'? TYPE_DESC
-TYPE_DESC ::= TUPLE_TYPE | STRUCT_TYPE | UNION_TYPE | ENUM_TYPE | INTERFACE | IDENT
+TYPE_DECL ::= 'pub'? 'type' IDENT GENERICS? '=' 'ref'? 'distinct'? TYPE_DESC
+TYPE_DESC ::= TUPLE_TYPE | STRUCT_TYPE | UNION_TYPE | ENUM_TYPE | INTERFACE | IDENT |
+ (TYPE_DESC ('|' TYPE_DESC)+)
TUPLE_TYPE ::= 'tuple' '[' (IDENT ':')? TYPE_DESC (',' (IDENT ':')? TYPE_DESC)* ']'
-STRUCT_TYPE ::= 'struct' '[' 'pub'? IDENT ':' TYPE_DESC' (',' 'pub'? IDENT ':' 'TYPE_DESC')* ']'
-# note: pub in structs conflicts w/ a structural system
-UNION_TYPE ::= 'union' '[' IDENT ':' TYPE_DESC' (',' IDENT ':' 'TYPE_DESC')* ']'
+STRUCT_TYPE ::= 'struct' '[' IDENT ANNOTATION (',' IDENT ANNOTATION)* ']'
+UNION_TYPE ::= 'union' '[' IDENT ANNOTATION (',' IDENT ANNOTATION)* ']'
ENUM_TYPE ::= 'enum' '[' IDENT ('=' EXPR)? (',' IDENT ('=' EXPR)?)* ']'
-FUNC_TYPE ::= 'func' ('(' (PARAMETER (',' PARAMETER)?)? ')')? (':' TYPE_DESC)?
+FUNC_TYPE ::= 'func' GENERICS? PARAMETERS? ANNOTATION?
INTERFACE ::= 'interface' '[' SIGNATURE (',' SIGNATURE)* ('for' TYPE_DESC)? ']'
```
@@ -137,8 +139,9 @@ STMT ::= SINGLE_STMT | STMT+
SINGLE_STMT ::= IF_STMT | WHEN_STMT | BLOCK_STMT | MATCH_STMT |
LOOP_STMT | WHILE_STMT | FOR_STMT |
IMPORT_STMT | EXPORT_STMT | MODULE_STMT |
- TYPE_DECL | FUNC_DECL | (EXPR ';')
+ DECL | (EXPR ';')
EXPR ::= IF_EXPR | WHEN_EXPR | BLOCK_EXPR | MATCH_EXPR |
MACRO_FUNC | MACRO_BLOCK |
- VALUE | APPLICATION | (STMT EXPR)
+ APPLICATION | OPERATION | PREFIX | SUFFIX |
+ VALUE | (STMT EXPR)
```