Added return of node_init
parent
fa6c6f3849
commit
e8482f39ea
|
@ -10,8 +10,16 @@ typedef struct n {
|
||||||
struct n **children;
|
struct n **children;
|
||||||
} node_t;
|
} node_t;
|
||||||
|
|
||||||
// Export the initializer function, it is needed by the parser
|
/**Export the initializer function, it is needed by the parser
|
||||||
void node_init (
|
* @param *nd node to initialize
|
||||||
|
* @param type type of node (see nodetype.h)
|
||||||
|
* @param *data associated data. Declared void to allow any type
|
||||||
|
* @param n_children number of children
|
||||||
|
* @param ... variable argument list of child nodes (node_t *)
|
||||||
|
*
|
||||||
|
* @return Pointer to the initialized node
|
||||||
|
* */
|
||||||
|
node_t* node_init (
|
||||||
node_t *nd, node_index_t type, void *data, uint64_t n_children, ...
|
node_t *nd, node_index_t type, void *data, uint64_t n_children, ...
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -73,8 +73,8 @@ print_syntax_tree ( void )
|
||||||
//tree_print(root, 0);
|
//tree_print(root, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Changed so it returns the pointer to the new node, can be used as before, but makes the parser file cleaner
|
||||||
void
|
node_t*
|
||||||
node_init (node_t *nd, node_index_t type, void *data, uint64_t n_children, ...)
|
node_init (node_t *nd, node_index_t type, void *data, uint64_t n_children, ...)
|
||||||
{
|
{
|
||||||
va_list child_list;
|
va_list child_list;
|
||||||
|
@ -89,6 +89,8 @@ node_init (node_t *nd, node_index_t type, void *data, uint64_t n_children, ...)
|
||||||
for ( uint64_t i=0; i<n_children; i++ )
|
for ( uint64_t i=0; i<n_children; i++ )
|
||||||
nd->children[i] = va_arg ( child_list, node_t * );
|
nd->children[i] = va_arg ( child_list, node_t * );
|
||||||
va_end ( child_list );
|
va_end ( child_list );
|
||||||
|
|
||||||
|
return nd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue