aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJJ2023-07-25 05:34:50 +0000
committerJJ2023-07-25 05:49:03 +0000
commit1fa5634540667e0431fe6e157b278dc294dd9db1 (patch)
tree32223f92eba0ec9d1b6111216de66aa04889965b
parentf2a8b4607de5d8832ba97be7d0222ed8e2ebea89 (diff)
docs: forgot about generics
-rw-r--r--README.md2
-rw-r--r--docs/SYNTAX.md41
2 files changed, 23 insertions, 20 deletions
diff --git a/README.md b/README.md
index aa569be..722730f 100644
--- a/README.md
+++ b/README.md
@@ -27,7 +27,7 @@ This is the language I keep in my head. It sprung from a series of unstructured
## How do I learn more?
-- The [basic usage](docs/BASIC.md) document lays out the fundamental grammar of Puck.
+- The [basic usage](docs/BASIC.md) document lays out the fundamental semantics of Puck.
- The [syntax](docs/SYNTAX.md) document provides a deeper and formal look into the grammar of Puck.
- The [type system](docs/TYPES.md) document gives an in-depth analysis of Puck's extensive type system. <!-- and its relationship to classes and other abstractions. -->
- The [memory management](docs/MEMORY_MANAGEMENT.md) document gives an overview of Puck's memory model. <!-- which is considered a mashup of the models pioneered by Lobster, Rust, and Nim. -->
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)
```