From ea89c3ca0702aa2618adc313ddda0cc69ce11494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurko=20Gospodneti=C4=87?= Date: Tue, 2 Sep 2008 11:06:24 +0000 Subject: [PATCH] Updated Boost Jam's error location reporting when parsing Jamfiles. Now it reports the correct error location information when encountering an unexpected EOF. It now also reports where an invalid lexical token being read started instead of finished which makes it much easier to find errors like unclosed quotes (") or curly braces ({). [SVN r48534] --- historic/jam/src/scan.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/historic/jam/src/scan.c b/historic/jam/src/scan.c index 692799ac0..e6c778e52 100644 --- a/historic/jam/src/scan.c +++ b/historic/jam/src/scan.c @@ -69,11 +69,20 @@ void yymode( int n ) void yyerror( char * s ) { - if ( incp ) - printf( "%s:%d: ", incp->fname, incp->line ); - - printf( "%s at %s\n", s, symdump( &yylval ) ); - + /* We use yylval instead of incp to access the error location information as + * the incp pointer will already be reset to 0 in case the error occurred at + * EOF. + * + * The two may differ only if we get an error while reading a lexical token + * spanning muliple lines, e.g. a multi-line string literal or action body, + * in which case yylval location information will hold the information about + * where this token started while incp will hold the information about where + * reading it broke. + * + * TODO: Test the theory about when yylval and incp location information are + * the same and when they differ. + */ + printf( "%s:%d: %s at %s\n", yylval.file, yylval.line, s, symdump( &yylval ) ); ++anyerrors; } @@ -360,9 +369,9 @@ int yylex() return yylval.type; eof: - yylval.file = "end-of-input"; /* just in case */ - yylval.line = 0; - + /* We do not reset yylval.file & yylval.line here so unexpected EOF error + * messages would include correct error location information. + */ yylval.type = EOF; return yylval.type; }