5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 /* 26 * Copyright (C) 2004-2011 27 * 28 * Permission is hereby granted, free of charge, to any person obtaining a copy 29 * of this software and associated documentation files (the "Software"), to deal 30 * in the Software without restriction, including without limitation the rights 31 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 32 * copies of the Software, and to permit persons to whom the Software is 33 * furnished to do so, subject to the following conditions: 34 * 35 * The above copyright notice and this permission notice shall be included in 36 * all copies or substantial portions of the Software. 37 * 38 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 39 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 40 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 41 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 42 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 43 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 44 * THE SOFTWARE. 45 */ 46 /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */ 47 /* JavaCCOptions: */ 48 package com.sun.xml.internal.rngom.parse.compact; 49 50 /** Token Manager Error. */ 51 public class TokenMgrError extends Error 52 { 53 54 /** 55 * The version identifier for this Serializable class. 56 * Increment only if the <i>serialized</i> form of the 57 * class changes. 58 */ 59 private static final long serialVersionUID = 1L; 60 61 /* 62 * Ordinals for various reasons why an Error of this type can be thrown. 63 */ 64 65 /** 66 * Lexical error occurred. 67 */ 68 static final int LEXICAL_ERROR = 0; 69 70 /** 71 * An attempt was made to create a second instance of a static token manager. 72 */ 73 static final int STATIC_LEXER_ERROR = 1; 74 75 /** 76 * Tried to change to an invalid lexical state. 77 */ 78 static final int INVALID_LEXICAL_STATE = 2; 79 80 /** 81 * Detected (and bailed out of) an infinite loop in the token manager. 82 */ 83 static final int LOOP_DETECTED = 3; 84 85 /** 86 * Indicates the reason why the exception is thrown. It will have 87 * one of the above 4 values. 88 */ 89 int errorCode; 90 91 /** 92 * Replaces unprintable characters by their escaped (or unicode escaped) 93 * equivalents in the given string 94 */ 95 protected static final String addEscapes(String str) { 96 StringBuffer retval = new StringBuffer(); 97 char ch; 98 for (int i = 0; i < str.length(); i++) { 99 switch (str.charAt(i)) 100 { 101 case 0 : 102 continue; 103 case '\b': 104 retval.append("\\b"); 105 continue; 106 case '\t': 107 retval.append("\\t"); 108 continue; 109 case '\n': 110 retval.append("\\n"); 111 continue; 112 case '\f': 124 case '\\': 125 retval.append("\\\\"); 126 continue; 127 default: 128 if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { 129 String s = "0000" + Integer.toString(ch, 16); 130 retval.append("\\u" + s.substring(s.length() - 4, s.length())); 131 } else { 132 retval.append(ch); 133 } 134 continue; 135 } 136 } 137 return retval.toString(); 138 } 139 140 /** 141 * Returns a detailed message for the Error when it is thrown by the 142 * token manager to indicate a lexical error. 143 * Parameters : 144 * EOFSeen : indicates if EOF caused the lexical error 145 * curLexState : lexical state in which this error occurred 146 * errorLine : line number when the error occurred 147 * errorColumn : column number when the error occurred 148 * errorAfter : prefix that was seen before this error occurred 149 * curchar : the offending character 150 * Note: You can customize the lexical error message by modifying this method. 151 */ 152 protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { 153 return("Lexical error at line " + 154 errorLine + ", column " + 155 errorColumn + ". Encountered: " + 156 (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + 157 "after : \"" + addEscapes(errorAfter) + "\""); 158 } 159 160 /** 161 * You can also modify the body of this method to customize your error messages. 162 * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not 163 * of end-users concern, so you can return something like : 164 * 165 * "Internal Error : Please file a bug report .... " 166 * 167 * from this method for such cases in the release version of your parser. 168 */ 169 public String getMessage() { 170 return super.getMessage(); 171 } 172 173 /* 174 * Constructors of various flavors follow. 175 */ 176 177 /** No arg constructor. */ 178 public TokenMgrError() { 179 } 180 181 /** Constructor with message and reason. */ 182 public TokenMgrError(String message, int reason) { 183 super(message); 184 errorCode = reason; 185 } 186 187 /** Full Constructor. */ 188 public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { 189 this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); 190 } 191 } 192 /* JavaCC - OriginalChecksum=1d6588bf7a27100c05b06541f6175759 (do not edit this line) */ | 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ 26 package com.sun.xml.internal.rngom.parse.compact; 27 28 public class TokenMgrError extends Error 29 { 30 /* 31 * Ordinals for various reasons why an Error of this type can be thrown. 32 */ 33 34 /** 35 * Lexical error occured. 36 */ 37 static final int LEXICAL_ERROR = 0; 38 39 /** 40 * An attempt wass made to create a second instance of a static token manager. 41 */ 42 static final int STATIC_LEXER_ERROR = 1; 43 44 /** 45 * Tried to change to an invalid lexical state. 46 */ 47 static final int INVALID_LEXICAL_STATE = 2; 48 49 /** 50 * Detected (and bailed out of) an infinite loop in the token manager. 51 */ 52 static final int LOOP_DETECTED = 3; 53 54 /** 55 * Indicates the reason why the exception is thrown. It will have 56 * one of the above 4 values. 57 */ 58 int errorCode; 59 60 /** 61 * Replaces unprintable characters by their espaced (or unicode escaped) 62 * equivalents in the given string 63 */ 64 protected static final String addEscapes(String str) { 65 StringBuffer retval = new StringBuffer(); 66 char ch; 67 for (int i = 0; i < str.length(); i++) { 68 switch (str.charAt(i)) 69 { 70 case 0 : 71 continue; 72 case '\b': 73 retval.append("\\b"); 74 continue; 75 case '\t': 76 retval.append("\\t"); 77 continue; 78 case '\n': 79 retval.append("\\n"); 80 continue; 81 case '\f': 93 case '\\': 94 retval.append("\\\\"); 95 continue; 96 default: 97 if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { 98 String s = "0000" + Integer.toString(ch, 16); 99 retval.append("\\u" + s.substring(s.length() - 4, s.length())); 100 } else { 101 retval.append(ch); 102 } 103 continue; 104 } 105 } 106 return retval.toString(); 107 } 108 109 /** 110 * Returns a detailed message for the Error when it is thrown by the 111 * token manager to indicate a lexical error. 112 * Parameters : 113 * EOFSeen : indicates if EOF caused the lexicl error 114 * curLexState : lexical state in which this error occured 115 * errorLine : line number when the error occured 116 * errorColumn : column number when the error occured 117 * errorAfter : prefix that was seen before this error occured 118 * curchar : the offending character 119 * Note: You can customize the lexical error message by modifying this method. 120 */ 121 protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { 122 return("Lexical error at line " + 123 errorLine + ", column " + 124 errorColumn + ". Encountered: " + 125 (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + 126 "after : \"" + addEscapes(errorAfter) + "\""); 127 } 128 129 /** 130 * You can also modify the body of this method to customize your error messages. 131 * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not 132 * of end-users concern, so you can return something like : 133 * 134 * "Internal Error : Please file a bug report .... " 135 * 136 * from this method for such cases in the release version of your parser. 137 */ 138 public String getMessage() { 139 return super.getMessage(); 140 } 141 142 /* 143 * Constructors of various flavors follow. 144 */ 145 146 public TokenMgrError() { 147 } 148 149 public TokenMgrError(String message, int reason) { 150 super(message); 151 errorCode = reason; 152 } 153 154 public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { 155 this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); 156 } 157 } |