diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2014-08-11 08:26:44 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2014-08-11 08:26:44 (GMT) |
commit | 3b8fea2f1f7f2e6a83a35626e6dec9d114a78c9e (patch) | |
tree | ee911a840e38f46d7388237c019866efa191e15d /vhdlparser/ErrorHandler.h | |
parent | 7506404e646f1fcc5a26ca6fca91a7f65154f05a (diff) | |
download | Doxygen-3b8fea2f1f7f2e6a83a35626e6dec9d114a78c9e.zip Doxygen-3b8fea2f1f7f2e6a83a35626e6dec9d114a78c9e.tar.gz Doxygen-3b8fea2f1f7f2e6a83a35626e6dec9d114a78c9e.tar.bz2 |
Vhdl fixes
Diffstat (limited to 'vhdlparser/ErrorHandler.h')
-rw-r--r-- | vhdlparser/ErrorHandler.h | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/vhdlparser/ErrorHandler.h b/vhdlparser/ErrorHandler.h index 9f0d38c..fba0a0e 100644 --- a/vhdlparser/ErrorHandler.h +++ b/vhdlparser/ErrorHandler.h @@ -1,15 +1,20 @@ /* Generated By:JavaCC: Do not edit this line. ErrorHandler.h Version 6.0 */ -/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true,BUILD_PARSER=true,BUILD_TOKEN_MANAGER=true */ #ifndef ERRORHANDLER_H #define ERRORHANDLER_H -#include <string> +//#include <string> #include "JavaCC.h" #include "Token.h" namespace vhdl { namespace parser { -class VhdlParser; + +//JAVACC_SIMPLE_STRING addUnicodeEscapes(JAVACC_STRING_TYPE str); + + class VhdlParser; class ErrorHandler { + friend class VhdlParserTokenManager; + friend class VhdlParser; protected: int error_count; public: @@ -18,26 +23,56 @@ class VhdlParser; // expectedKind - token kind that the parser was trying to consume. // expectedToken - the image of the token - tokenImages[expectedKind]. // actual - the actual token that the parser got instead. - virtual void handleUnexpectedToken(int, JAVACC_STRING_TYPE expectedToken, Token *actual, VhdlParser *) { + virtual void handleUnexpectedToken(int , JAVACC_STRING_TYPE , Token *, VhdlParser *) { error_count++; - fprintf(stderr, "Expecting %s at: %d:%d but got %s\n", addUnicodeEscapes(expectedToken).c_str(), actual->beginLine, actual->beginColumn, addUnicodeEscapes(actual->image).c_str()); + // fprintf(stderr, "Expecting %s at: %d:%d but got %s\n", addUnicodeEscapes(expectedToken).c_str(), actual->beginLine, actual->beginColumn, addUnicodeEscapes(actual->image).c_str()); } // Called when the parser cannot continue parsing. // last - the last token successfully parsed. // unexpected - the token at which the error occurs. // production - the production in which this error occurrs. - virtual void handleParseError(Token *, Token *unexpected, JAVACC_SIMPLE_STRING production, VhdlParser *) { + virtual void handleParseError(Token *, Token *, JAVACC_SIMPLE_STRING , VhdlParser *) { error_count++; - fprintf(stderr, "Encountered: %s at: %d:%d while parsing: %s\n", addUnicodeEscapes(unexpected->image).c_str(), unexpected->beginLine, unexpected->beginColumn, production.c_str()); + // fprintf(stderr, "Encountered: %s at: %d:%d while parsing: %s\n", addUnicodeEscapes(unexpected->image).c_str(), unexpected->beginLine, unexpected->beginColumn, production.c_str()); } virtual int getErrorCount() { return error_count; } + virtual void handleOtherError(JAVACC_STRING_TYPE message, VhdlParser *) { + fprintf(stderr, "Error: %s\n", (char*)message.c_str()); + } virtual ~ErrorHandler() {} ErrorHandler() { error_count = 0; } }; + + class VhdlParserTokenManager; + class TokenManagerErrorHandler { + friend class VhdlParserTokenManager; + protected: + int error_count; + public: + // Returns a detailed message for the Error when it is thrown by the + // token manager to indicate a lexical error. + // Parameters : + // EOFSeen : indicates if EOF caused the lexical error + // curLexState : lexical state in which this error occurred + // errorLine : line number when the error occurred + // errorColumn : column number when the error occurred + // errorAfter : prefix that was seen before this error occurred + // curchar : the offending character + // + virtual void lexicalError(bool EOFSeen, int /*lexState*/, int errorLine, int errorColumn, JAVACC_STRING_TYPE errorAfter, JAVACC_CHAR_TYPE curChar, VhdlParserTokenManager*) { + // by default, we just print an error message and return. + fprintf(stderr, "Lexical error at: %d:%d. Encountered: %c after: %s.\n", errorLine, errorColumn, curChar, (EOFSeen? "EOF" : (const char*)errorAfter.c_str())); + } + virtual void lexicalError(JAVACC_STRING_TYPE errorMessage, VhdlParserTokenManager* ) { + fprintf(stderr, "%s\n", (char*)errorMessage.c_str()); + } + virtual ~TokenManagerErrorHandler() {} + }; + } } #endif -/* JavaCC - OriginalChecksum=282223c3bcb53b7ff385aed35944d185 (do not edit this line) */ +/* JavaCC - OriginalChecksum=685d19cb4cd943b60089f599e45f23ad (do not edit this line) */ |