diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2018-05-01 17:25:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-01 17:25:19 (GMT) |
commit | d50acc2b7161fdee0c5a4a988d3f58c6f888420f (patch) | |
tree | 6ca2894e86b4181c83a9dc392eae2dedb80458dc | |
parent | c33bb00b648606a72df51ed8ee41e03cb85d312c (diff) | |
parent | 12ea0367d27b47280e8d768d04c8c332e9657491 (diff) | |
download | Doxygen-d50acc2b7161fdee0c5a4a988d3f58c6f888420f.zip Doxygen-d50acc2b7161fdee0c5a4a988d3f58c6f888420f.tar.gz Doxygen-d50acc2b7161fdee0c5a4a988d3f58c6f888420f.tar.bz2 |
Merge pull request #686 from albert-github/feature/bug_vhdl_error_message
Making VHDL error messages more doxygen like
-rw-r--r-- | src/vhdljjparser.cpp | 7 | ||||
-rw-r--r-- | vhdlparser/VhdlParserErrorHandler.hpp | 27 | ||||
-rw-r--r-- | vhdlparser/VhdlParserIF.cpp | 2 |
3 files changed, 30 insertions, 6 deletions
diff --git a/src/vhdljjparser.cpp b/src/vhdljjparser.cpp index 953cd6b..34391b5 100644 --- a/src/vhdljjparser.cpp +++ b/src/vhdljjparser.cpp @@ -83,6 +83,7 @@ static struct static bool doxComment=FALSE; // doxygen comment ? static QCString strComment; static int iCodeLen; +static const char *vhdlFileName = 0; bool checkMultiComment(QCString& qcs,int line); QList<Entry>* getEntryAtLine(const Entry* ce,int line); @@ -200,6 +201,7 @@ void VHDLLanguageScanner::parseInput(const char *fileName,const char *fileBuf,En VhdlParser::current=new Entry(); VhdlParser::initEntry(VhdlParser::current); groupEnterFile(fileName,yyLineNr); + vhdlFileName = fileName; lineParse=new int[200]; // Dimitri: dangerous constant: should be bigger than largest token id in VhdlParserConstants.h VhdlParserIF::parseVhdlfile(fileBuf,inLine); @@ -213,6 +215,7 @@ void VHDLLanguageScanner::parseInput(const char *fileName,const char *fileBuf,En yyFileName.resize(0); libUse.clear(); VhdlDocGen::resetCodeVhdlParserState(); + vhdlFileName = 0; } void VhdlParser::lineCount() @@ -851,3 +854,7 @@ QList<Entry>* getEntryAtLine(const Entry* ce,int line) return &lineEntry; } +const char *getVhdlFileName(void) +{ + return vhdlFileName; +} diff --git a/vhdlparser/VhdlParserErrorHandler.hpp b/vhdlparser/VhdlParserErrorHandler.hpp index d98f029..9576ce6 100644 --- a/vhdlparser/VhdlParserErrorHandler.hpp +++ b/vhdlparser/VhdlParserErrorHandler.hpp @@ -7,32 +7,47 @@ #include "VhdlParser.h" #include "ErrorHandler.h" #include "vhdlstring.h" +#include "message.h" + +const char *getVhdlFileName(void); namespace vhdl { namespace parser { -class VhdlErrorHandler: public ErrorHandler +class VhdlErrorHandler: public ErrorHandler { - virtual void handleUnexpectedToken(int expectedKind, JAVACC_STRING_TYPE expectedToken, Token *actual, VhdlParser *parser) + virtual void handleUnexpectedToken(int expectedKind, JAVACC_STRING_TYPE expectedToken, Token *actual, VhdlParser *parser) { - fprintf(stderr,"\n\n syntax error at line: %d : %s\n", actual->beginLine,actual->image.data()); + warn(getVhdlFileName(),actual->beginLine,"syntax error '%s'",actual->image.data()); error_count++; throw std::exception(); } - virtual void handleParseError(Token *last, Token *unexpected, JAVACC_SIMPLE_STRING production, VhdlParser *parser) + virtual void handleParseError(Token *last, Token *unexpected, JAVACC_SIMPLE_STRING production, VhdlParser *parser) { - fprintf(stderr,"\n\n unexpected token at line: %d %s\n", last->beginLine,unexpected->image.data()); + warn(getVhdlFileName(),last->beginLine,"unexpected token: '%s'", unexpected->image.data()); error_count++; throw std::exception(); } virtual void handleOtherError(JAVACC_STRING_TYPE message, VhdlParser *parser) { - fprintf(stderr, "\n\n unexpected error: %s\n", (char*)message.c_str()); + warn(getVhdlFileName(), -1, "unexpected error: '%s'", (char*)message.c_str()); error_count++; throw std::exception(); } }; + +class VhdlTokenManagerErrorHandler: public TokenManagerErrorHandler { + virtual void lexicalError(bool EOFSeen, int lexState, int errorLine, int errorColumn, JAVACC_STRING_TYPE errorAfter, JAVACC_CHAR_TYPE curChar, VhdlParserTokenManager* token_manager) + { + warn(getVhdlFileName(),errorLine,"Lexical error, Encountered: '%c' after: '%s'",curChar, (EOFSeen? "EOF" : (const char*)errorAfter.c_str())); + } + + virtual void lexicalError(JAVACC_STRING_TYPE errorMessage, VhdlParserTokenManager* token_manager) + { + warn(getVhdlFileName(),-1,"Unknown error: '%s'", (char*)errorMessage.c_str()); + } + }; } } diff --git a/vhdlparser/VhdlParserIF.cpp b/vhdlparser/VhdlParserIF.cpp index f9f689b..3a6746f 100644 --- a/vhdlparser/VhdlParserIF.cpp +++ b/vhdlparser/VhdlParserIF.cpp @@ -14,6 +14,8 @@ void VhdlParserIF::parseVhdlfile(const char* inputBuffer,bool inLine) JAVACC_STRING_TYPE s =inputBuffer; CharStream *stream = new CharStream(s.c_str(), (int)s.size(), 1, 1); VhdlParserTokenManager *tokenManager = new VhdlParserTokenManager(stream); + VhdlTokenManagerErrorHandler *myTokErr=new VhdlTokenManagerErrorHandler(); + tokenManager->setErrorHandler(myTokErr); myParser=new VhdlParser(tokenManager); VhdlErrorHandler *myErr=new VhdlErrorHandler(); myParser->setErrorHandler(myErr); |