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
@@ -100,6 +100,25 @@ typedef struct grecs_value {
} v;
} grecs_value_t;
+#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)(
enum grecs_callback_command cmd,
grecs_locus_t * /* locus */,
@@ -138,19 +157,20 @@ char *grecs_strdup(const char *str);
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*);
void grecs_warning(grecs_locus_t *locus, int errcode, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
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);
void grecs_lex_trace(int n);
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);
void grecs_line_begin(void);
void grecs_line_add(const char *text, size_t len);
@@ -163,6 +183,12 @@ extern void grecs_process_ident(struct grecs_keyword *kwp,
void *base,
grecs_locus_t *locus);
+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;
extern int grecs_error_count;
extern int grecs_default_port;
@@ -187,16 +213,22 @@ void grecs_include_path_setup(const char *dir, ...);
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);
struct grecs_list *grecs_list_create(void);
size_t grecs_list_size(struct grecs_list *lp);
@@ -240,5 +272,33 @@ int grecs_symtab_enumerate(struct grecs_symtab *st,
grecs_symtab_enumerator_t fun, void *data);
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.