EC_PARSE_CHILD(3)

πŸ’– EC_PARSE_CHILD β€” bestie edition πŸ’–

okay so we're in the Libecoli Programmer's Manual today, section 3, and the star of the show is ec_parse_child. grab a lil snack, this one's a bop πŸ“


✨ NAME ✨

ec_parse_child β€” parse a string vector using a grammar tree, from a parent node.

it's giving "the middle-manager of parsing" and honestly? iconic behavior πŸ‘‘


🌸 SYNOPSIS 🌸

#include <ecoli/parse.h>

int ec_parse_child(
    const struct ec_node     *node,    /* The grammar node. */
    struct ec_pnode          *pstate,  /* The node of the parsing tree. */
    const struct ec_strvec   *strvec   /* The input string vector. */
);

three arguments, no drama, we love a clean signature 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe. this function is usually called from an intermediate node β€” think ec_node_seq(), ec_node_or(), you know the ones β€” and its whole job is to backfill the parsing tree. that tree gets built piece by piece while you're browsing the grammar tree, like a lil puzzle 🧩

and like, here's what actually goes down: ec_parse_child() creates a new child in this parsing tree, and then it calls the parse() method for that child node, with pstate pointing to this new child.

then the moment of truth:

  • if it does not match, the child gets removed from the state πŸ™ˆ
  • if it matches, the child is kept, along with its possible descendants πŸ’…

that's it. that's the whole function. no cap.


⭐ RETURN VALUE ⭐

okay bestie, pay attention, this part matters:

  • On success: the number of matched elements in the input string vector β€” and yes, that can totally be 0, zero is a valid slay β€” or EC_PARSE_NOMATCH (which is a positive value) if the input does not match the grammar.
  • On error: -1 is returned, and errno is set. 😭
lowkey important: EC_PARSE_NOMATCH is positive, so don't go treating it like an error code. it's just the grammar saying "nope, not today."

πŸ”₯ SEE ALSO πŸ”₯

the whole friend group, fr fr β€” go read these next:


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


and that's the whole page, bestie πŸ’œ this has been EC_PARSE_CHILD(3) from libecoli, dated 2026-06-11 β€” thanks for coming to my ted talk, go forth and parse responsibly, mwah πŸ’…βœ¨πŸŽ€πŸŒˆ

πŸ“¦ where this page comes from