Skip to content

Instantly share code, notes, and snippets.

@JCBurnside
Last active October 9, 2023 19:32
Show Gist options
  • Save JCBurnside/e0610a939a95292400c743ce65d6d603 to your computer and use it in GitHub Desktop.
Save JCBurnside/e0610a939a95292400c743ce65d6d603 to your computer and use it in GitHub Desktop.
a document detailing the design of the ast for my lange fflat
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