55286b48827459fecc9677feb64bc30a44f2695e
[platform/upstream/doxygen.git] / vhdlparser / ErrorHandler.h
1 /* Generated By:JavaCC: Do not edit this line. ErrorHandler.h Version 6.0 */
2 /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true,BUILD_PARSER=true,BUILD_TOKEN_MANAGER=true */
3 #ifndef ERRORHANDLER_H
4 #define ERRORHANDLER_H
5 #include <string>
6 #include "JavaCC.h"
7 #include "Token.h"
8
9 namespace vhdl {
10 namespace parser {
11
12 JAVACC_SIMPLE_STRING addUnicodeEscapes(JAVACC_STRING_TYPE str);
13
14   class VhdlParser;
15   class ErrorHandler {
16     friend class VhdlParserTokenManager;
17     friend class VhdlParser;
18     protected:
19       int error_count;
20     public:
21       // Called when the parser encounters a different token when expecting to
22       // consume a specific kind of token.
23       // expectedKind - token kind that the parser was trying to consume.
24       // expectedToken - the image of the token - tokenImages[expectedKind].
25       // actual - the actual token that the parser got instead.
26       virtual void handleUnexpectedToken(int expectedKind, JAVACC_STRING_TYPE expectedToken, Token *actual, VhdlParser *parser) {
27         error_count++;
28         fprintf(stderr, "Expecting %s at: %d:%d but got %s\n", addUnicodeEscapes(expectedToken).c_str(), actual->beginLine, actual->beginColumn, addUnicodeEscapes(actual->image).c_str());
29       }
30       // Called when the parser cannot continue parsing.
31       // last - the last token successfully parsed.
32       // unexpected - the token at which the error occurs.
33       // production - the production in which this error occurrs.
34       virtual void handleParseError(Token *last, Token *unexpected, JAVACC_SIMPLE_STRING production, VhdlParser *parser) {
35         error_count++;
36         fprintf(stderr, "Encountered: %s at: %d:%d while parsing: %s\n", addUnicodeEscapes(unexpected->image).c_str(), unexpected->beginLine, unexpected->beginColumn, production.c_str());
37       }
38       virtual int getErrorCount() {
39         return error_count;
40       }
41       virtual void handleOtherError(JAVACC_STRING_TYPE message, VhdlParser *parser) {
42         fprintf(stderr, "Error: %s\n", (char*)message.c_str());
43       }
44       virtual ~ErrorHandler() {}
45       ErrorHandler() { error_count = 0; }
46   };
47
48   class VhdlParserTokenManager;
49   class TokenManagerErrorHandler {
50     friend class VhdlParserTokenManager;
51     protected:
52       int error_count;
53     public:
54        // Returns a detailed message for the Error when it is thrown by the
55        // token manager to indicate a lexical error.
56        // Parameters :
57        //    EOFSeen     : indicates if EOF caused the lexical error
58        //    curLexState : lexical state in which this error occurred
59        //    errorLine   : line number when the error occurred
60        //    errorColumn : column number when the error occurred
61        //    errorAfter  : prefix that was seen before this error occurred
62        //    curchar     : the offending character
63        //
64        virtual void lexicalError(bool EOFSeen, int lexState, int errorLine, int errorColumn, JAVACC_STRING_TYPE errorAfter, JAVACC_CHAR_TYPE curChar, VhdlParserTokenManager* token_manager) {
65         // by default, we just print an error message and return.
66         fprintf(stderr, "Lexical error at: %d:%d. Encountered: %c after: %s.\n", errorLine, errorColumn, curChar, (EOFSeen? "EOF" : (const char*)errorAfter.c_str()));
67       }
68        virtual void lexicalError(JAVACC_STRING_TYPE errorMessage, VhdlParserTokenManager* token_manager) {
69         fprintf(stderr, "%s\n", (char*)errorMessage.c_str());
70       }
71       virtual ~TokenManagerErrorHandler() {}
72   };
73
74 }
75 }
76
77 #endif
78 /* JavaCC - OriginalChecksum=685d19cb4cd943b60089f599e45f23ad (do not edit this line) */