Skip to content

Commit 3783a8a

Browse files
committed
feat: Add initial Abstract Syntax Tree (AST) definitions for ProXPL expressions, statements, and type system.
1 parent f8d3e0c commit 3783a8a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

include/ast.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ typedef enum {
3737
EXPR_VARIABLE, EXPR_ASSIGN, EXPR_LOGICAL, EXPR_CALL,
3838
EXPR_GET, EXPR_SET, EXPR_INDEX, EXPR_LIST,
3939
EXPR_DICTIONARY, EXPR_TERNARY, EXPR_LAMBDA,
40-
EXPR_AWAIT
40+
EXPR_AWAIT, EXPR_THIS, EXPR_SUPER, EXPR_NEW
4141
} ExprType;
4242

4343
typedef enum {
@@ -105,6 +105,9 @@ typedef struct { DictPairList *pairs; } DictionaryExpr;
105105
typedef struct { Expr *condition; Expr *true_branch; Expr *false_branch; } TernaryExpr;
106106
typedef struct { StringList *params; StmtList *body; } LambdaExpr;
107107
typedef struct { Expr *expression; } AwaitExpr;
108+
typedef struct { int dummy; } ThisExpr;
109+
typedef struct { char *method; } SuperExpr;
110+
typedef struct { Expr *clazz; ExprList *args; } NewExpr;
108111

109112
struct Expr {
110113
ExprType type;
@@ -117,6 +120,7 @@ struct Expr {
117120
LogicalExpr logical; CallExpr call; GetExpr get; SetExpr set;
118121
IndexExpr index; ListExpr list; DictionaryExpr dictionary;
119122
TernaryExpr ternary; LambdaExpr lambda; AwaitExpr await_expr;
123+
ThisExpr this_expr; SuperExpr super_expr; NewExpr new_expr;
120124
} as;
121125
};
122126

@@ -170,6 +174,9 @@ Expr *createDictionaryExpr(DictPairList *pairs, int line, int column);
170174
Expr *createTernaryExpr(Expr *cond, Expr *true_br, Expr *false_br, int line, int column);
171175
Expr *createLambdaExpr(StringList *params, StmtList *body, int line, int column);
172176
Expr *createAwaitExpr(Expr *expression, int line, int column);
177+
Expr *createThisExpr(int line, int column);
178+
Expr *createSuperExpr(const char *method, int line, int column);
179+
Expr *createNewExpr(Expr *clazz, ExprList *args, int line, int column);
173180

174181
Stmt *createExpressionStmt(Expr *expression, int line, int column);
175182
Stmt *createVarDeclStmt(const char *name, Expr *init, bool is_const, int line, int column);

0 commit comments

Comments
 (0)