From 13bda5d4f77ca469bbbe0d9b1f268682a9f0ec71 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 4 Aug 2006 21:01:05 +0000 Subject: Better error handling again, and about to add more language features. --- src/build.y | 7 +------ src/builder.cpp | 10 ++++++++++ src/builder.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/build.y b/src/build.y index 4d87a86..bf565fb 100644 --- a/src/build.y +++ b/src/build.y @@ -244,10 +244,5 @@ rulecompletion: TOK_COMMAND STRING void yyerror( YYLTYPE *locp, Builder &bld, char const *msg ) { - fprintf( stderr, "%s:%d-%d:%d-%d: %s\n", - bld.file.c_str(), - locp->first_line, locp->last_line, - locp->first_column, locp->last_column, - msg - ); + bld.error( locp, msg ); } diff --git a/src/builder.cpp b/src/builder.cpp index 3bcd593..d3cb2c0 100644 --- a/src/builder.cpp +++ b/src/builder.cpp @@ -563,3 +563,13 @@ void Builder::error( const std::string &err ) throw BuildException( err.c_str() ); } +void Builder::error( YYLTYPE *locp, const std::string &err ) +{ + fprintf( stderr, "%s:%d-%d:%d-%d: %s\n", + file.c_str(), + locp->first_line, locp->last_line, + locp->first_column, locp->last_column, + err.c_str() + ); +} + diff --git a/src/builder.h b/src/builder.h index 152b969..06e84f3 100644 --- a/src/builder.h +++ b/src/builder.h @@ -39,7 +39,7 @@ public: void build( const char *sAct=NULL ); void execute( Action *pAct ); - //void error( const yy::location &l, const std::string &m ); + void error( YYLTYPE *locp, const std::string &m ); void error( const std::string &m ); std::string file; -- cgit v1.2.3