python-plus-plus/ppp/ppp_ast.ppp
germax26 66cd54e532
Move .ppp files into ppp/ directory
I plan to make a few changes to my language, and I will then update
these files later. I am moving them because I don't want them
polluting the main directory. I probably should have done this to
begin with, but better late than never.
2024-08-11 11:35:49 +10:00

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
}