Doxygen
Loading...
Searching...
No Matches
VhdlParserErrorHandler.hpp
Go to the documentation of this file.
1#ifndef VHDLPARSERERRORHANDLER_H
2#define VHDLPARSERERRORHANDLER_H
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <exception>
7#include "VhdlParser.h"
8#include "ErrorHandler.h"
9#include "vhdlstring.h"
10#include "message.h"
11
12const char *getVhdlFileName(void);
13
14namespace vhdl { namespace parser {
15
17{
18 public:
19 VhdlErrorHandler(const char *fileName) : m_fileName(fileName) {}
20
21 virtual void handleUnexpectedToken(int /* expectedKind */, const JJString& /* expectedToken */, Token *actual, VhdlParser * /* parser */)
22 {
23 warn(m_fileName,actual->beginLine,"syntax error '%s'",actual->image.data());
25 throw std::exception();
26 }
27
28 virtual void handleParseError(Token *last, Token *unexpected, const JJSimpleString& /* production */, VhdlParser * /* parser */)
29 {
30 warn(m_fileName,last->beginLine,"unexpected token: '%s'", unexpected->image.data());
32 throw std::exception();
33 }
34
35 virtual void handleOtherError(const JJString& message, VhdlParser * /* parser */)
36 {
37 warn(m_fileName, -1, "unexpected error: '%s'", (char*)message.c_str());
39 throw std::exception();
40 }
41
42 private:
44};
45
47{
48 public:
49 VhdlTokenManagerErrorHandler(const char *fileName) : m_fileName(fileName) {}
50
51 virtual void lexicalError(bool EOFSeen, int /* lexState */, int errorLine, int /* errorColumn */, const JJString& errorAfter, JJChar curChar, VhdlParserTokenManager* /* token_manager */)
52 {
53 warn(m_fileName,errorLine,"Lexical error, Encountered: '%c' after: '%s'",curChar, (EOFSeen? "EOF" : (const char*)errorAfter.c_str()));
54 }
55
56 virtual void lexicalError(const JJString& errorMessage, VhdlParserTokenManager* /* token_manager */)
57 {
58 warn(m_fileName,-1,"Unknown error: '%s'", (char*)errorMessage.c_str());
59 }
60
61 private:
63};
64
65} }
66
67#endif
68
JAVACC_STRING_TYPE JJString
Definition JavaCC.h:22
JAVACC_CHAR_TYPE JJChar
Definition JavaCC.h:21
JAVACC_SIMPLE_STRING JJSimpleString
Definition JavaCC.h:24
const char * getVhdlFileName(void)
This is an alternative implementation of QCString.
Definition qcstring.h:101
Describes the input token stream.
Definition Token.h:17
JJString image
The string image of the token.
Definition Token.h:39
int beginLine
The line number of the first character of this Token.
Definition Token.h:28
virtual void handleParseError(Token *last, Token *unexpected, const JJSimpleString &, VhdlParser *)
virtual void handleOtherError(const JJString &message, VhdlParser *)
virtual void handleUnexpectedToken(int, const JJString &, Token *actual, VhdlParser *)
virtual void lexicalError(const JJString &errorMessage, VhdlParserTokenManager *)
virtual void lexicalError(bool EOFSeen, int, int errorLine, int, const JJString &errorAfter, JJChar curChar, VhdlParserTokenManager *)
#define warn(file, line, fmt,...)
Definition message.h:59
Token literal values and constants.
Definition CharStream.h:12