|
| 1 | + |
| 2 | + /** This character denotes the end of file */ |
| 3 | + public static final int YYEOF = -1; |
| 4 | + |
| 5 | + /** initial size of the lookahead buffer */ |
| 6 | +--- private static final int ZZ_BUFFERSIZE = ...; |
| 7 | + |
| 8 | + /** lexical states */ |
| 9 | +--- lexical states, charmap |
| 10 | + |
| 11 | + /* error codes */ |
| 12 | + private static final int ZZ_UNKNOWN_ERROR = 0; |
| 13 | + private static final int ZZ_NO_MATCH = 1; |
| 14 | + private static final int ZZ_PUSHBACK_2BIG = 2; |
| 15 | + |
| 16 | + /* error messages for the codes above */ |
| 17 | + private static final String[] ZZ_ERROR_MSG = { |
| 18 | + "Unknown internal scanner error", |
| 19 | + "Error: could not match input", |
| 20 | + "Error: pushback value was too large" |
| 21 | + }; |
| 22 | + |
| 23 | +--- isFinal list |
| 24 | + /** the input device */ |
| 25 | + private java.io.Reader zzReader; |
| 26 | + |
| 27 | + /** the current state of the DFA */ |
| 28 | + private int zzState; |
| 29 | + |
| 30 | + /** the current lexical state */ |
| 31 | + private int zzLexicalState = YYINITIAL; |
| 32 | + |
| 33 | + /** this buffer contains the current text to be matched and is |
| 34 | + the source of the yytext() string */ |
| 35 | + private CharSequence zzBuffer = ""; |
| 36 | + |
| 37 | + /** the textposition at the last accepting state */ |
| 38 | + private int zzMarkedPos; |
| 39 | + |
| 40 | + /** the current text position in the buffer */ |
| 41 | + private int zzCurrentPos; |
| 42 | + |
| 43 | + /** startRead marks the beginning of the yytext() string in the buffer */ |
| 44 | + private int zzStartRead; |
| 45 | + |
| 46 | + /** endRead marks the last character in the buffer, that has been read |
| 47 | + from input */ |
| 48 | + private int zzEndRead; |
| 49 | + |
| 50 | + /** zzAtEOF == true <=> the scanner is at the EOF */ |
| 51 | + private boolean zzAtEOF; |
| 52 | + |
| 53 | +--- user class code |
| 54 | + |
| 55 | +--- constructor declaration |
| 56 | + |
| 57 | + public final int getTokenStart() { |
| 58 | + return zzStartRead; |
| 59 | + } |
| 60 | + |
| 61 | + public final int getTokenEnd() { |
| 62 | + return getTokenStart() + yylength(); |
| 63 | + } |
| 64 | + |
| 65 | + public void reset(CharSequence buffer, int start, int end, int initialState) { |
| 66 | + zzBuffer = buffer; |
| 67 | + zzCurrentPos = zzMarkedPos = zzStartRead = start; |
| 68 | + zzAtEOF = false; |
| 69 | + zzAtBOL = true; |
| 70 | + zzEndRead = end; |
| 71 | + yybegin(initialState); |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * Refills the input buffer. |
| 76 | + * |
| 77 | + * @return {@code false}, iff there was new input. |
| 78 | + * |
| 79 | + * @exception java.io.IOException if any I/O-Error occurs |
| 80 | + */ |
| 81 | + private boolean zzRefill() throws java.io.IOException { |
| 82 | + return true; |
| 83 | + } |
| 84 | + |
| 85 | + |
| 86 | + /** |
| 87 | + * Returns the current lexical state. |
| 88 | + */ |
| 89 | + public final int yystate() { |
| 90 | + return zzLexicalState; |
| 91 | + } |
| 92 | + |
| 93 | + |
| 94 | + /** |
| 95 | + * Enters a new lexical state |
| 96 | + * |
| 97 | + * @param newState the new lexical state |
| 98 | + */ |
| 99 | + public final void yybegin(int newState) { |
| 100 | + zzLexicalState = newState; |
| 101 | + } |
| 102 | + |
| 103 | + |
| 104 | + /** |
| 105 | + * Returns the text matched by the current regular expression. |
| 106 | + */ |
| 107 | + public final CharSequence yytext() { |
| 108 | + return zzBuffer.subSequence(zzStartRead, zzMarkedPos); |
| 109 | + } |
| 110 | + |
| 111 | + |
| 112 | + /** |
| 113 | + * Returns the character at position {@code pos} from the |
| 114 | + * matched text. |
| 115 | + * |
| 116 | + * It is equivalent to yytext().charAt(pos), but faster |
| 117 | + * |
| 118 | + * @param pos the position of the character to fetch. |
| 119 | + * A value from 0 to yylength()-1. |
| 120 | + * |
| 121 | + * @return the character at position pos |
| 122 | + */ |
| 123 | + public final char yycharat(int pos) { |
| 124 | + return zzBuffer.charAt(zzStartRead+pos); |
| 125 | + } |
| 126 | + |
| 127 | + |
| 128 | + /** |
| 129 | + * Returns the length of the matched text region. |
| 130 | + */ |
| 131 | + public final int yylength() { |
| 132 | + return zzMarkedPos-zzStartRead; |
| 133 | + } |
| 134 | + |
| 135 | + |
| 136 | + /** |
| 137 | + * Reports an error that occurred while scanning. |
| 138 | + * |
| 139 | + * In a wellformed scanner (no or only correct usage of |
| 140 | + * yypushback(int) and a match-all fallback rule) this method |
| 141 | + * will only be called with things that "Can't Possibly Happen". |
| 142 | + * If this method is called, something is seriously wrong |
| 143 | + * (e.g. a JFlex bug producing a faulty scanner etc.). |
| 144 | + * |
| 145 | + * Usual syntax/scanner level error handling should be done |
| 146 | + * in error fallback rules. |
| 147 | + * |
| 148 | + * @param errorCode the code of the errormessage to display |
| 149 | + */ |
| 150 | +--- zzScanError declaration |
| 151 | + String message; |
| 152 | + try { |
| 153 | + message = ZZ_ERROR_MSG[errorCode]; |
| 154 | + } |
| 155 | + catch (ArrayIndexOutOfBoundsException e) { |
| 156 | + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; |
| 157 | + } |
| 158 | + |
| 159 | +--- throws clause |
| 160 | + } |
| 161 | + |
| 162 | + |
| 163 | + /** |
| 164 | + * Pushes the specified amount of characters back into the input stream. |
| 165 | + * |
| 166 | + * They will be read again by then next call of the scanning method |
| 167 | + * |
| 168 | + * @param number the number of characters to be read again. |
| 169 | + * This number must not be greater than yylength()! |
| 170 | + */ |
| 171 | +--- yypushback decl (contains zzScanError exception) |
| 172 | + if ( number > yylength() ) |
| 173 | + zzScanError(ZZ_PUSHBACK_2BIG); |
| 174 | + |
| 175 | + zzMarkedPos -= number; |
| 176 | + } |
| 177 | + |
| 178 | + |
| 179 | +--- zzDoEOF |
| 180 | + /** |
| 181 | + * Resumes scanning until the next regular expression is matched, |
| 182 | + * the end of input is encountered or an I/O-Error occurs. |
| 183 | + * |
| 184 | + * @return the next token |
| 185 | + * @exception java.io.IOException if any I/O-Error occurs |
| 186 | + */ |
| 187 | +--- yylex declaration |
| 188 | + int zzInput; |
| 189 | + int zzAction; |
| 190 | + |
| 191 | + // cached fields: |
| 192 | + int zzCurrentPosL; |
| 193 | + int zzMarkedPosL; |
| 194 | + int zzEndReadL = zzEndRead; |
| 195 | + CharSequence zzBufferL = zzBuffer; |
| 196 | + |
| 197 | +--- local declarations |
| 198 | + |
| 199 | + while (true) { |
| 200 | + zzMarkedPosL = zzMarkedPos; |
| 201 | + |
| 202 | +--- start admin (line, char, col count) |
| 203 | + zzAction = -1; |
| 204 | + |
| 205 | + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; |
| 206 | + |
| 207 | +--- start admin (lexstate etc) |
| 208 | + |
| 209 | + zzForAction: { |
| 210 | + while (true) { |
| 211 | + |
| 212 | +--- next input, line, col, char count, next transition, isFinal action |
| 213 | + zzAction = zzState; |
| 214 | + zzMarkedPosL = zzCurrentPosL; |
| 215 | +--- line count update |
| 216 | + } |
| 217 | + |
| 218 | + } |
| 219 | + } |
| 220 | + |
| 221 | + // store back cached position |
| 222 | + zzMarkedPos = zzMarkedPosL; |
| 223 | +--- char count update |
| 224 | + |
| 225 | + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { |
| 226 | + zzAtEOF = true; |
| 227 | +--- eofvalue |
| 228 | + } |
| 229 | + else { |
| 230 | +--- actions |
| 231 | + default: |
| 232 | +--- no match |
| 233 | + } |
| 234 | + } |
| 235 | + } |
| 236 | + } |
| 237 | + |
| 238 | +--- main |
| 239 | + |
| 240 | +} |
0 commit comments