summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2025-01-28 05:19:39 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2025-01-28 05:19:39 +0330
commit378aa3eee5db8c85b94f0d1852b82a259800fd40 (patch)
tree9178678d4c40e24b04c5b197eee39be35150b060 /src/compiler
parent5adca3ef1277b9e7f8f4d77e1b2ecce9ad78d76b (diff)
add automatic type finding to u64 values
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/ast-tree.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/compiler/ast-tree.c b/src/compiler/ast-tree.c
index b03754d..f26d1b5 100644
--- a/src/compiler/ast-tree.c
+++ b/src/compiler/ast-tree.c
@@ -683,23 +683,28 @@ bool astTreeParseConstant(ParserNode *parserNode, AstTreeVariables **variables,
size_t variables_size) {
ParserNodeVariableMetadata *node_metadata = parserNode->metadata;
- if (node_metadata->value == NULL || node_metadata->type == NULL ||
+ if (node_metadata->value == NULL ||
node_metadata->name->token != PARSER_TOKEN_IDENTIFIER) {
- printLog("Not yet supported");
+ printLog("Not supported");
return NULL;
}
- AstTree *type = astTreeParse(node_metadata->type, variables, variables_size);
- if (type == NULL) {
- goto RETURN_ERROR;
- }
-
AstTree *value =
astTreeParse(node_metadata->value, variables, variables_size);
if (value == NULL) {
goto RETURN_ERROR;
}
+ AstTree *type;
+ if (node_metadata->type == NULL) {
+ type = makeTypeOf(value);
+ } else {
+ type = astTreeParse(node_metadata->type, variables, variables_size);
+ if (type == NULL) {
+ goto RETURN_ERROR;
+ }
+ }
+
AstTreeVariable *variable = a404m_malloc(sizeof(*variable));
variable->type = type;
variable->value = value;