mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-10-02 03:48:00 +03:00
jaf: show file name/line number in error messages
This commit is contained in:
@@ -37,7 +37,7 @@ IS (((u|U)(l|L|ll|LL)?)|((l|L|ll|LL)(u|U)?))
|
||||
CP (u|U|L)
|
||||
SP (u8|u|U|L)
|
||||
ES (\\(['"\?\\abfnrtv]|[0-7]{1,3}|x[a-fA-F0-9]+))
|
||||
WS [ \t\v\n\f]
|
||||
WS [ \t\v\f]
|
||||
|
||||
%{
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
@@ -52,6 +52,8 @@ extern int sym_type(const char *); /* returns type from symbol table */
|
||||
static void comment(void);
|
||||
static int check_type(void);
|
||||
|
||||
unsigned long jaf_line = 1;
|
||||
|
||||
#define RETURN_STRING(tok_type) yylval.string = make_string(yytext, yyleng); return tok_type
|
||||
%}
|
||||
|
||||
@@ -151,6 +153,7 @@ static int check_type(void);
|
||||
"?" { return '?'; }
|
||||
"@" { return '@'; }
|
||||
|
||||
\n { jaf_line++; }
|
||||
{WS}+ { /* whitespace separates tokens */ }
|
||||
. { /* discard bad characters */ }
|
||||
|
||||
|
||||
@@ -38,6 +38,9 @@ FILE *yyin;
|
||||
struct ain *jaf_ain_out;
|
||||
struct jaf_block *jaf_toplevel;
|
||||
|
||||
unsigned long jaf_line;
|
||||
const char *jaf_file;
|
||||
|
||||
static FILE *open_jaf_file(const char *file)
|
||||
{
|
||||
if (!strcmp(file, "-"))
|
||||
@@ -68,9 +71,11 @@ struct jaf_block *jaf_parse(struct ain *ain, const char **files, unsigned nr_fil
|
||||
|
||||
for (unsigned i = 0; i < nr_files; i++) {
|
||||
// open file
|
||||
jaf_file = files[i];
|
||||
jaf_line = 1;
|
||||
yyin = open_jaf_file(files[i]);
|
||||
if (yyparse())
|
||||
ERROR("Failed to parse .jaf file");
|
||||
ERROR("Failed to parse .jaf file: %s", files[i]);
|
||||
if (yyin != stdin)
|
||||
fclose(yyin);
|
||||
|
||||
@@ -548,5 +553,5 @@ parameter_declaration
|
||||
void yyerror(const char *s)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "*** %s\n", s);
|
||||
fprintf(stderr, "*** %s at %s:%lu\n", s, jaf_file, jaf_line);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user