Doxygen
ErrorHandler.h
浏览该文件的文档.
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 
15 
16  class VhdlParser;
17  class ErrorHandler {
18  friend class VhdlParserTokenManager;
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) {
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 occurrs.
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() {}
48  };
49 
50  class VhdlParserTokenManager;
52  friend class VhdlParserTokenManager;
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=5361b31ac6530c6c23511012deb15394 (do not edit this line) */
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::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
JJChar
JAVACC_CHAR_TYPE JJChar
Definition: JavaCC.h:21
Token.h
vhdl::parser::ErrorHandler::~ErrorHandler
virtual ~ErrorHandler()
Definition: ErrorHandler.h:46
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::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::TokenManagerErrorHandler::error_count
int error_count
Definition: ErrorHandler.h:54
vhdl::parser::ErrorHandler::handleParseError
virtual void handleParseError(Token *last, Token *unexpected, const JJSimpleString &production, VhdlParser *parser)
Definition: ErrorHandler.h:36
vhdl
Token literal values and constants.
Definition: CharStream.h:12
vhdl::parser::ErrorHandler::getErrorCount
virtual int getErrorCount()
Definition: ErrorHandler.h:40
vhdl::parser::ErrorHandler::error_count
int error_count
Definition: ErrorHandler.h:21
vhdl::parser::addUnicodeEscapes
JJSimpleString addUnicodeEscapes(const JJString &str)
JJString
JAVACC_STRING_TYPE JJString
Definition: JavaCC.h:22
vhdl::parser::TokenManagerErrorHandler::lexicalError
virtual void lexicalError(const JJString &errorMessage, VhdlParserTokenManager *token_manager)
Definition: ErrorHandler.h:70
vhdl::parser::TokenManagerErrorHandler
Definition: ErrorHandler.h:51
JavaCC.h
vhdl::parser::ErrorHandler::handleOtherError
virtual void handleOtherError(const JJString &message, VhdlParser *parser)
Definition: ErrorHandler.h:43
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::~TokenManagerErrorHandler
virtual ~TokenManagerErrorHandler()
Definition: ErrorHandler.h:73