feat(parser + ast): function parsing support

This commit is contained in:
matteo 2026-01-31 13:24:44 +01:00
parent a63632005c
commit 132f4f3a53
5 changed files with 54 additions and 11 deletions

View file

@ -23,7 +23,7 @@ struct ast *ast_create_function(char *name, struct ast *value)
if (!function_data)
return NULL;
function_data->name = strdup(name);
function_data->name = name;
function_data->value = value;
return ast_create(AST_FUNCTION, function_data);

View file

@ -9,18 +9,19 @@ struct ast_function
/**
* Checks if the given AST node is an ast_function
* @brief: Checks if the given AST node is an ast_function
*/
bool ast_is_function(struct ast *node);
/**
* Retrieves the function data from the given AST node.
* Assumes that the node is of type AST_function.
* @brief: Retrieves the function data from the given AST node.
* Assumes that the node is of type AST_function.
*/
struct ast_function *ast_get_function(struct ast *node);
/**
* Creates a new AST node representing an AST_function
* @brief: Creates a new AST node representing an AST_function
* @warning: name must be already allocated.
*/
struct ast *ast_create_function(char *name, struct ast *value);
/*