diff options
Diffstat (limited to 'src/grecs.h')
-rw-r--r-- | src/grecs.h | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/src/grecs.h b/src/grecs.h index 8bd70d1..1581791 100644 --- a/src/grecs.h +++ b/src/grecs.h @@ -51,9 +51,23 @@ struct grecs_version_info { char *buffer; }; -typedef struct { +struct grecs_locus_point { char *file; - int line; + unsigned line; + unsigned col; +}; + +#define grecs_locus_point_advance_line(loc) do { \ + (loc).line++; \ + (loc).col = 0; \ + } while (0) + +#define GRECS_LOCUS_POINT_EQ(a,b) \ + ((strcmp((a)->file, (b)->file) == 0) && ((a)->line == (b)->line)) + +typedef struct grecs_locus { + struct grecs_locus_point beg; + struct grecs_locus_point end; } grecs_locus_t; extern grecs_locus_t grecs_locus; @@ -109,6 +123,7 @@ struct grecs_list { typedef struct grecs_value { int type; + grecs_locus_t locus; union { struct grecs_list *list; char *string; @@ -137,6 +152,7 @@ typedef struct grecs_node { struct grecs_node *next; struct grecs_node *prev; char *ident; + grecs_locus_t idloc; union { struct grecs_value *value; struct grecs_symtab *texttab; @@ -192,12 +208,14 @@ void grecs_free(void *ptr); grecs_value_t *grecs_value_ptr_from_static(grecs_value_t *input); -extern void (*grecs_print_diag_fun)(grecs_locus_t *, int, int, const char*); +extern void (*grecs_print_diag_fun)(grecs_locus_t const *, 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_warning(grecs_locus_t const *locus, + int errcode, const char *fmt, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); +void grecs_error(grecs_locus_t const *locus, int errcode, + const char *fmt, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); extern int grecs_trace_flags; @@ -208,8 +226,10 @@ void grecs_gram_trace(int n); void grecs_lex_trace(int n); void grecs_parse_line_directive(char *text, grecs_locus_t *ploc, + struct grecs_locus_point *ppoint, size_t *pxlines); void grecs_parse_line_directive_cpp(char *text, grecs_locus_t *ploc, + struct grecs_locus_point *ppoint, size_t *pxlines); @@ -251,7 +271,8 @@ void grecs_line_begin(void); char *grecs_line_finish(void); extern int grecs_string_convert(void *target, enum grecs_data_type type, - const char *string, grecs_locus_t *locus); + const char *string, + grecs_locus_t const *locus); extern void grecs_process_ident(struct grecs_keyword *kwp, grecs_value_t *value, void *base, @@ -259,12 +280,15 @@ extern void grecs_process_ident(struct grecs_keyword *kwp, struct grecs_node *grecs_node_create(enum grecs_node_type type, grecs_locus_t *loc); +struct grecs_node *grecs_node_create_points(enum grecs_node_type type, + struct grecs_locus_point beg, + struct grecs_locus_point end); 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; +extern struct grecs_locus_point grecs_current_locus_point; extern int grecs_error_count; extern int grecs_default_port; @@ -450,7 +474,8 @@ 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); struct grecs_node *grecs_node_from_path_locus(const char *path, const char *value, - grecs_locus_t *locus); + grecs_locus_t *locus, + grecs_locus_t *vallocus); int grecs_tree_reduce(struct grecs_node *node, struct grecs_keyword *kwd, int flags); |