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