diff --git a/src/tools/ainedit/jaf_lexer.l b/src/tools/ainedit/jaf_lexer.l index 4fb2e25..dd6d7e7 100644 --- a/src/tools/ainedit/jaf_lexer.l +++ b/src/tools/ainedit/jaf_lexer.l @@ -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 */ } diff --git a/src/tools/ainedit/jaf_parser.y b/src/tools/ainedit/jaf_parser.y index 8523ff1..014b5da 100644 --- a/src/tools/ainedit/jaf_parser.y +++ b/src/tools/ainedit/jaf_parser.y @@ -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); }