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