88#define EC_NODE_TYPE_REGISTER(t) \
89 static void ec_node_init_##t(void); \
90 static void __attribute__((constructor, used)) ec_node_init_##t(void) \
92 if (ec_node_type_register(&t, 0) < 0) \
93 fprintf(stderr, "cannot register node type %s\n", t.name); \
109#define EC_NODE_TYPE_REGISTER_OVERRIDE(t) \
110 static void ec_node_init_##t(void); \
111 static void __attribute__((constructor, used)) ec_node_init_##t(void) \
113 if (ec_node_type_register(&t, 1) < 0) \
114 fprintf(stderr, "cannot register node type %s\n", t.name); \
241typedef char *(*ec_node_desc_t)(
const struct ec_node *);
struct ec_comp * ec_comp(void)
Create an empty completion object (list of completion items).
struct ec_dict * ec_dict(void)
Create a hash table.
struct ec_node * ec_node_clone(struct ec_node *node)
Clone a grammar node.
const char * ec_node_id(const struct ec_node *node)
Get node identifier.
struct ec_node * ec_node_iter_get_node(struct ec_node_iter *iter)
Get the grammar node referenced by the iterator node.
int ec_node_get_child(const struct ec_node *node, size_t i, struct ec_node **child)
Get the n-th child of a node.
void ec_node_iter_free(struct ec_node_iter *iter)
Free a grammar graph iterator.
const char * ec_node_get_type_name(const struct ec_node *node)
Get the type name of a grammar node.
struct ec_node * ec_node_from_type(const struct ec_node_type *type, const char *id)
Create a new node when the type is known.
void ec_node_dump(FILE *out, const struct ec_node *node)
Dump a grammar tree.
void(* ec_node_free_priv_t)(struct ec_node *)
Free the node private area.
struct ec_node * ec_node(const char *typename, const char *id)
Create a new node from its type name.
struct ec_dict * ec_node_attrs(const struct ec_node *node)
Get the attributes dict of the node.
struct ec_node * ec_node_find(struct ec_node *node, const char *id)
Find a node from its identifier string.
void ec_node_type_dump(FILE *out)
Dump registered node types.
int ec_node_check_type(const struct ec_node *node, const struct ec_node_type *type)
Check the type of a node.
int ec_node_set_config(struct ec_node *node, struct ec_config *config)
Set node configuration.
struct ec_node_iter * ec_node_iter(struct ec_node *node)
Create an iterator on a grammar tree.
struct ec_node_type_list node_type_list
The list of registered node types.
int(* ec_node_get_child_t)(const struct ec_node *, size_t i, struct ec_node **child, unsigned int *refs)
Get the i-th child node.
size_t ec_node_get_children_count(const struct ec_node *node)
Return the number of children for a node.
struct ec_node_iter * ec_node_iter_get_parent(struct ec_node_iter *iter)
Get the parent of an iterator node.
char *(* ec_node_desc_t)(const struct ec_node *)
Get the short description of a grammar node.
struct ec_node_iter * ec_node_iter_next(struct ec_node_iter *root, struct ec_node_iter *iter, bool iter_children)
Iterate to the next node.
const struct ec_config * ec_node_get_config(const struct ec_node *node)
Get the current node configuration.
int(* ec_node_set_config_t)(struct ec_node *node, const struct ec_config *config)
Function type used to configure a node.
const struct ec_node_type * ec_node_type(const struct ec_node *node)
Get the type of a node.
int ec_node_type_register(struct ec_node_type *type, bool override)
Register a node type.
int(* ec_node_init_priv_t)(struct ec_node *)
Initialize the node private area.
int(* ec_complete_t)(const struct ec_node *node, struct ec_comp *comp, const struct ec_strvec *strvec)
Get completion items using the given grammar graph.
size_t(* ec_node_get_children_count_t)(const struct ec_node *)
Count the number of node children.
const struct ec_config_schema * ec_node_type_schema(const struct ec_node_type *type)
Get the config schema of a node type.
char * ec_node_desc(const struct ec_node *node)
Get node short description.
int(* ec_parse_t)(const struct ec_node *node, struct ec_pnode *pstate, const struct ec_strvec *strvec)
Parse a string vector using the given grammar graph.
void ec_node_schema_dump(FILE *out, const struct ec_node *node)
Dump the node configuration schema.
const struct ec_node_type * ec_node_type_lookup(const char *name)
Lookup node type by name.
const char * ec_node_type_name(const struct ec_node_type *type)
Get the name of a node type.
void * ec_node_priv(const struct ec_node *node)
Get the pointer to the node private area.
void ec_node_free(struct ec_node *node)
Decrement node reference counter and free the node if it is the last reference.
struct ec_pnode * ec_pnode(const struct ec_node *node)
Create an empty parsing tree.
struct ec_strvec * ec_strvec(void)
Allocate a new empty string vector.
Structure describing the format of a configuration value.
Structure storing the configuration data.
A structure describing a grammar node type.