Doxygen
VhdlParserErrorHandler.hpp
浏览该文件的文档.
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 
12 const char *getVhdlFileName(void);
13 
14 namespace 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());
24  error_count++;
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());
31  error_count++;
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());
38  error_count++;
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 
ErrorHandler.h
vhdl::parser::VhdlTokenManagerErrorHandler::lexicalError
virtual void lexicalError(const JJString &errorMessage, VhdlParserTokenManager *token_manager)
Definition: VhdlParserErrorHandler.hpp:56
vhdl::parser::VhdlTokenManagerErrorHandler
Definition: VhdlParserErrorHandler.hpp:46
vhdl::parser::Token::beginLine
int beginLine
The line number of the first character of this Token.
Definition: Token.h:28
vhdl::parser::Token
Describes the input token stream.
Definition: Token.h:16
JJSimpleString
JAVACC_SIMPLE_STRING JJSimpleString
Definition: JavaCC.h:24
vhdl::parser::VhdlTokenManagerErrorHandler::VhdlTokenManagerErrorHandler
VhdlTokenManagerErrorHandler(const char *fileName)
Definition: VhdlParserErrorHandler.hpp:49
JJChar
JAVACC_CHAR_TYPE JJChar
Definition: JavaCC.h:21
vhdl::parser::VhdlErrorHandler::handleOtherError
virtual void handleOtherError(const JJString &message, VhdlParser *parser)
Definition: VhdlParserErrorHandler.hpp:35
vhdl::parser::VhdlErrorHandler::handleUnexpectedToken
virtual void handleUnexpectedToken(int expectedKind, const JJString &expectedToken, Token *actual, VhdlParser *parser)
Definition: VhdlParserErrorHandler.hpp:21
vhdl::parser::VhdlParser
Definition: VhdlParser.h:21
vhdl::parser::ErrorHandler
Definition: ErrorHandler.h:17
vhdl::parser::VhdlParserTokenManager
Token Manager.
Definition: VhdlParserTokenManager.h:18
vhdl::parser::VhdlTokenManagerErrorHandler::m_fileName
QCString m_fileName
Definition: VhdlParserErrorHandler.hpp:62
warn
void warn(const QCString &file, int line, const char *fmt,...)
Definition: message.cpp:151
vhdl::parser::VhdlErrorHandler::VhdlErrorHandler
VhdlErrorHandler(const char *fileName)
Definition: VhdlParserErrorHandler.hpp:19
vhdl::parser::VhdlTokenManagerErrorHandler::lexicalError
virtual void lexicalError(bool EOFSeen, int lexState, int errorLine, int errorColumn, const JJString &errorAfter, JJChar curChar, VhdlParserTokenManager *token_manager)
Definition: VhdlParserErrorHandler.hpp:51
message.h
vhdl::parser::Token::image
JJString image
The string image of the token.
Definition: Token.h:39
vhdl
Token literal values and constants.
Definition: CharStream.h:12
vhdl::parser::VhdlErrorHandler
Definition: VhdlParserErrorHandler.hpp:16
vhdl::parser::ErrorHandler::error_count
int error_count
Definition: ErrorHandler.h:21
getVhdlFileName
const char * getVhdlFileName(void)
JJString
JAVACC_STRING_TYPE JJString
Definition: JavaCC.h:22
vhdlstring.h
vhdl::parser::VhdlErrorHandler::handleParseError
virtual void handleParseError(Token *last, Token *unexpected, const JJSimpleString &production, VhdlParser *parser)
Definition: VhdlParserErrorHandler.hpp:28
VhdlParser.h
vhdl::parser::VhdlErrorHandler::m_fileName
QCString m_fileName
Definition: VhdlParserErrorHandler.hpp:43
vhdl::parser::TokenManagerErrorHandler
Definition: ErrorHandler.h:51
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108