save
[protos/libecoli.git] / lib / ecoli_parsed.h
index 1ebea9e..0755336 100644 (file)
@@ -39,6 +39,7 @@ TAILQ_HEAD(ec_parsed_list, ec_parsed);
 
 /*
   node == NULL + empty children list means "no match"
+  XXX still valid?
 */
 struct ec_parsed {
        TAILQ_ENTRY(ec_parsed) next;
@@ -46,6 +47,7 @@ struct ec_parsed {
        struct ec_parsed *parent;
        const struct ec_node *node;
        struct ec_strvec *strvec;
+       struct ec_keyval *attrs;
 };
 
 struct ec_parsed *ec_parsed(void);
@@ -56,7 +58,8 @@ const struct ec_strvec *ec_parsed_strvec(const struct ec_parsed *parsed);
 
 /* XXX we could use a cache to store possible completions or match: the
  * cache would be per-node, and would be reset for each call to parse()
- * or complete() ? */
+ * or complete() ? ... not sure, since parse result can depend on state
+ */
 /* a NULL return value is an error, with errno set
   ENOTSUP: no ->parse() operation
 */
@@ -68,7 +71,7 @@ struct ec_parsed *ec_node_parse_strvec(struct ec_node *node,
 #define EC_PARSED_NOMATCH INT_MIN
 /* internal: used by nodes
  *
- * state is the current parse tree, which is built bit by bit while
+ * state is the current parse tree, which is built piece by piece while
  *   parsing the node tree: ec_node_parse_child() creates a new child in
  *   this state parse tree, and calls the parse() method for the child
  *   node, with state pointing to this new child. If it does not match,
@@ -80,6 +83,7 @@ struct ec_parsed *ec_node_parse_strvec(struct ec_node *node,
  * EC_PARSED_NOMATCH (negative) if it does not match
  * any other negative value (-errno) for other errors
  * the number of matched strings in strvec
+ * XXX state is not freed on error ?
  */
 int ec_node_parse_child(struct ec_node *node,
                        struct ec_parsed *state,
@@ -89,9 +93,12 @@ void ec_parsed_add_child(struct ec_parsed *parsed,
                        struct ec_parsed *child);
 void ec_parsed_del_child(struct ec_parsed *parsed,
                        struct ec_parsed *child);
+
 struct ec_parsed *ec_parsed_get_root(struct ec_parsed *parsed);
+struct ec_parsed *ec_parsed_get_parent(struct ec_parsed *parsed);
 struct ec_parsed *ec_parsed_get_last_child(struct ec_parsed *parsed);
 void ec_parsed_del_last_child(struct ec_parsed *parsed);
+int ec_parsed_get_path(struct ec_parsed *parsed, struct ec_node **path);
 
 void ec_parsed_dump(FILE *out, const struct ec_parsed *parsed);