From e5c8e1dcd7f2d3784194498e5ea916e7b48fe33a Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Fri, 12 Sep 2008 13:39:49 -0500 Subject: Enhance source position implementation. Implemented some print and copy routines. Made empty srcpos objects that will be used later. Protected .h file from multiple #include's. Added srcpos_error() and srcpos_warn(). Signed-off-by: Jon Loeliger --- srcpos.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'srcpos.h') diff --git a/srcpos.h b/srcpos.h index e17c7c0..a6d0077 100644 --- a/srcpos.h +++ b/srcpos.h @@ -17,6 +17,9 @@ * USA */ +#ifndef _SRCPOS_H_ +#define _SRCPOS_H_ + /* * Augment the standard YYLTYPE with a filenum index into an * array of all opened filenames. @@ -69,9 +72,14 @@ typedef struct YYLTYPE { while (YYID (0)) +typedef YYLTYPE srcpos; -extern void yyerror(char const *); -extern void yyerrorf(char const *, ...) __attribute__((format(printf, 1, 2))); +/* + * Fictional source position used for IR nodes that are + * created without otherwise knowing a true source position. + * For example,constant definitions from the command line. + */ +extern srcpos srcpos_empty; extern struct dtc_file *srcpos_file; @@ -83,3 +91,14 @@ struct search_path { extern struct dtc_file *dtc_open_file(const char *fname, const struct search_path *search); extern void dtc_close_file(struct dtc_file *file); + +extern srcpos *srcpos_copy(srcpos *pos); +extern char *srcpos_string(srcpos *pos); +extern void srcpos_dump(srcpos *pos); + +extern void srcpos_error(srcpos *pos, char const *, ...) + __attribute__((format(printf, 2, 3))); +extern void srcpos_warn(srcpos *pos, char const *, ...) + __attribute__((format(printf, 2, 3))); + +#endif /* _SRCPOS_H_ */ -- cgit v1.2.1