Debian Codegraph @

Source/Parser/FunctionalJAVACC/TokenMgrError.cpp

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