summaryrefslogtreecommitdiff
path: root/src/compiler/ast-tree.h
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2025-02-12 11:55:38 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2025-02-12 11:55:38 +0330
commit5c336962d3d0a885a870708076f154ee422fee12 (patch)
tree6f24bf2de914d94fd309d34c7c82e8025692154b /src/compiler/ast-tree.h
parent217b2c70adfd60756591dd6b06b60279f805a596 (diff)
add if
Diffstat (limited to 'src/compiler/ast-tree.h')
-rw-r--r--src/compiler/ast-tree.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/compiler/ast-tree.h b/src/compiler/ast-tree.h
index 579d919..38a6f66 100644
--- a/src/compiler/ast-tree.h
+++ b/src/compiler/ast-tree.h
@@ -9,6 +9,7 @@ typedef enum AstTreeToken {
AST_TREE_TOKEN_KEYWORD_PRINT_U64,
AST_TREE_TOKEN_KEYWORD_RETURN,
+ AST_TREE_TOKEN_KEYWORD_IF,
AST_TREE_TOKEN_TYPE_TYPE,
AST_TREE_TOKEN_TYPE_FUNCTION,
@@ -106,6 +107,11 @@ typedef struct AstTreeReturn {
AstTree *value;
} AstTreeReturn;
+typedef struct AstTreeIf {
+ AstTree *condition;
+ AstTree *body;
+} AstTreeIf;
+
typedef struct AstTreeHelper {
AstTreeVariables **variables;
size_t variables_size;
@@ -129,7 +135,8 @@ AstTreeVariables copyAstTreeVariables(AstTreeVariables variables);
AstTreeRoot *makeAstTree(ParserNode *parsedRoot);
-bool pushVariable(AstTreeHelper *helper,AstTreeVariables *variables, AstTreeVariable *variable);
+bool pushVariable(AstTreeHelper *helper, AstTreeVariables *variables,
+ AstTreeVariable *variable);
AstTreeVariable *getVariable(AstTreeHelper *helper, char *name_begin,
char *name_end);
@@ -158,14 +165,17 @@ bool astTreeParseConstant(ParserNode *parserNode, AstTreeHelper *helper);
AstTree *astTreeParseVariable(ParserNode *parserNode, AstTreeHelper *helper);
+AstTree *astTreeParseIf(ParserNode *parserNode, AstTreeHelper *helper);
+
AstTreeFunction *getFunction(AstTree *value);
bool isConst(AstTree *value);
AstTree *makeTypeOf(AstTree *value);
bool typeIsEqual(const AstTree *type0, const AstTree *type1);
-bool isCircularDependencies(AstTreeHelper *helper,AstTreeVariable *variable,AstTree *tree);
+bool isCircularDependencies(AstTreeHelper *helper, AstTreeVariable *variable,
+ AstTree *tree);
-bool setAllTypesRoot(AstTreeRoot *root,AstTreeHelper *helper);
+bool setAllTypesRoot(AstTreeRoot *root, AstTreeHelper *helper);
bool setAllTypes(AstTree *tree, AstTreeFunction *function);
bool setTypesFunction(AstTree *tree);
bool setTypesPrintU64(AstTree *tree);
@@ -177,6 +187,7 @@ bool setTypesOperatorAssign(AstTree *tree);
bool setTypesOperatorInfix(AstTree *tree);
bool setTypesOperatorUnary(AstTree *tree);
bool setTypesVariableDefine(AstTree *tree);
+bool setTypesIf(AstTree *tree,AstTreeFunction *function);
bool setTypesAstVariable(AstTreeVariable *variable);
bool setTypesAstInfix(AstTreeInfix *infix);