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 \
|
ast/ast_loop.c \
|
||||||
args/args.c \
|
args/args.c \
|
||||||
vars/vars.c \
|
vars/vars.c \
|
||||||
ast/ast_assignment.c
|
ast/ast_assignment.c \
|
||||||
|
ast/ast_function.c
|
||||||
|
|
||||||
libutils_a_CPPFLAGS = -I$(top_srcdir)/src
|
libutils_a_CPPFLAGS = -I$(top_srcdir)/src
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ void ast_free(struct ast **node)
|
||||||
{
|
{
|
||||||
if (node == NULL || *node == NULL)
|
if (node == NULL || *node == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(
|
||||||
|
stderr,
|
||||||
"WARNING: Internal error: failed to free AST node (NULL argument)");
|
"WARNING: Internal error: failed to free AST node (NULL argument)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +57,8 @@ void ast_free(struct ast **node)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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)");
|
"type)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "ast_base.h"
|
#include "ast_base.h"
|
||||||
#include "ast_command.h"
|
#include "ast_command.h"
|
||||||
#include "ast_end.h"
|
#include "ast_end.h"
|
||||||
|
#include "ast_function.h"
|
||||||
#include "ast_if.h"
|
#include "ast_if.h"
|
||||||
#include "ast_list.h"
|
#include "ast_list.h"
|
||||||
#include "ast_loop.h"
|
#include "ast_loop.h"
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ struct ast *ast_create_function(char *name, struct ast *value)
|
||||||
if (!function_data)
|
if (!function_data)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
function_data->name = strdup(name);
|
function_data->name = name;
|
||||||
function_data->value = value;
|
function_data->value = value;
|
||||||
|
|
||||||
return ast_create(AST_FUNCTION, function_data);
|
return ast_create(AST_FUNCTION, function_data);
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
#ifndef AST_FUNCTION_H
|
#ifndef AST_FUNCTION_H
|
||||||
#define AST_FUNCTION_H
|
#define AST_FUNCTION_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
struct ast_function
|
struct ast_function
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
struct ast *value;
|
struct ast *value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given AST node is an ast_function
|
* Checks if the given AST node is an ast_function
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
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