2 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */
\r
10 package org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse;
\r
12 /** Token Manager Error. */
\r
13 public class TokenMgrError extends Error
\r
17 * The version identifier for this Serializable class.
\r
18 * Increment only if the <i>serialized</i> form of the
\r
21 private static final long serialVersionUID = 1L;
\r
24 * Ordinals for various reasons why an Error of this type can be thrown.
\r
28 * Lexical error occurred.
\r
30 static final int LEXICAL_ERROR = 0;
\r
33 * An attempt was made to create a second instance of a static token manager.
\r
35 static final int STATIC_LEXER_ERROR = 1;
\r
38 * Tried to change to an invalid lexical state.
\r
40 static final int INVALID_LEXICAL_STATE = 2;
\r
43 * Detected (and bailed out of) an infinite loop in the token manager.
\r
45 static final int LOOP_DETECTED = 3;
\r
48 * Indicates the reason why the exception is thrown. It will have
\r
49 * one of the above 4 values.
\r
54 * Replaces unprintable characters by their escaped (or unicode escaped)
\r
55 * equivalents in the given string
\r
57 protected static final String addEscapes(String str) {
\r
58 StringBuffer retval = new StringBuffer();
\r
60 for (int i = 0; i < str.length(); i++) {
\r
61 switch (str.charAt(i))
\r
66 retval.append("\\b");
\r
69 retval.append("\\t");
\r
72 retval.append("\\n");
\r
75 retval.append("\\f");
\r
78 retval.append("\\r");
\r
81 retval.append("\\\"");
\r
84 retval.append("\\\'");
\r
87 retval.append("\\\\");
\r
90 if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
\r
91 String s = "0000" + Integer.toString(ch, 16);
\r
92 retval.append("\\u" + s.substring(s.length() - 4, s.length()));
\r
99 return retval.toString();
\r
103 * Returns a detailed message for the Error when it is thrown by the
\r
104 * token manager to indicate a lexical error.
\r
106 * EOFSeen : indicates if EOF caused the lexical error
\r
107 * curLexState : lexical state in which this error occurred
\r
108 * errorLine : line number when the error occurred
\r
109 * errorColumn : column number when the error occurred
\r
110 * errorAfter : prefix that was seen before this error occurred
\r
111 * curchar : the offending character
\r
112 * Note: You can customize the lexical error message by modifying this method.
\r
114 protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
\r
115 return("Lexical error at line " +
\r
116 errorLine + ", column " +
\r
117 errorColumn + ". Encountered: " +
\r
118 (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
\r
119 "after : \"" + addEscapes(errorAfter) + "\"");
\r
123 * You can also modify the body of this method to customize your error messages.
\r
124 * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
\r
125 * of end-users concern, so you can return something like :
\r
127 * "Internal Error : Please file a bug report .... "
\r
129 * from this method for such cases in the release version of your parser.
\r
131 public String getMessage() {
\r
132 return super.getMessage();
\r
136 * Constructors of various flavors follow.
\r
139 /** No arg constructor. */
\r
140 public TokenMgrError() {
\r
143 /** Constructor with message and reason. */
\r
144 public TokenMgrError(String message, int reason) {
\r
146 errorCode = reason;
\r
149 /** Full Constructor. */
\r
150 public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
\r
151 this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
\r
154 /* JavaCC - OriginalChecksum=91ec89f496ecd57e6511b78a642440de (do not edit this line) */
\r