Boost logo

Boost-Commit :

From: jurko.gospodnetic_at_[hidden]
Date: 2008-09-02 07:06:24


Author: jurko
Date: 2008-09-02 07:06:24 EDT (Tue, 02 Sep 2008)
New Revision: 48534
URL: http://svn.boost.org/trac/boost/changeset/48534

Log:
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 ({).
Text files modified:
   trunk/tools/jam/src/scan.c | 25 +++++++++++++++++--------
   1 files changed, 17 insertions(+), 8 deletions(-)

Modified: trunk/tools/jam/src/scan.c
==============================================================================
--- trunk/tools/jam/src/scan.c (original)
+++ trunk/tools/jam/src/scan.c 2008-09-02 07:06:24 EDT (Tue, 02 Sep 2008)
@@ -69,11 +69,20 @@
 
 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 @@
     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;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk