X-Git-Url: http://git.droids-corp.org/?p=protos%2Flibecoli.git;a=blobdiff_plain;f=include%2Fecoli_node.h;h=38e25e42dd0d55a815936e17c9c89509e1008562;hp=45f3e74aa1d58f7984249d6ebba72cf758273e9c;hb=ae32f7f2fd1bc44a5388e1984f7c96bc29d3fdc2;hpb=18d03456d96f7a086a2ccc82ce97fcf056848d90 diff --git a/include/ecoli_node.h b/include/ecoli_node.h index 45f3e74..38e25e4 100644 --- a/include/ecoli_node.h +++ b/include/ecoli_node.h @@ -3,10 +3,13 @@ */ /** - * Interface to manage the ecoli nodes. + * @defgroup grammar_tree Grammar Tree + * @{ * - * A node is a main structure of the ecoli library, used to define how - * to match and complete the input tokens. A node is a generic object + * @brief Libecoli grammar nodes. + * + * The grammar node is a main structure of the ecoli library, used to define + * how to match and complete the input tokens. A node is a generic object * that implements: * - a parse(node, input) method: check if an input matches * - a complete(node, input) method: return possible completions for @@ -46,6 +49,9 @@ #include #include +/** + * Node has no identifier. + */ #define EC_NO_ID "no-id" #define EC_NODE_ENDLIST ((void *)1) @@ -54,7 +60,7 @@ struct ec_node; struct ec_parse; struct ec_comp; struct ec_strvec; -struct ec_keyval; +struct ec_dict; struct ec_config; struct ec_config_schema; @@ -152,20 +158,6 @@ enum ec_node_free_state { EC_NODE_FREE_STATE_FREEING, }; -struct ec_node { - const struct ec_node_type *type; - struct ec_config *config; /**< Generic configuration. */ - char *id; - char *desc; - struct ec_keyval *attrs; - unsigned int refcnt; - struct { - enum ec_node_free_state state; /**< State of loop detection */ - unsigned int refcnt; /**< Number of reachable references - * starting from node beeing freed */ - } free; /**< Freeing state: used for loop detection */ -}; - /* create a new node when the type is known, typically called from the node * code */ struct ec_node *ec_node_from_type(const struct ec_node_type *type, const char *id); @@ -192,7 +184,7 @@ ec_node_get_child(const struct ec_node *node, size_t i, /* XXX add more accessors */ const struct ec_node_type *ec_node_type(const struct ec_node *node); -struct ec_keyval *ec_node_attrs(const struct ec_node *node); +struct ec_dict *ec_node_attrs(const struct ec_node *node); const char *ec_node_id(const struct ec_node *node); const char *ec_node_desc(const struct ec_node *node); @@ -203,4 +195,18 @@ struct ec_node *ec_node_find(struct ec_node *node, const char *id); int ec_node_check_type(const struct ec_node *node, const struct ec_node_type *type); +const char *ec_node_get_type_name(const struct ec_node *node); + +/** + * Get the pointer to the node private area. + * + * @param node + * The grammar node. + * @return + * The pointer to the node private area. + */ +void *ec_node_priv(const struct ec_node *node); + #endif + + /** @} */