| Matching Statements |
| File1 Line# |
File2 Line# |
Statement |
| 20 | 28 | public class ParseException extends Exception { |
| 34 | 42 | public ParseException(Token currentTokenVal, |
| 35 | 43 | int[][] expectedTokenSequencesVal, |
| 36 | 44 | String[] tokenImageVal |
| 40 | 48 | specialConstructor = true |
| 41 | 49 | currentToken = currentTokenVal |
| 42 | 50 | expectedTokenSequences = expectedTokenSequencesVal |
| 43 | 51 | tokenImage = tokenImageVal |
| 56 | 64 | public ParseException() { |
58 63 | 66 71 | specialConstructor = false |
| 61 | 69 | public ParseException(String message) { |
| 62 | 70 | super(message) |
| 71 | 79 | protected boolean specialConstructor |
| 78 | 86 | public Token currentToken |
| 85 | 93 | public int[][] expectedTokenSequences |
| 92 | 100 | public String[] tokenImage |
| 104 | 112 | public String getMessage() { |
| 105 | 113 | if (!specialConstructor) { |
| 106 | 114 | return super.getMessage() |
| 109 | 117 | int maxSize = 0 |
110 124 156 | 118 132 165 | for (int i = 0 |
| 110 | 118 | i < expectedTokenSequences.length |
110 124 156 | 118 132 165 | i++) { |
| 111 | 119 | if (maxSize < expectedTokenSequences[i].length) { |
| 112 | 120 | maxSize = expectedTokenSequences[i].length |
| 114 | 122 | for (int j = 0 |
| 114 | 122 | j < expectedTokenSequences[i].length |
| 114 | 122 | j++) { |
| 117 | 125 | if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { |
| 122 | 130 | String retval = |
| 123 | 131 | Token tok = currentToken.next |
| 124 | 132 | i < maxSize |
| 125 | 133 | if (i != 0) retval += |
| 126 | 134 | if (tok.kind == 0) { |
| 127 | 135 | retval += tokenImage[0] |
| 130 | 138 | retval += add_escapes(tok.image) |
| 131 | 139 | tok = tok.next |
| 134 | 143 | if (expectedTokenSequences.length == 1) { |
135 137 | 144 146 | retval += + eol + |
| 140 | 149 | return retval |
| 146 | 155 | protected String eol = System.getProperty( , ) |
| 153 | 162 | protected String add_escapes(String str) { |
| 154 | 163 | StringBuffer retval = new StringBuffer() |
| 155 | 164 | char ch |
| 156 | 165 | i < str.length() |
| 157 | 166 | switch (str.charAt(i)) |
| 159 | 168 | case 0 : |
162 165 168 171 174 177 180 183 | 171 174 177 180 183 186 189 192 | retval.append( ) |
| 186 | 195 | if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { |
| 187 | 196 | String s = + Integer.toString(ch, 16) |
| 188 | 197 | retval.append( + s.substring(s.length() - 4, s.length())) |
| 190 | 199 | retval.append(ch) |
| 195 | 204 | return retval.toString() |
| Matching Comments and Strings |
| File1 Line# |
File2 Line# |
Comment/String |
| 12 | 20 | * This exception is thrown when parse errors are encountered. |
| 13 | 21 | * You can explicitly create objects of this exception type by |
| 14 | 22 | * calling the method generateParseException in the generated |
| 15 | 23 | * parser. |
| 17 | 25 | * You can modify this class to customize your error reporting |
| 18 | 26 | * mechanisms so long as you retain the public fields. |
| 23 | 31 | * This constructor is used by the method "generateParseException" |
| 24 | 32 | * in the generated parser. Calling this constructor generates |
| 25 | 33 | * a new object of this type with the fields "currentToken", |
| 26 | 34 | * "expectedTokenSequences", and "tokenImage" set. The boolean |
| 27 | 35 | * flag "specialConstructor" is also set to true to indicate that |
| 28 | 36 | * this constructor was used to create this object. |
| 29 | 37 | * This constructor calls its super class with the empty string |
| 30 | 38 | * to force the "toString" method of parent class "Throwable" to |
| 31 | 39 | * print the error message in the form: |
| 32 | 40 | * ParseException: <result of getMessage> |
| 47 | 55 | * The following constructors are for use by you for whatever |
| 48 | 56 | * purpose you can think of. Constructing the exception in this |
| 49 | 57 | * manner makes the exception behave in the normal way - i.e., as |
| 50 | 58 | * documented in the class "Throwable". The fields "errorToken", |
| 51 | 59 | * "expectedTokenSequences", and "tokenImage" do not contain |
| 52 | 60 | * relevant information. The JavaCC generated code does not use |
| 53 | 61 | * these constructors. |
| 67 | 75 | * This variable determines which constructor was used to create |
| 68 | 76 | * this object and thereby affects the semantics of the |
| 69 | 77 | * "getMessage" method (see below). |
| 74 | 82 | * This is the last token that has been consumed successfully. If |
| 75 | 83 | * this object has been created due to a parse error, the token |
| 76 | 84 | * followng this token will (therefore) be the first error token. |
| 81 | 89 | * Each entry in this array is an array of integers. Each array |
| 82 | 90 | * of integers represents a sequence of tokens (by their ordinal |
| 83 | 91 | * values) that is expected at this point of the parse. |
| 88 | 96 | * This is a reference to the "tokenImage" array of the generated |
| 89 | 97 | * parser within which the parse error occurred. This array is |
| 90 | 98 | * defined in the generated ...Constants interface. |
| 95 | 103 | * This method has the standard behavior when this object has been |
| 96 | 104 | * created using the standard constructors. Otherwise, it uses |
| 97 | 105 | * "currentToken" and "expectedTokenSequences" to generate a parse |
| 98 | 106 | * error message and returns it. If this object has been created |
| 99 | 107 | * due to a parse error, and you do not catch it (it gets thrown |
| 100 | 108 | * from the parser), then this method is called during the printing |
| 101 | 109 | * of the final stack trace, and hence the correct error message |
| 102 | 110 | * gets displayed. |
| 118 | 126 | ... |
| 122 | 130 | Encountered \" |
| 133 | 141 | \" at line |
| 133 | 141 | , column |
| 135 | 144 | Was expecting: |
| 137 | 146 | Was expecting one of: |
| 144 | 153 | * The end of line string for this machine. |
| 146 | 155 | line.separator |
| 149 | 158 | * Used to convert raw characters to their escaped version |
| 150 | 159 | * when these raw version cannot be used as part of an ASCII |
| 151 | 160 | * string literal. |
| 162 | 171 | \\b |
| 165 | 174 | \\t |
| 168 | 177 | \\n |
| 171 | 180 | \\f |
| 174 | 183 | \\r |
| 177 | 186 | \\\" |
| 180 | 189 | \\\' |
| 183 | 192 | \\\\ |
| 187 | 196 | 0000 |
| 188 | 197 | \\u |