aboutsummaryrefslogtreecommitdiff
path: root/src/grecs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/grecs.h')
-rw-r--r--src/grecs.h86
1 files changed, 73 insertions, 13 deletions
diff --git a/src/grecs.h b/src/grecs.h
index 5769736..e0f0fa5 100644
--- a/src/grecs.h
+++ b/src/grecs.h
@@ -102,2 +102,21 @@ typedef struct grecs_value {
+#define GRECS_VALUE_EMPTY_P(val) \
+ (!(val) || \
+ ((val)->type == GRECS_TYPE_STRING && (val)->v.string == NULL))
+
+enum grecs_node_type {
+ grecs_node_stmt,
+ grecs_node_block
+};
+
+typedef struct grecs_node {
+ enum grecs_node_type type;
+ grecs_locus_t locus;
+ struct grecs_node *up;
+ struct grecs_node *down;
+ struct grecs_node *next;
+ char *ident;
+ struct grecs_value value;
+} grecs_node_t;
+
typedef int (*grecs_callback_fn)(
@@ -140,3 +159,3 @@ grecs_value_t *grecs_value_dup(grecs_value_t *input);
-extern void grecs_print_diag(grecs_locus_t *, int, int, const char*);
+extern void (*grecs_print_diag_fun)(grecs_locus_t *, int, int, const char*);
@@ -146,3 +165,2 @@ void grecs_error(grecs_locus_t *locus, int errcode, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
-void grecs_set_keywords(struct grecs_keyword *kwd);
void grecs_gram_trace(int n);
@@ -152,3 +170,5 @@ int grecs_lex_begin(const char*);
void grecs_lex_end(void);
-int grecs_parse(const char *name);
+struct grecs_node *grecs_parse(const char *name);
+
+struct grecs_list *_grecs_simple_list_create(int dispose);
@@ -165,2 +185,8 @@ extern void grecs_process_ident(struct grecs_keyword *kwp,
+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);
+
+
extern grecs_locus_t grecs_current_locus;
@@ -189,12 +215,18 @@ void grecs_include_path_setup_v(char **dirs);
const char *grecs_data_type_string(enum grecs_data_type type);
-void grecs_format_docstring(FILE *stream, const char *docstring,
- unsigned level);
-void grecs_format_simple_statement(FILE *stream, struct grecs_keyword *kwp,
- unsigned level);
-void grecs_format_block_statement(FILE *stream, struct grecs_keyword *kwp,
- unsigned level);
-void grecs_format_statement_array(FILE *stream, struct grecs_keyword *kwp,
- unsigned n,
- unsigned level);
-
+void grecs_format_docstring(const char *docstring, unsigned level,
+ FILE *stream);
+void grecs_format_simple_statement(struct grecs_keyword *kwp,
+ unsigned level, FILE *stream);
+void grecs_format_block_statement(struct grecs_keyword *kwp,
+ unsigned level, FILE *stream);
+void grecs_format_statement_array(struct grecs_keyword *kwp,
+ unsigned n,
+ unsigned level, FILE *stream);
+
+void grecs_format_locus(grecs_locus_t *locus, FILE *fp);
+void grecs_format_node_ident(struct grecs_node *node, int delim, FILE *fp);
+void grecs_format_value(struct grecs_value *val, FILE *fp);
+
+#define GRECS_NODE_FLAG_LOCUS 0x0100
+void grecs_format_node(struct grecs_node *node, int flags, FILE *fp);
@@ -242,3 +274,31 @@ int grecs_symtab_enumerate(struct grecs_symtab *st,
size_t grecs_symtab_count_entries(struct grecs_symtab *st);
+
+void grecs_node_free(struct grecs_node *node);
+void grecs_tree_free(struct grecs_node *node);
+
+enum grecs_tree_recurse_op {
+ grecs_tree_recurse_set,
+ grecs_tree_recurse_pre,
+ grecs_tree_recurse_post
+};
+
+enum grecs_tree_recurse_res {
+ grecs_tree_recurse_ok,
+ grecs_tree_recurse_fail,
+ grecs_tree_recurse_skip,
+ grecs_tree_recurse_stop
+};
+
+typedef enum grecs_tree_recurse_res
+ (*grecs_tree_recursor_t)(enum grecs_tree_recurse_op,
+ struct grecs_node *, void *);
+
+int grecs_tree_recurse(struct grecs_node *node, grecs_tree_recursor_t recfun,
+ void *data);
+
+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);

Return to:

Send suggestions and report system problems to the System administrator.