TokenMgrError.cc
Go to the documentation of this file.
1 /* Generated By:JavaCC: Do not edit this line. TokenMgrError.cc Version 6.2 */
2 /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
3 #include "TokenMgrError.h"
4 
5 namespace vhdl {
6 namespace parser {
7 
8  /**
9  * Returns a detailed message for the Error when it is thrown by the
10  * token manager to indicate a lexical error.
11  * Parameters :
12  * EOFSeen : indicates if EOF caused the lexical error
13  * curLexState : lexical state in which this error occurred
14  * errorLine : line number when the error occurred
15  * errorColumn : column number when the error occurred
16  * errorAfter : prefix that was seen before this error occurred
17  * curJAVACC_CHAR_TYPE : the offending character
18  * Note: You can customize the lexical error message by modifying this method.
19  */
20  JAVACC_STRING_TYPE TokenMgrError::LexicalError(bool EOFSeen, int lexState, int errorLine, int errorColumn, JAVACC_STRING_TYPE errorAfter, JAVACC_CHAR_TYPE curChar) {
21 #if 0
23  stringstream<JAVACC_STRING_TYPE> ss;
24  ss << "Lexical error at line " << errorLine << " column " << errorColumn
25  << ". Encountered: " << curChar << "(" << (int)curChar
26  << ") after : \"" << errorAfter.c_str() << "\"";
27  return (JAVACC_STRING_TYPE)ss.rdbuf()->str();
28 #endif
29  return EMPTY;
30  }
31 
32  /**
33  * You can also modify the body of this method to customize your error messages.
34  * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
35  * of end-users concern, so you can return something like :
36  *
37  * "Internal Error : Please file a bug report .... "
38  *
39  * from this method for such cases in the release version of your parser.
40  */
42  return message;
43  }
44 
45  /*
46  * Constructors of various flavors follow.
47  */
48 
49  /** No arg constructor. */
51  }
52 
53  /** Constructor with message and reason. */
55  errorCode = reason;
56  }
57 
58  /** Full Constructor. */
59  TokenMgrError::TokenMgrError(bool EOFSeen, int lexState, int errorLine, int errorColumn, JAVACC_STRING_TYPE errorAfter, JAVACC_CHAR_TYPE curChar, int reason) {
60  message = LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar);
61  errorCode = reason;
62  }
63 
64 // i < 16 - guaranteed
65 char hexChar(int i) {
66  if (i < 10) {
67  return i + '0';
68  }
69  return 'a' + (i - 10);
70 }
71 
72 /**
73  * Replaces unprintable characters by their escaped (or unicode escaped)
74  * equivalents in the given string
75  */
77  JAVACC_SIMPLE_STRING retval;
78  for (size_t i = 0; i < str.size(); i++) {
79  JAVACC_CHAR_TYPE ch = str[i];
80  switch (ch)
81  {
82  case '\b':
83  retval.append("\\b");
84  continue;
85  case '\t':
86  retval.append("\\t");
87  continue;
88  case '\n':
89  retval.append("\\n");
90  continue;
91  case '\f':
92  retval.append("\\f");
93  continue;
94  case '\r':
95  retval.append("\\r");
96  continue;
97  case '\\':
98  retval.append("\\\\");
99  continue;
100  default:
101  if (ch < 0xff) {
102  retval += ch;
103  continue;
104  }
105  retval.append("\\u");
106  retval += (hexChar(ch >> 12));
107  retval += (hexChar((ch & 0x0f00) >> 8));
108  retval += (hexChar((ch & 0x00f0) >> 4));
109  retval += (hexChar(ch & 0x000f));
110  continue;
111  }
112  }
113  return retval;
114 }
115 
116 }
117 }
118 /* JavaCC - OriginalChecksum=72f292bc267bd0602e63291bf864f942 (do not edit this line) */
#define JAVACC_STRING_TYPE
Definition: JavaCC.h:16
JAVACC_STRING_TYPE getMessage()
JAVACC_STRING_TYPE LexicalError(bool EOFSeen, int lexState, int errorLine, int errorColumn, JAVACC_STRING_TYPE errorAfter, JAVACC_CHAR_TYPE curChar)
#define JAVACC_CHAR_TYPE
Definition: JavaCC.h:12
const JAVACC_CHAR_TYPE EMPTY[]
Definition: JavaCC.h:33
#define JAVACC_SIMPLE_STRING
Definition: JavaCC.h:19
char hexChar(int i)
JAVACC_SIMPLE_STRING addUnicodeEscapes(JAVACC_STRING_TYPE str)
JAVACC_STRING_TYPE message
Definition: TokenMgrError.h:60
static QCString * s
Definition: config.cpp:1042
static QCString str