1 /** initial size of the lookahead buffer */
2 --- private static final int ZZ_BUFFERSIZE = ...;
5 --- lexical states, charmap
8 private static final int ZZ_UNKNOWN_ERROR = 0;
9 private static final int ZZ_NO_MATCH = 1;
10 private static final int ZZ_PUSHBACK_2BIG = 2;
11 private static final char[] EMPTY_BUFFER = new char[0];
12 private static final int YYEOF = -1;
13 private static java.io.Reader zzReader = null; // Fake
15 /* error messages for the codes above */
16 private static final String ZZ_ERROR_MSG[] = {
17 "Unkown internal scanner error",
18 "Error: could not match input",
19 "Error: pushback value was too large"
23 /** the current state of the DFA */
26 /** the current lexical state */
27 private int zzLexicalState = YYINITIAL;
29 /** this buffer contains the current text to be matched and is
30 the source of the yytext() string */
31 private CharSequence zzBuffer = "";
33 /** this buffer may contains the current text array to be matched when it is cheap to acquire it */
34 private char[] zzBufferArray;
36 /** the textposition at the last accepting state */
37 private int zzMarkedPos;
39 /** the textposition at the last state to be included in yytext */
40 private int zzPushbackPos;
42 /** the current text position in the buffer */
43 private int zzCurrentPos;
45 /** startRead marks the beginning of the yytext() string in the buffer */
46 private int zzStartRead;
48 /** endRead marks the last character in the buffer, that has been read
50 private int zzEndRead;
53 * zzAtBOL == true <=> the scanner is currently at the beginning of a line
55 private boolean zzAtBOL = true;
57 /** zzAtEOF == true <=> the scanner is at the EOF */
58 private boolean zzAtEOF;
62 --- constructor declaration
64 public final int getTokenStart(){
68 public final int getTokenEnd(){
69 return getTokenStart() + yylength();
72 public void reset(CharSequence buffer, int start, int end,int initialState){
74 zzBufferArray = com.intellij.util.text.CharArrayUtil.fromSequenceWithoutCopying(buffer);
75 zzCurrentPos = zzMarkedPos = zzStartRead = start;
80 yybegin(initialState);
83 // For Demetra compatibility
84 public void reset(CharSequence buffer, int initialState){
87 zzCurrentPos = zzMarkedPos = zzStartRead = 0;
91 zzEndRead = buffer.length();
92 yybegin(initialState);
96 * Refills the input buffer.
98 * @return <code>false</code>, iff there was new input.
100 * @exception java.io.IOException if any I/O-Error occurs
102 private boolean zzRefill() throws java.io.IOException {
108 * Returns the current lexical state.
110 public final int yystate() {
111 return zzLexicalState;
116 * Enters a new lexical state
118 * @param newState the new lexical state
120 public final void yybegin(int newState) {
121 zzLexicalState = newState;
126 * Returns the text matched by the current regular expression.
128 public final CharSequence yytext() {
129 return zzBuffer.subSequence(zzStartRead, zzMarkedPos);
134 * Returns the character at position <tt>pos</tt> from the
137 * It is equivalent to yytext().charAt(pos), but faster
139 * @param pos the position of the character to fetch.
140 * A value from 0 to yylength()-1.
142 * @return the character at position pos
144 public final char yycharat(int pos) {
145 return zzBufferArray != null ? zzBufferArray[zzStartRead+pos]:zzBuffer.charAt(zzStartRead+pos);
150 * Returns the length of the matched text region.
152 public final int yylength() {
153 return zzMarkedPos-zzStartRead;
158 * Reports an error that occured while scanning.
160 * In a wellformed scanner (no or only correct usage of
161 * yypushback(int) and a match-all fallback rule) this method
162 * will only be called with things that "Can't Possibly Happen".
163 * If this method is called, something is seriously wrong
164 * (e.g. a JFlex bug producing a faulty scanner etc.).
166 * Usual syntax/scanner level error handling should be done
167 * in error fallback rules.
169 * @param errorCode the code of the errormessage to display
171 --- zzScanError declaration
174 message = ZZ_ERROR_MSG[errorCode];
176 catch (ArrayIndexOutOfBoundsException e) {
177 message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
185 * Pushes the specified amount of characters back into the input stream.
187 * They will be read again by then next call of the scanning method
189 * @param number the number of characters to be read again.
190 * This number must not be greater than yylength()!
192 --- yypushback decl (contains zzScanError exception)
193 if ( number > yylength() )
194 zzScanError(ZZ_PUSHBACK_2BIG);
196 zzMarkedPos -= number;
202 * Resumes scanning until the next regular expression is matched,
203 * the end of input is encountered or an I/O-Error occurs.
205 * @return the next token
206 * @exception java.io.IOException if any I/O-Error occurs
208 --- yylex declaration
215 int zzEndReadL = zzEndRead;
216 CharSequence zzBufferL = zzBuffer;
217 char[] zzBufferArrayL = zzBufferArray;
218 char [] zzCMapL = ZZ_CMAP;
220 --- local declarations
223 zzMarkedPosL = zzMarkedPos;
225 --- start admin (line, char, col count)
228 zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
230 --- start admin (lexstate etc)
235 --- next input, line, col, char count, next transition, isFinal action
237 zzMarkedPosL = zzCurrentPosL;
238 --- line count update
244 // store back cached position
245 zzMarkedPos = zzMarkedPosL;
246 --- char count update
250 if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {