Created
October 4, 2017 17:40
-
-
Save exerro/f06bebdb703a8fe9fbcaebcca3d6e5da to your computer and use it in GitHub Desktop.
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
grammar Flux; | |
type Name = string[] | |
enum AST { | |
enum RootStatement { | |
NamespaceStatement(Name, RootStatement[]) | |
EnumDefinition(Name, Template, EnumBody) | |
ClassDefinition(bool, bool, Name, Template, Type.Reference, Type.Reference[], ClassBodyStatement[]) // final abstract | |
StructDefinition(Name, Template, Type.Reference[], ClassBodyStatement[]) | |
TypeDefinition(Name, Template, Type) | |
StatementInRoot(Statement) | |
} | |
enum Statement { | |
IfStatement(Expression, Block, Block?) | |
WhileLoop(Expression, Block) | |
RepeatLoop(Block, string, Expression) | |
ForeachLoop(string, string?, Expression, Block) | |
TryStatement(Block, CatchBlock[], Block?) | |
LetStatement(Pattern, Expression) | |
NewStatement(Type, Name, int?, Expression[]) | |
UseStatement(Expression) | |
ReturnStatement(Expression?) | |
DefinitionStatement(Definition) | |
ExpressionStatement(Expression) | |
BreakStatement | |
ContinueStatement | |
} | |
enum Definition { | |
VariableDefinition(Extern?, bool, Type, Name, Expression?) | |
FunctionDefinition(Extern?, bool, Type, Name, string?, Template, (Type, string)[], Block?) | |
} | |
enum Expression { | |
enum Primary { | |
PrimitiveLiteral(LiteralType, string) | |
ArrayLiteral(Expression[]) | |
StructLiteral((Type, string, Expression)[]) | |
Lambda(Pattern[], Expression) | |
New(Type, int?, Expression[]) | |
Tuple(Expression[]) | |
Reference(Name, Template?) | |
Match(Expression, (Pattern, Expression)[], Expression?) | |
Match(Expression, (Expression, Expression)[], Expression?) | |
} | |
Operative(string, Expression[]) | |
Typed(string, Expression, Type) | |
} | |
enum Type { | |
Reference(Name, Type[]) | |
Function(Type[], Type) | |
Enum(EnumBody) | |
Struct((Type, string)[]) | |
Tuple(Type[]) | |
} | |
enum Pattern { | |
Name(string) | |
TypedName(Type, string) | |
Enum(string, Pattern[]) | |
Tuple(Pattern[]) | |
Struct((Type?, string, Pattern)[]) | |
Literal(LiteralType, string) | |
} | |
Block(Statement[]) | |
RootBlock(RootStatement[]) | |
enum LiteralType { | |
String, Character, Float, Integer, Boolean, Null | |
} | |
enum TemplateType { | |
Generic(string) | |
Type(Type) | |
} | |
enum ClassBodyStatement { | |
GlobalAccessModifier(bool) | |
ConstructorDefinition(string, (Type, string)[], string[], Block) | |
CastDefinition(Type, Block) | |
MemberDefinition(bool, Definition) | |
} | |
enum EnumBodyMember { | |
EnumDefinition(RootStatement.EnumDefinition) | |
MemberDefinition(string, Type[]) | |
} | |
Template(TemplateType[]) | |
Extern(String, (string, string)[]) | |
CatchBlock(Type, string, Block) | |
EnumBody(EnumBodyMember[]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment