aboutsummaryrefslogtreecommitdiff
path: root/src/grecs.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-06 11:58:47 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-06 13:00:06 +0300
commit52c12573a505bf29a0301a1c9553e88c3270713e (patch)
tree642047e5b3de469199b68a76064f756990a3b249 /src/grecs.h
parent8465fa7066d3c922b738346335f801cf9ea2243f (diff)
downloadgrecs-52c12573a505bf29a0301a1c9553e88c3270713e.tar.gz
grecs-52c12573a505bf29a0301a1c9553e88c3270713e.tar.bz2
Rewrite list support to keep doubly-linked lists. Implement tree reduction.
* src/format.c (grecs_format_node) (grecs_format_node_path): Handle grecs_node_root. * src/grecs-gram.y (input production): Create root node. * src/grecs.h (grecs_list_entry)<prev>: New member. (grecs_node_root): New node type. (grecs_node_eq): New proto. (grecs_list_add,grecs_tree_reduce): New protos. * src/list.c: Rewrite as a doubly-linked list. * src/tree.c (grecs_node_bind): Bugfix. (grecs_node_unlink): New function. (_tree_recurse): Allow for removal of the current node. (grecs_node_eq): New function. (grecs_tree_reduce): New function. (grecs_tree_process): Descend into the first subnode at once. * src/lookup.c (node_finder): Handle grecs_node_root. * tests/reduce00.at: New testcase. * tests/reduce01.at: New testcase. * tests/reduce02.at: New testcase. * tests/testsuite.at (GRECS_TEST): New macro. Include reduce0[0-2].at. * tests/gcffmt.c: New option -reduce. * tests/gcfpeek.c: Likewise. * tests/gcfset.c: Likewise.
Diffstat (limited to 'src/grecs.h')
-rw-r--r--src/grecs.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/grecs.h b/src/grecs.h
index b6ac85c..6dc3cda 100644
--- a/src/grecs.h
+++ b/src/grecs.h
@@ -90,7 +90,7 @@ enum grecs_callback_command {
#define GRECS_TYPE_ARRAY 2
struct grecs_list_entry {
- struct grecs_list_entry *next;
+ struct grecs_list_entry *next, *prev;
void *data;
};
@@ -118,6 +118,7 @@ typedef struct grecs_value {
((val)->type == GRECS_TYPE_STRING && (val)->v.string == NULL))
enum grecs_node_type {
+ grecs_node_root,
grecs_node_stmt,
grecs_node_block
};
@@ -204,6 +205,7 @@ struct grecs_node *grecs_node_create(enum grecs_node_type type,
grecs_locus_t *loc);
void grecs_node_bind(struct grecs_node *master, struct grecs_node *node,
int dn);
+int grecs_node_eq(struct grecs_node *a, struct grecs_node *b);
extern grecs_locus_t grecs_current_locus;
@@ -264,6 +266,7 @@ void *grecs_list_index(struct grecs_list *lp, size_t idx);
void *grecs_list_remove_tail(struct grecs_list *lp);
void grecs_list_clear(struct grecs_list *lp);
void grecs_list_free(struct grecs_list *lp);
+void grecs_list_add(struct grecs_list *dst, struct grecs_list *src);
int grecs_vasprintf(char **pbuf, size_t *psize, const char *fmt, va_list ap);
int grecs_asprintf(char **pbuf, size_t *psize, const char *fmt, ...);
@@ -326,5 +329,6 @@ int grecs_tree_process(struct grecs_node *node, struct grecs_keyword *kwd);
int grecs_value_eq(struct grecs_value *a, struct grecs_value *b);
struct grecs_node *grecs_find_node(struct grecs_node *node, const char *path);
struct grecs_node *grecs_node_from_path(const char *path, const char *value);
+int grecs_tree_reduce(struct grecs_node *node, struct grecs_keyword *kwd);
#endif

Return to:

Send suggestions and report system problems to the System administrator.