+/* These states are used to mark the grammar graph when freeing, to
+ * detect loop. */
+enum ec_node_free_state {
+ EC_NODE_FREE_STATE_NONE,
+ EC_NODE_FREE_STATE_TRAVERSED,
+ EC_NODE_FREE_STATE_FREEABLE,
+ EC_NODE_FREE_STATE_NOT_FREEABLE,
+ EC_NODE_FREE_STATE_FREEING,
+};
+
+/**
+ * The grammar node structure.
+ */
+struct ec_node {
+ const struct ec_node_type *type; /**< The node type. */
+ struct ec_config *config; /**< Node configuration. */
+ char *id; /**< Node identifier (EC_NO_ID if none). */
+ struct ec_dict *attrs; /**< Attributes of the node. */
+ unsigned int refcnt; /**< Reference counter. */
+ 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 */
+};
+