diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2019-12-12 19:45:59 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2019-12-12 19:45:59 (GMT) |
commit | 8e9306fe1f1673772b6695ee390ce781898e8565 (patch) | |
tree | 96d78f99a5a04748064cab13e230959e4bdda4cf /vhdlparser/VhdlParserTokenManager.cc | |
parent | 0e4dc3b329e8010bbff4a43761027f60fb61ecd3 (diff) | |
download | Doxygen-8e9306fe1f1673772b6695ee390ce781898e8565.zip Doxygen-8e9306fe1f1673772b6695ee390ce781898e8565.tar.gz Doxygen-8e9306fe1f1673772b6695ee390ce781898e8565.tar.bz2 |
Revert to locally patched version 6.2 of JavaCC due to more regressions :-(
Diffstat (limited to 'vhdlparser/VhdlParserTokenManager.cc')
-rw-r--r-- | vhdlparser/VhdlParserTokenManager.cc | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/vhdlparser/VhdlParserTokenManager.cc b/vhdlparser/VhdlParserTokenManager.cc index 728e4c4..01e8d37 100644 --- a/vhdlparser/VhdlParserTokenManager.cc +++ b/vhdlparser/VhdlParserTokenManager.cc @@ -1,5 +1,6 @@ /* VhdlParserTokenManager.cc */ -#include "/Users/dimitri/doxygen/vhdlparser/VhdlParserTokenManager.h" +#include "VhdlParserTokenManager.h" +#include "TokenMgrError.h" namespace vhdl { namespace parser { static const unsigned long long jjbitVec0[] = { @@ -3321,10 +3322,10 @@ bool VhdlParserTokenManager::jjCanMove_1(int hiByte, int i1, int i2, unsigned lo Token * VhdlParserTokenManager::jjFillToken(){ Token *t; JAVACC_STRING_TYPE curTokenImage; - int beginLine; - int endLine; - int beginColumn; - int endColumn; + int beginLine = -1; + int endLine = -1; + int beginColumn = -1; + int endColumn = -1; JAVACC_STRING_TYPE im = jjstrLiteralImages[jjmatchedKind]; curTokenImage = (im.length() == 0) ? input_stream->GetImage() : im; if (input_stream->getTrackLineColumn()) { @@ -3333,7 +3334,9 @@ Token * VhdlParserTokenManager::jjFillToken(){ endLine = input_stream->getEndLine(); endColumn = input_stream->getEndColumn(); } - t = Token::newToken(jjmatchedKind, curTokenImage); + t = Token::newToken(jjmatchedKind); + t->kind = jjmatchedKind; + t->image = curTokenImage; t->specialToken = NULL; t->next = NULL; @@ -3591,7 +3594,7 @@ void VhdlParserTokenManager::TokenLexicalActions(Token *matchedToken){ } /** Reinitialise parser. */ void VhdlParserTokenManager::ReInit(JAVACC_CHARSTREAM *stream, int lexState, VhdlParser *parserArg) { - if (input_stream) delete input_stream; + clear(); jjmatchedPos = jjnewStateCnt = 0; curLexState = lexState; input_stream = stream; @@ -3612,10 +3615,17 @@ void VhdlParserTokenManager::TokenLexicalActions(Token *matchedToken){ /** Switch to specified lex state. */ void VhdlParserTokenManager::SwitchTo(int lexState) { - if (lexState >= 1 || lexState < 0) - assert(false); - //throw 1;//new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); - else + if (lexState >= 1 || lexState < 0) { + JAVACC_STRING_TYPE message; +#ifdef WIDE_CHAR + message += L"Error: Ignoring invalid lexical state : "; + message += lexState; message += L". State unchanged."; +#else + message += "Error: Ignoring invalid lexical state : "; + message += lexState; message += ". State unchanged."; +#endif + throw new TokenMgrError(message, INVALID_LEXICAL_STATE); + } else curLexState = lexState; } @@ -3623,14 +3633,23 @@ void VhdlParserTokenManager::TokenLexicalActions(Token *matchedToken){ VhdlParserTokenManager::VhdlParserTokenManager (JAVACC_CHARSTREAM *stream, int lexState, VhdlParser *parserArg) { input_stream = NULL; + errorHandlerCreated = false; ReInit(stream, lexState, parserArg); } // Destructor VhdlParserTokenManager::~VhdlParserTokenManager () { - if (input_stream) delete input_stream; - if (errorHandlerCreated) delete errorHandler; + clear(); + } + + // clear + void VhdlParserTokenManager::clear() { + //Since input_stream was generated outside of TokenManager + //TokenManager should not take care of deleting it + //if (input_stream) delete input_stream; + if (errorHandlerCreated) delete errorHandler; } + } } |