/* Generated by AspectJ version 0.7beta7 */ import Token; /** * This exception is thrown when parse errors are encountered. * You can explicitly create objects of this exception type by * calling the method generateParseException in the generated * parser. * * You can modify this class to customize your error reporting * mechanisms so long as you retain the public fields. */ public class ParseException extends java.lang.Exception { //from ParseException.java:11 /** * This constructor is used by the method "generateParseException" * in the generated parser. Calling this constructor generates * a new object of this type with the fields "currentToken", * "expectedTokenSequences", and "tokenImage" set. The boolean * flag "specialConstructor" is also set to true to indicate that * this constructor was used to create this object. * This constructor calls its super class with the empty string * to force the "toString" method of parent class "Throwable" to * print the error message in the form: * ParseException: */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, java.lang.String[] tokenImageVal) { //from ParseException.java:29 super(""); //from ParseException.java:30 ; //from ParseException.java:30 specialConstructor = true; //from ParseException.java:31 currentToken = currentTokenVal; //from ParseException.java:32 expectedTokenSequences = expectedTokenSequencesVal; //from ParseException.java:33 tokenImage = tokenImageVal; //from ParseException.java:34 } /** * The following constructors are for use by you for whatever * purpose you can think of. Constructing the exception in this * manner makes the exception behave in the normal way - i.e., as * documented in the class "Throwable". The fields "errorToken", * "expectedTokenSequences", and "tokenImage" do not contain * relevant information. The JavaCC generated code does not use * these constructors. */ public ParseException() { //from ParseException.java:47 super(); //from ParseException.java:48 ; //from ParseException.java:48 specialConstructor = false; //from ParseException.java:49 } public ParseException(java.lang.String message) { //from ParseException.java:52 super(message); //from ParseException.java:53 ; //from ParseException.java:53 specialConstructor = false; //from ParseException.java:54 } /** * This variable determines which constructor was used to create * this object and thereby affects the semantics of the * "getMessage" method (see below). */ protected boolean specialConstructor; //from ParseException.java:62 /** * This is the last token that has been consumed successfully. If * this object has been created due to a parse error, the token * followng this token will (therefore) be the first error token. */ public Token currentToken; //from ParseException.java:69 /** * Each entry in this array is an array of integers. Each array * of integers represents a sequence of tokens (by their ordinal * values) that is expected at this point of the parse. */ public int[][] expectedTokenSequences; //from ParseException.java:76 /** * This is a reference to the "tokenImage" array of the generated * parser within which the parse error occurred. This array is * defined in the generated ...Constants interface. */ public java.lang.String[] tokenImage; //from ParseException.java:83 /** * This method has the standard behavior when this object has been * created using the standard constructors. Otherwise, it uses * "currentToken" and "expectedTokenSequences" to generate a parse * error message and returns it. If this object has been created * due to a parse error, and you do not catch it (it gets thrown * from the parser), then this method is called during the printing * of the final stack trace, and hence the correct error message * gets displayed. */ public java.lang.String getMessage() { //from ParseException.java:95 if (!specialConstructor) { //from ParseException.java:96 return super.getMessage(); //from ParseException.java:97 } java.lang.String expected = ""; //from ParseException.java:99 int maxSize = 0; //from ParseException.java:100 for (int i = 0; i < expectedTokenSequences.length; i++) { //from ParseException.java:101 if (maxSize < expectedTokenSequences[i].length) { //from ParseException.java:102 maxSize = expectedTokenSequences[i].length; //from ParseException.java:103 } for (int j = 0; j < expectedTokenSequences[i].length; j++) { //from ParseException.java:105 expected += tokenImage[expectedTokenSequences[i][j]] + " "; //from ParseException.java:106 } if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { //from ParseException.java:108 expected += "..."; //from ParseException.java:109 } expected += eol + " "; //from ParseException.java:111 } java.lang.String retval = "Encountered \""; //from ParseException.java:113 Token tok = currentToken.next; //from ParseException.java:114 for (int i = 0; i < maxSize; i++) { //from ParseException.java:115 if (i != 0) retval += " "; //from ParseException.java:116 if (tok.kind == 0) { //from ParseException.java:117 retval += tokenImage[0]; //from ParseException.java:118 break; //from ParseException.java:119 } retval += add_escapes(tok.image); //from ParseException.java:121 tok = tok.next; //from ParseException.java:122 } retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn + "." + eol; //from ParseException.java:124 if (expectedTokenSequences.length == 1) { //from ParseException.java:125 retval += "Was expecting:" + eol + " "; //from ParseException.java:126 } else { //from ParseException.java:127 retval += "Was expecting one of:" + eol + " "; //from ParseException.java:128 } retval += expected; //from ParseException.java:130 return retval; //from ParseException.java:131 } /** * The end of line string for this machine. */ protected java.lang.String eol = java.lang.System.getProperty("line.separator", "\n"); //from ParseException.java:137 /** * Used to convert raw characters to their escaped version * when these raw version cannot be used as part of an ASCII * string literal. */ protected java.lang.String add_escapes(java.lang.String str) { //from ParseException.java:144 java.lang.StringBuffer retval = new java.lang.StringBuffer(); //from ParseException.java:145 char ch; //from ParseException.java:146 for (int i = 0; i < str.length(); i++) { //from ParseException.java:147 switch (str.charAt(i)) { //from ParseException.java:148 case 0: //from ParseException.java:150 continue; //from ParseException.java:151 case '\b': //from ParseException.java:152 retval.append("\\b"); //from ParseException.java:153 continue; //from ParseException.java:154 case '\t': //from ParseException.java:155 retval.append("\\t"); //from ParseException.java:156 continue; //from ParseException.java:157 case '\n': //from ParseException.java:158 retval.append("\\n"); //from ParseException.java:159 continue; //from ParseException.java:160 case '\f': //from ParseException.java:161 retval.append("\\f"); //from ParseException.java:162 continue; //from ParseException.java:163 case '\r': //from ParseException.java:164 retval.append("\\r"); //from ParseException.java:165 continue; //from ParseException.java:166 case '\"': //from ParseException.java:167 retval.append("\\\""); //from ParseException.java:168 continue; //from ParseException.java:169 case '\'': //from ParseException.java:170 retval.append("\\\'"); //from ParseException.java:171 continue; //from ParseException.java:172 case '\\': //from ParseException.java:173 retval.append("\\\\"); //from ParseException.java:174 continue; //from ParseException.java:175 default: if ((ch = str.charAt(i)) < 32 || ch > 126) { //from ParseException.java:177 java.lang.String s = "0000" + java.lang.Integer.toString(ch, 16); //from ParseException.java:178 retval.append("\\u" + s.substring(s.length() - 4, s.length())); //from ParseException.java:179 } else { //from ParseException.java:180 retval.append(ch); //from ParseException.java:181 } continue; //from ParseException.java:183 } } return retval.toString(); //from ParseException.java:186 } }