ec_node_iter - Man Page

Create an iterator on a grammar tree.

Synopsis

#include <ecoli/node.h>

struct ec_node_iter * ec_node_iter(
    struct ec_node   *node   /* The grammar graph to iterate */
);

Description

A grammar tree is actually not really a tree, it is an oriented graph where loops can exist. For this reason, it is not possible to iterate the grammar graph without storing somewhere the list of browsed nodes in order to break loops.

Another property of grammar graphs is that the same node can appear several times at different places in the graph, having a different parent. This kind of node will be iterated only once.

The typical use is:

struct ec_node_iter *iter_root, *iter;

iter_root = ec_node_iter(node);
if (iter_root == NULL)
   goto fail;

for (iter = iter_root; iter != NULL;
     iter = ec_node_iter_next(iter_root, iter, true)) {
   do_something_with(ec_node_iter_get_node(iter));
}

ec_node_iter_free(iter_root);

Technically, this function builds a tree from the grammar graph. Each node of this tree references a node of the grammar graph.

Return Value

The grammar graph iterator on success, that must be freed using ec_node_iter_free(). Return NULL on error.

See Also

ec_node_check_type(3), ec_node_attrs(3), ec_node_find(3), ec_node_type_name(3), ec_node_free(3), ec_node_id(3), ec_node_type_dump(3), ec_node_get_config(3), ec_node_schema_dump(3), ec_node_priv(3), ec_node_type_lookup(3), ec_node_clone(3), ec_node_dump(3), ec_node_desc(3), ec_node_iter_free(3), ec_node_iter_get_parent(3), ec_node_from_type(3), ec_node_type(3), ec_node_iter_next(3), ec_node_type_schema(3), ec_node(3), ec_node_get_children_count(3), ec_node_get_type_name(3), ec_node_type_register(3), ec_node_set_config(3), ec_node_iter_get_node(3), ec_node_get_child(3)

Referenced By

ec_node(3), ec_node_attrs(3), ec_node_check_type(3), ec_node_clone(3), ec_node_desc(3), ec_node_dump(3), ec_node_find(3), ec_node_free(3), ec_node_from_type(3), ec_node_get_child(3), ec_node_get_children_count(3), ec_node_get_config(3), ec_node_get_type_name(3), ec_node_id(3), ec_node_iter_free(3), ec_node_iter_get_node(3), ec_node_iter_get_parent(3), ec_node_iter_next(3), ec_node_priv(3), ec_node_schema_dump(3), ec_node_set_config(3), ec_node_type(3), ec_node_type_dump(3), ec_node_type_lookup(3), ec_node_type_name(3), ec_node_type_register(3), ec_node_type_schema(3).

2026-06-11 Libecoli Programmer's Manual