Doxygen
Toggle main menu visibility
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
11
namespace
vhdl
{
12
namespace
parser
{
13
14
JJSimpleString
addUnicodeEscapes
(
const
JJString
& str);
15
16
class
VhdlParser
;
17
class
ErrorHandler
{
18
friend
class
VhdlParserTokenManager
;
19
friend
class
VhdlParser
;
20
protected
:
21
int
error_count
;
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
) {
29
error_count
++;
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
) {
37
error_count
++;
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
() {}
47
ErrorHandler
() {
error_count
= 0; }
48
};
49
50
class
VhdlParserTokenManager;
51
class
TokenManagerErrorHandler
{
52
friend
class
VhdlParserTokenManager
;
53
protected
:
54
int
error_count
;
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
}
73
virtual
~TokenManagerErrorHandler
() {}
74
};
75
76
}
77
}
78
79
#endif
80
81
/* JavaCC - OriginalChecksum=606dd7f8d67c1d0f99424d91ac3656c0 (do not edit this line) */
JavaCC.h
JJString
JAVACC_STRING_TYPE JJString
Definition
JavaCC.h:22
JJChar
JAVACC_CHAR_TYPE JJChar
Definition
JavaCC.h:21
JJSimpleString
JAVACC_SIMPLE_STRING JJSimpleString
Definition
JavaCC.h:24
Token.h
vhdl::parser::ErrorHandler::~ErrorHandler
virtual ~ErrorHandler()
Definition
ErrorHandler.h:46
vhdl::parser::ErrorHandler::handleUnexpectedToken
virtual void handleUnexpectedToken(int expectedKind, const JJString &expectedToken, Token *actual, VhdlParser *parser)
Definition
ErrorHandler.h:28
vhdl::parser::ErrorHandler::ErrorHandler
ErrorHandler()
Definition
ErrorHandler.h:47
vhdl::parser::ErrorHandler::VhdlParser
friend class VhdlParser
Definition
ErrorHandler.h:19
vhdl::parser::ErrorHandler::getErrorCount
virtual int getErrorCount()
Definition
ErrorHandler.h:40
vhdl::parser::ErrorHandler::handleParseError
virtual void handleParseError(Token *last, Token *unexpected, const JJSimpleString &production, VhdlParser *parser)
Definition
ErrorHandler.h:36
vhdl::parser::ErrorHandler::handleOtherError
virtual void handleOtherError(const JJString &message, VhdlParser *parser)
Definition
ErrorHandler.h:43
vhdl::parser::ErrorHandler::error_count
int error_count
Definition
ErrorHandler.h:21
vhdl::parser::ErrorHandler::VhdlParserTokenManager
friend class VhdlParserTokenManager
Definition
ErrorHandler.h:18
vhdl::parser::Token
Describes the input token stream.
Definition
Token.h:17
vhdl::parser::Token::image
JJString image
The string image of the token.
Definition
Token.h:39
vhdl::parser::Token::beginColumn
int beginColumn
The column number of the first character of this Token.
Definition
Token.h:30
vhdl::parser::Token::beginLine
int beginLine
The line number of the first character of this Token.
Definition
Token.h:28
vhdl::parser::TokenManagerErrorHandler
Definition
ErrorHandler.h:51
vhdl::parser::TokenManagerErrorHandler::~TokenManagerErrorHandler
virtual ~TokenManagerErrorHandler()
Definition
ErrorHandler.h:73
vhdl::parser::TokenManagerErrorHandler::lexicalError
virtual void lexicalError(bool EOFSeen, int lexState, int errorLine, int errorColumn, const JJString &errorAfter, JJChar curChar, VhdlParserTokenManager *token_manager)
Definition
ErrorHandler.h:66
vhdl::parser::TokenManagerErrorHandler::error_count
int error_count
Definition
ErrorHandler.h:54
vhdl::parser::TokenManagerErrorHandler::lexicalError
virtual void lexicalError(const JJString &errorMessage, VhdlParserTokenManager *token_manager)
Definition
ErrorHandler.h:70
vhdl::parser::TokenManagerErrorHandler::VhdlParserTokenManager
friend class VhdlParserTokenManager
Definition
ErrorHandler.h:52
vhdl::parser::VhdlParser
Definition
VhdlParser.h:21
vhdl::parser
Definition
CharStream.h:13
vhdl::parser::addUnicodeEscapes
JJSimpleString addUnicodeEscapes(const JJString &str)
vhdl
Token literal values and constants.
Definition
CharStream.h:12
vhdlparser
ErrorHandler.h
Generated by
1.17.0