mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-23 01:41:53 +02:00
b2/lang.l: print file name in diagnostics
This commit is contained in:
parent
9a06757420
commit
5d7f4fc662
@ -26,6 +26,7 @@ extern int yyparse(void);
|
||||
|
||||
static int start_token;
|
||||
static int expose_nl;
|
||||
static const char *file_name;
|
||||
static int lineno;
|
||||
|
||||
|
||||
@ -48,8 +49,10 @@ static void open_stdin(const char *name)
|
||||
static void do_parse(const char *name, int start, int nl)
|
||||
{
|
||||
open_stdin(name);
|
||||
|
||||
start_token = start;
|
||||
expose_nl = nl;
|
||||
file_name = unique(name);
|
||||
lineno = 1;
|
||||
yyparse();
|
||||
}
|
||||
@ -132,7 +135,7 @@ void yywarnf(const char *fmt, ...)
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
fprintf(stderr, "%d: warning: ", lineno);
|
||||
fprintf(stderr, "%s:%d: warning: ", file_name, lineno);
|
||||
vfprintf(stderr, fmt, ap) ;
|
||||
fprintf(stderr, "\n");
|
||||
va_end(ap);
|
||||
@ -144,7 +147,7 @@ void yyerrorf(const char *fmt, ...)
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
fprintf(stderr, "%d: ", lineno);
|
||||
fprintf(stderr, "%s:%d: ", file_name, lineno);
|
||||
vfprintf(stderr, fmt, ap) ;
|
||||
fprintf(stderr, "\n");
|
||||
va_end(ap);
|
||||
@ -154,6 +157,6 @@ void yyerrorf(const char *fmt, ...)
|
||||
|
||||
void yyerror(const char *s)
|
||||
{
|
||||
fprintf(stderr, "%d: %s\n", lineno, s);
|
||||
fprintf(stderr, "%s:%d: %s\n", file_name, lineno, s);
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user