diff options
author | Flavian Kaufmann <flavian@flaviankaufmann.ch> | 2025-05-20 08:03:20 +0200 |
---|---|---|
committer | Flavian Kaufmann <flavian@flaviankaufmann.ch> | 2025-05-20 08:03:20 +0200 |
commit | 77339ce34a79a7b5a1818c1009d1db1252fe8ea6 (patch) | |
tree | 0fa1cc0819b0be255dd37b0774d088b11fc0cc92 /ast.h | |
parent | ee64135583d5ba02b57cd520bb50ca8819d37bff (diff) | |
download | imp-77339ce34a79a7b5a1818c1009d1db1252fe8ea6.tar.gz imp-77339ce34a79a7b5a1818c1009d1db1252fe8ea6.zip |
cleanup
Diffstat (limited to 'ast.h')
-rw-r--r-- | ast.h | 35 |
1 files changed, 19 insertions, 16 deletions
@@ -13,30 +13,33 @@ typedef enum { ROP_EQ, ROP_NE, ROP_LT, ROP_LE, ROP_GT, ROP_GE } ROp; typedef struct ASTNode { NodeType type; union { - int val; - char *var; - struct { struct ASTNode *var, *aexp; } assign; - struct { struct ASTNode *exp1, *exp2; union { AOp aop; BOp bop; ROp rop; } op;} bin; - struct ASTNode *bexp; - struct { struct ASTNode *bexp, *s1, *s2; } cond; - struct { struct ASTNode *s1, *s2; } seq; + struct { struct ASTNode *var, *aexp; } d_assign; + struct { struct ASTNode *stm1, *stm2; } d_seq; + struct { struct ASTNode *bexp, *stm1, *stm2; } d_if; + struct { struct ASTNode *bexp, *stm; } d_while; + struct { int val; } d_int ; + struct { char *name; } d_var; + struct { AOp aop; struct ASTNode *aexp1, *aexp2; } d_aop; + struct { BOp bop; struct ASTNode *bexp1, *bexp2; } d_bop; + struct { struct ASTNode *bexp; } d_not; + struct { ROp rop; struct ASTNode *aexp1, *aexp2; } d_rop; } u; } ASTNode; ASTNode *ast_skip(void); ASTNode *ast_assign(ASTNode *var, ASTNode *aexp); -ASTNode *ast_seq(ASTNode *s1, ASTNode *s2); -ASTNode *ast_if(ASTNode *bexp, ASTNode *s1, ASTNode *s2); -ASTNode *ast_while(ASTNode *bexp, ASTNode *s); +ASTNode *ast_seq(ASTNode *stm1, ASTNode *stm2); +ASTNode *ast_if(ASTNode *bexp, ASTNode *stm1, ASTNode *stm2); +ASTNode *ast_while(ASTNode *bexp, ASTNode *stm); ASTNode *ast_int(int val); -ASTNode *ast_var(char *var); -ASTNode *ast_aop(AOp, ASTNode *aexp1, ASTNode *aexp2); -ASTNode *ast_bop(BOp, ASTNode *bexp1, ASTNode *bexp2); +ASTNode *ast_var(char *name); +ASTNode *ast_aop(AOp aop, ASTNode *aexp1, ASTNode *aexp2); +ASTNode *ast_bop(BOp bop, ASTNode *bexp1, ASTNode *bexp2); ASTNode *ast_not(ASTNode *bexp); -ASTNode *ast_rop(ROp, ASTNode *aexp1, ASTNode *aexp2); +ASTNode *ast_rop(ROp rop, ASTNode *aexp1, ASTNode *aexp2); -void exec_stmt(ASTNode *n); -void free_ast(ASTNode *n); +void exec_stmt(ASTNode *node); +void free_ast(ASTNode *node); void env_print(void); #endif |