Last active
October 9, 2023 19:32
-
-
Save JCBurnside/e0610a939a95292400c743ce65d6d603 to your computer and use it in GitHub Desktop.
a document detailing the design of the ast for my lange fflat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Program is | |
Declaration+ | |
TopLevelDeclaration is | |
"type" Ident = '{' FieldDeclaration* '}' | |
"enum" Ident = ('|' EnumDeclaration)* | |
Declaration | |
"for<"(Ident',')+'>' TopLevelDeclaration | |
Declaration is | |
"let" "fn"? Ident ArgDeclaration* (':' Type)? = FnBody | |
FieldDeclaration is | |
Ident : Type; | |
EnumDeclaration is | |
Ident | |
Ident Type | |
Ident '{' FieldDeclaration* '}' | |
ArgDeclaration is | |
Ident | |
'('Ident ':' Type')' | |
'_' | |
"( _ :" Type')' | |
Type is | |
Ident | |
Ident'<'Type'>' | |
Type -> Type | |
'('Type')' | |
'['Type;number']' | |
'('(Type',')+')' | |
"()" | |
Ident is string that is not op or number | |
FnBody is | |
Statement;+Expr? | |
Expr | |
Statement is | |
"return" Expr | |
Declaration | |
If | |
Match | |
FnCall | |
Op is | |
string of '|' | '>' | '<' | '!' | '@' | '$' | '=' | '&' | '+' | '-' | '\\' | '/' | '*' | '^' | '.' | |
Expr is | |
Literal | |
FnCall | |
'('Expr')' | |
Expr Op Expr | |
Op Expr | |
If | |
Match | |
If is | |
"if" Expr "then" FnBody | |
(else FnBody)? | |
Match is | |
match Expr where | |
MatchArm + | |
MatchArm is | |
Condition -> Expr, | |
Condition -> | |
(Statement';')+ | |
Expr? | |
Condition is | |
'|' Literal ('|'Condition)* | |
'|' Ident | |
"| _" | |
Literal is | |
ArrayLiteral | |
number | |
'\''char'\'' | |
'"'string'"' | |
'('(Expr',')+')' | |
"()" | |
ArrayLiteral is | |
'['Expr';'number']' | |
'['(Expr',')+']' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment