EC_NODE_ITER(3)
π EC_NODE_ITER(3) π
okay bestie, sit down, hydrate, and let me tell you about ec_node_iter β it's the cutie from the Libecoli Programmer's Manual that builds you an iterator on a grammar tree, and honestly? she's doing the most. β¨
πΈ NAME πΈ
ec_node_iter β 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 π¦
okay so first thing, bestie, plot twist: a grammar tree is not actually a tree. π It's an oriented graph, which means loops can exist in it. Which is iconic of her but also means you literally cannot just walk the grammar graph without storing somewhere the list of browsed nodes, because if you don't you will loop forever and that's not the vibe. π So yeah β we keep track. Loop-breaking is mandatory, no cap.
Second thing: the same node can show up several times at different places in the graph, and it can have a different parent each time. Not me showing up to three different parties with three different outfits. π Anyway β this kind of node will be iterated only once. One node, one appearance in the iteration. Periodt.
The typical use is giving:
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);
look at that little for-loop. she ate. π₯
Technically β and this is the lowkey nerdy part that I'm obsessed with β this function builds a tree from the grammar graph. Each node of this tree references a node of the grammar graph. So the graph stays the graph, the tree is the tour guide. π§
β RETURN VALUE β
The grammar graph iterator on success β and you must free it using ec_node_iter_free(), do not leave her hanging bestie. π
Returns 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)
that's the whole friend group right there. go say hi. π«Ά
π COPYRIGHT π
Copyright (C) 2010-2026 Olivier Matz, Robin Jarry.
and that's the tea, bestie β¨ this whole page came straight outta libecoli, version-dated 2026-06-11, filed under EC_NODE_ITER(3) β love her, follow her, free your iterators. πππ¦πΈπ
π¦ where this page comes from
- fedora 44: libecoli-devel 0.11.7-1.fc44 Β· BSD-3-Clause AND LicenseRef-Fedora-Public-Domain
- fedora 44: libecoli-devel 0.11.7-1.fc44 Β· BSD-3-Clause AND LicenseRef-Fedora-Public-Domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms