95 lines
2.3 KiB
Plaintext
95 lines
2.3 KiB
Plaintext
|
enum TypeExpression {
|
||
|
Tuple(TypeExpression[]),
|
||
|
Union(TypeExpression[]),
|
||
|
List(TypeExpression),
|
||
|
Array(TypeExpression, int),
|
||
|
Name(str),
|
||
|
Specification(TypeExpression, TypeExpression[]),
|
||
|
Function(TypeExpression[], TypeExpression)
|
||
|
}
|
||
|
|
||
|
enum OptionalTypeExpression {
|
||
|
Some(TypeExpression),
|
||
|
None
|
||
|
}
|
||
|
|
||
|
struct TypeDeclaration {
|
||
|
name: str,
|
||
|
type_: TypeExpression
|
||
|
}
|
||
|
|
||
|
struct EnumEntry {
|
||
|
name: str,
|
||
|
types: TypeExpression[]
|
||
|
}
|
||
|
|
||
|
|
||
|
enum Expression {
|
||
|
FunctionCall(Expression, Expression[]),
|
||
|
Variable(str),
|
||
|
ArrayAccess(Expression, Expression),
|
||
|
Array(Expression[]),
|
||
|
FieldAccess(Expression, str),
|
||
|
Number(int),
|
||
|
String(str),
|
||
|
Tuple(Expression[]),
|
||
|
StructInstantiation(Expression, (str, Expression)[]),
|
||
|
LoopComrehension(Expression, str, Expression),
|
||
|
Dictionary((Expression, Expression)[]),
|
||
|
DictComprehension((Expression, Expression), str, Expression),
|
||
|
Return(Expression),
|
||
|
Ternary(Expression, Expression, Expression),
|
||
|
Or(Expression, Expression),
|
||
|
And(Expression, Expression),
|
||
|
Bor(Expression, Expression),
|
||
|
Bxor(Expression, Expression),
|
||
|
Band(Expression, Expression),
|
||
|
Equal(Expression, Expression),
|
||
|
NotEqual(Expression, Expression),
|
||
|
LessThan(Expression, Expression),
|
||
|
GreaterThan(Expression, Expression),
|
||
|
LessThanOrEqual(Expression, Expression),
|
||
|
GreaterThanOrEqual(Expression, Expression),
|
||
|
ShiftLeft(Expression, Expression),
|
||
|
ShiftRight(Expression, Expression),
|
||
|
Addition(Expression, Expression),
|
||
|
Subtract(Expression, Expression),
|
||
|
Multiplication(Expression, Expression),
|
||
|
Division(Expression, Expression),
|
||
|
Modulo(Expression, Expression),
|
||
|
Bnot(Expression),
|
||
|
Not(Expression),
|
||
|
UnaryPlus(Expression),
|
||
|
UnaryMinus(Expression)
|
||
|
}
|
||
|
|
||
|
enum OptionalExpression {
|
||
|
Some(Expression),
|
||
|
None
|
||
|
}
|
||
|
|
||
|
|
||
|
enum Statement {
|
||
|
Statements(Statement[]),
|
||
|
EnumDefinition(str, EnumEntry[]),
|
||
|
StructDefinition(str, TypeDeclaration[]),
|
||
|
FunctionDefinition(str, TypeDeclaration[], OptionalTypeExpression, Statement),
|
||
|
Expression(Expression),
|
||
|
Assignment(Expression, Expression, OptionalTypeExpression),
|
||
|
TypeDeclaration(TypeDeclaration),
|
||
|
If(Expression, Statement, OptionalStatement),
|
||
|
While(Expression, Statement),
|
||
|
DoWhile(Statement, OptionalExpression),
|
||
|
Break,
|
||
|
Continue,
|
||
|
Match(Expression, (Expression, Statement)[]),
|
||
|
Assert(Expression, OptionalExpression),
|
||
|
ForLoop(str, Expression, Statement),
|
||
|
Import(Expression),
|
||
|
TypeDefinition(str, TypeExpression)
|
||
|
}
|
||
|
|
||
|
enum OptionalStatement {
|
||
|
Some(Statement),
|
||
|
None
|
||
|
}
|