diff options
Diffstat (limited to 'srcpos.h')
-rw-r--r-- | srcpos.h | 72 |
1 files changed, 27 insertions, 45 deletions
@@ -20,11 +20,6 @@ #ifndef _SRCPOS_H_ #define _SRCPOS_H_ -/* - * Augment the standard YYLTYPE with a filenum index into an - * array of all opened filenames. - */ - #include <stdio.h> struct srcfile_state { @@ -41,62 +36,49 @@ FILE *srcfile_relative_open(const char *fname, char **fullnamep); void srcfile_push(const char *fname); int srcfile_pop(void); -#if ! defined(YYLTYPE) && ! defined(YYLTYPE_IS_DECLARED) -typedef struct YYLTYPE { +struct srcpos { int first_line; int first_column; int last_line; int last_column; struct srcfile_state *file; -} YYLTYPE; - -#define YYLTYPE_IS_DECLARED 1 -#define YYLTYPE_IS_TRIVIAL 1 -#endif - -/* Cater to old parser templates. */ -#ifndef YYID -#define YYID(n) (n) -#endif - -#define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - (Current).file = YYRHSLOC (Rhs, N).file; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - (Current).file = YYRHSLOC (Rhs, 0).file; \ - } \ - while (YYID (0)) +}; +#define YYLTYPE struct srcpos + +#define YYLLOC_DEFAULT(Current, Rhs, N) \ + do { \ + if (N) { \ + (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + (Current).file = YYRHSLOC(Rhs, N).file; \ + } else { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC(Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC(Rhs, 0).last_column; \ + (Current).file = YYRHSLOC (Rhs, 0).file; \ + } \ + } while (0) -typedef YYLTYPE srcpos; /* * 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 srcpos srcpos_empty; -extern void srcpos_update(srcpos *pos, const char *text, int len); -extern srcpos *srcpos_copy(srcpos *pos); -extern char *srcpos_string(srcpos *pos); -extern void srcpos_dump(srcpos *pos); +extern void srcpos_update(struct srcpos *pos, const char *text, int len); +extern struct srcpos *srcpos_copy(struct srcpos *pos); +extern char *srcpos_string(struct srcpos *pos); +extern void srcpos_dump(struct srcpos *pos); -extern void srcpos_error(srcpos *pos, char const *, ...) +extern void srcpos_error(struct srcpos *pos, char const *, ...) __attribute__((format(printf, 2, 3))); -extern void srcpos_warn(srcpos *pos, char const *, ...) +extern void srcpos_warn(struct srcpos *pos, char const *, ...) __attribute__((format(printf, 2, 3))); #endif /* _SRCPOS_H_ */ |