145#define EC_PARSE_NOMATCH INT_MAX
212#define EC_PNODE_GET_ROOT(parse) \
214 const struct ec_pnode *p_ = parse; \
215 struct ec_pnode *pnode_ = (struct ec_pnode *)parse; \
216 __typeof__(parse) res_; \
218 res_ = ec_pnode_get_root(pnode_); \
286#define EC_PNODE_FOREACH_CHILD(child, pnode) \
287 for (child = ec_pnode_get_first_child(pnode); child != NULL; child = ec_pnode_next(child))
401__ec_pnode_iter_next(
const struct ec_pnode *root,
struct ec_pnode *pnode,
bool iter_children);
415#define EC_PNODE_ITER_NEXT(root, parse, iter_children) \
417 const struct ec_pnode *p_ = parse; \
418 struct ec_pnode *pnode_ = (struct ec_pnode *)parse; \
419 __typeof__(parse) res_; \
421 res_ = __ec_pnode_iter_next(root, pnode_, iter_children); \
433#define EC_PNODE_FOREACH(iter, root) \
434 for ((iter) = (root); (iter) != NULL; (iter) = EC_PNODE_ITER_NEXT((root), (iter), true))
struct ec_dict * ec_dict(void)
Create a hash table.
struct ec_node * ec_node(const char *typename, const char *id)
Create a new node from its type name.
int ec_parse_child(const struct ec_node *node, struct ec_pnode *pstate, const struct ec_strvec *strvec)
Parse a string vector using a grammar tree, from a parent node.
bool ec_pnode_matches(const struct ec_pnode *pnode)
Check if the parsing tree matches the input.
struct ec_pnode * ec_pnode_next(const struct ec_pnode *pnode)
Get the next sibling node.
struct ec_pnode * ec_pnode_get_parent(const struct ec_pnode *pnode)
Get the parent node in the parsing tree.
struct ec_dict * ec_pnode_get_attrs(const struct ec_pnode *pnode)
Get attributes associated with a node in a parsing tree.
struct ec_pnode * ec_parse(const struct ec_node *node, const char *str)
Parse a string using a grammar tree.
void ec_pnode_del_last_child(struct ec_pnode *pnode)
Unlink and free the last child.
void ec_pnode_link_child(struct ec_pnode *pnode, struct ec_pnode *child)
Link a parsing node to a parsing tree.
struct ec_pnode * ec_pnode_get_last_child(const struct ec_pnode *pnode)
Get the last child of a node in the parsing tree.
struct ec_pnode * ec_parse_strvec(const struct ec_node *node, const struct ec_strvec *strvec)
Parse a string vector using a grammar tree.
void ec_pnode_dump(FILE *out, const struct ec_pnode *pnode)
Dump a parsing tree.
void ec_pnode_free(struct ec_pnode *pnode)
Free a parsing tree.
const struct ec_strvec * ec_pnode_get_strvec(const struct ec_pnode *pnode)
Get the string vector associated with a parsing node.
const struct ec_pnode * ec_pnode_find(const struct ec_pnode *root, const char *id)
Find a node from its identifier.
struct ec_pnode * ec_pnode_get_root(struct ec_pnode *pnode)
Get the root of the parsing tree.
void ec_pnode_free_children(struct ec_pnode *pnode)
Remove and free all the children of a parsing tree node.
void ec_pnode_unlink_child(struct ec_pnode *child)
Remove a child node from parsing tree.
struct ec_pnode * ec_pnode_get_first_child(const struct ec_pnode *pnode)
Get the first child of a node in the parsing tree.
const struct ec_pnode * ec_pnode_find_next(const struct ec_pnode *root, const struct ec_pnode *prev, const char *id, bool iter_children)
Find the next node matching an identifier.
size_t ec_pnode_len(const struct ec_pnode *pnode)
Get the number of strings in the parsed string vector.
struct ec_pnode * ec_pnode_dup(const struct ec_pnode *pnode)
Duplicate a parsing tree.
const struct ec_node * ec_pnode_get_node(const struct ec_pnode *pnode)
Get the grammar node corresponding to the parsing node.
struct ec_pnode * ec_pnode(const struct ec_node *node)
Create an empty parsing tree.
unsigned int ec_pnode_count(const struct ec_pnode *root, const char *id)
Count node occurrences in a parse subtree.
struct ec_strvec * ec_strvec(void)
Allocate a new empty string vector.