diff options
author | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-02-08 02:16:05 +0330 |
---|---|---|
committer | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-02-08 02:16:05 +0330 |
commit | 1460877dca47ab740eef3a5529cd30008e1a27a5 (patch) | |
tree | d02752f617157d0cfd3d037bd69280e0acd094b3 /src/compiler/ast-tree.c | |
parent | 1b8c8fb55ae5a2bc48951b65b01eb83d75ab4715 (diff) |
add const check
fix some bugs
Diffstat (limited to 'src/compiler/ast-tree.c')
-rw-r--r-- | src/compiler/ast-tree.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/compiler/ast-tree.c b/src/compiler/ast-tree.c index 3ea860e..f5867cc 100644 --- a/src/compiler/ast-tree.c +++ b/src/compiler/ast-tree.c @@ -554,6 +554,7 @@ AstTree *astTreeParse(ParserNode *parserNode, AstTreeVariables **variables, case PARSER_TOKEN_OPERATOR_SUM: return astTreeParseSum(parserNode, variables, variables_size); case PARSER_TOKEN_VARIABLE: + return astTreeParseVariable(parserNode, variables, variables_size); case PARSER_TOKEN_CONSTANT: case PARSER_TOKEN_SYMBOL_EOL: case PARSER_TOKEN_SYMBOL_PARENTHESIS: @@ -638,10 +639,6 @@ AstTree *astTreeParseFunction(ParserNode *parserNode, if (!astTreeParseConstant(node, variables, variables_size)) { goto RETURN_ERROR; } - } else if (node->token == PARSER_TOKEN_VARIABLE) { - if (!astTreeParseConstant(node, variables, variables_size)) { - goto RETURN_ERROR; - } } else { AstTree *tree = astTreeParse(node, variables, variables_size); @@ -1263,6 +1260,9 @@ bool setTypesOperatorAssign(AstTree *tree) { } else if (!typeIsEqual(infix->left.type, infix->right.type)) { printLog("Type mismatch"); return false; + } else if(isConst(&infix->left)){ + printLog("Constants can't be assigned"); + return false; } else { tree->type = copyAstTree(infix->left.type); return true; |