EC_NODE_ONCE(3)

πŸ’– EC_NODE_ONCE πŸ’–

okay bestie, welcome to the libecoli programmer's manual, section 3 (that's the library functions girlies 🫢). today's main character is ec_node_once, and no cap, she's a little sneaky in the best way.


✨ NAME ✨

ec_node_once β€” this node behaves like its child, but it stops that child from being parsed more than once. like, one and done. periodt. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <ecoli/node_once.h>

struct ec_node * ec_node_once(
    const char       *id,
    struct ec_node   *child
);

🌸 DESCRIPTION 🌸

so the vibe is: ec_node_once wraps around a child node and is literally just its child... except it keeps count. once the child has been parsed one time, that's it, that's the whole era, she's not doing it again. 🧚

here's the example from the manual, verbatim bestie:

many(
  or(
    once(str("foo")),
    str("bar")))

Matches: [], ["foo", "bar"], ["bar", "bar"], ["foo", "bar", "bar"], ...

But not: ["foo", "foo"], ["foo", "bar", "foo"], ...

see how "foo" shows up at most once in every matching list? that's the once doing its one-time-only thing. it ate and left no crumbs. πŸ”₯

⚠️ important warning time, and I'm not being dramatic: on error, the child is not freed. so like, if something goes wrong, that child is still out here in the world and it's your problem now, not this node's. lowkey crucial. πŸ’€

πŸ” SEE ALSO πŸ”

  • ec_node_once_set_child(3) β€” yeah you're gonna want to go read her too, she's the one who handles the whole child situation. iykyk. πŸ’œ

Copyright (C) 2010-2026 Olivier Matz, Robin Jarry.


and that's the whole page bestie, you're so welcome πŸ’– stay iconic, read your manpages, and remember: some things are only meant to happen once 🌈

libecoli Β· 2026-06-11 Β· EC_NODE_ONCE(3) β€” mwah, catch you on the next one πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from