fix: build and .sh test file for functions
This commit is contained in:
parent
a63632005c
commit
3cd231f031
7 changed files with 12 additions and 7 deletions
|
|
@ -20,7 +20,8 @@ libutils_a_SOURCES = \
|
|||
ast/ast_loop.c \
|
||||
args/args.c \
|
||||
vars/vars.c \
|
||||
ast/ast_assignment.c
|
||||
ast/ast_assignment.c \
|
||||
ast/ast_function.c
|
||||
|
||||
libutils_a_CPPFLAGS = -I$(top_srcdir)/src
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ void ast_free(struct ast **node)
|
|||
{
|
||||
if (node == NULL || *node == NULL)
|
||||
{
|
||||
fprintf(stderr,
|
||||
fprintf(
|
||||
stderr,
|
||||
"WARNING: Internal error: failed to free AST node (NULL argument)");
|
||||
return;
|
||||
}
|
||||
|
|
@ -56,7 +57,8 @@ void ast_free(struct ast **node)
|
|||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "WARNING: Internal error: failed to free an AST node (Unknown "
|
||||
fprintf(stderr,
|
||||
"WARNING: Internal error: failed to free an AST node (Unknown "
|
||||
"type)");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "ast_base.h"
|
||||
#include "ast_command.h"
|
||||
#include "ast_end.h"
|
||||
#include "ast_function.h"
|
||||
#include "ast_if.h"
|
||||
#include "ast_list.h"
|
||||
#include "ast_loop.h"
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
#ifndef AST_FUNCTION_H
|
||||
#define AST_FUNCTION_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct ast_function
|
||||
{
|
||||
char *name;
|
||||
struct ast *value;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the given AST node is an ast_function
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ struct ast_loop *ast_get_loop(struct ast *node);
|
|||
/**
|
||||
* Creates a new AST node representing a loop.
|
||||
*/
|
||||
struct ast *ast_create_loop(struct ast* condition, struct ast* body);
|
||||
struct ast *ast_create_loop(struct ast *condition, struct ast *body);
|
||||
|
||||
/*
|
||||
* @brief: frees the given ast_loop and sets the pointer to NULL.
|
||||
|
|
|
|||
0
tests/func.sh
Normal file → Executable file
0
tests/func.sh
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue