diff --git a/src/operations/node.c b/src/operations/node.c index a1f5404..083d9b4 100644 --- a/src/operations/node.c +++ b/src/operations/node.c @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include #include #include "node.h" #include "operators.h" @@ -10,7 +10,7 @@ #include "../variables/variable.h" /* creates a new node and returns it */ -struct Node* make_node(int type, struct Value* value, char* id) { +struct Node* make_node(int type, struct Value* value, std::string id) { int i; /* allocate space */ @@ -19,7 +19,7 @@ struct Node* make_node(int type, struct Value* value, char* id) { /* set properties */ node->type = type; node->value = value; - strcpy(node->id, id); + id.copy(node->id, id.length(), 0); node->num_children = 0; for(i = 0; i < MAX_CHILDREN; i++) { node->children[i] = NULL; @@ -37,9 +37,9 @@ void attach_node(struct Node* parent, struct Node* child) { assert(parent->num_children <= MAX_CHILDREN); } -void check_num_nodes(struct Node* node, int num_children, char* error) { +void check_num_nodes(struct Node* node, int num_children, std::string error) { if (node && node->num_children != num_children) { - fprintf(stderr, "%s%s%s", "Error, ", error, "\n"); + std::cerr << "Error, " << error << std::endl; } } diff --git a/src/operations/node.h b/src/operations/node.h index d1db734..16af7cb 100644 --- a/src/operations/node.h +++ b/src/operations/node.h @@ -1,6 +1,7 @@ #ifndef NODE_H #define NODE_H +#include #include "../variables/value.h" #include "../variables/environment.h" @@ -21,7 +22,7 @@ struct Node { }; // Abstract Syntax Tree Functions -struct Node* make_node(int type, struct Value* value, char* id); +struct Node* make_node(int type, struct Value* value, std::string id); void attach_node(struct Node* parent, struct Node* child); void print_tree(struct Node* node, int tabs); void delete_tree(struct Node* node);