source: other-projects/rsyntax-textarea/src/java/org/fife/ui/rsyntaxtextarea/modes/MakefileTokenMaker.java@ 25584

Last change on this file since 25584 was 25584, checked in by davidb, 12 years ago

Initial cut an a text edit area for GLI that supports color syntax highlighting

File size: 27.6 KB
Line 
1/* The following code was generated by JFlex 1.4.1 on 1/20/09 10:04 AM */
2
3/*
4 * 09/20/2008
5 *
6 * MakefileTokenMaker.java - Scanner for makefiles.
7 *
8 * This library is distributed under a modified BSD license. See the included
9 * RSyntaxTextArea.License.txt file for details.
10 */
11package org.fife.ui.rsyntaxtextarea.modes;
12
13import java.io.*;
14import java.util.Stack;
15import javax.swing.text.Segment;
16
17import org.fife.ui.rsyntaxtextarea.*;
18
19
20/**
21 * Scanner for makefiles.<p>
22 *
23 * This implementation was created using
24 * <a href="http://www.jflex.de/">JFlex</a> 1.4.1; however, the generated file
25 * was modified for performance. Memory allocation needs to be almost
26 * completely removed to be competitive with the handwritten lexers (subclasses
27 * of <code>AbstractTokenMaker</code>, so this class has been modified so that
28 * Strings are never allocated (via yytext()), and the scanner never has to
29 * worry about refilling its buffer (needlessly copying chars around).
30 * We can achieve this because RText always scans exactly 1 line of tokens at a
31 * time, and hands the scanner this line as an array of characters (a Segment
32 * really). Since tokens contain pointers to char arrays instead of Strings
33 * holding their contents, there is no need for allocating new memory for
34 * Strings.<p>
35 *
36 * The actual algorithm generated for scanning has, of course, not been
37 * modified.<p>
38 *
39 * If you wish to regenerate this file yourself, keep in mind the following:
40 * <ul>
41 * <li>The generated MakefileTokenMaker.java</code> file will contain two
42 * definitions of both <code>zzRefill</code> and <code>yyreset</code>.
43 * You should hand-delete the second of each definition (the ones
44 * generated by the lexer), as these generated methods modify the input
45 * buffer, which we'll never have to do.</li>
46 * <li>You should also change the declaration/definition of zzBuffer to NOT
47 * be initialized. This is a needless memory allocation for us since we
48 * will be pointing the array somewhere else anyway.</li>
49 * <li>You should NOT call <code>yylex()</code> on the generated scanner
50 * directly; rather, you should use <code>getTokenList</code> as you would
51 * with any other <code>TokenMaker</code> instance.</li>
52 * </ul>
53 *
54 * @author Robert Futrell
55 * @version 0.5
56 *
57 */
58
59public class MakefileTokenMaker extends AbstractJFlexTokenMaker {
60
61 /** This character denotes the end of file */
62 public static final int YYEOF = -1;
63
64 /** lexical states */
65 public static final int VAR = 1;
66 public static final int YYINITIAL = 0;
67
68 /**
69 * Translates characters to character classes
70 */
71 private static final String ZZ_CMAP_PACKED =
72 "\11\0\1\10\1\7\1\0\1\10\23\0\1\10\1\0\1\13\1\15"+
73 "\1\4\2\0\1\11\1\6\1\47\1\0\1\16\1\0\1\37\1\1"+
74 "\1\0\12\2\1\3\2\0\1\17\1\0\1\16\1\0\32\1\1\0"+
75 "\1\12\2\0\1\1\1\14\1\20\1\32\1\43\1\21\1\24\1\25"+
76 "\1\41\1\44\1\26\1\45\1\1\1\35\1\34\1\33\1\40\1\22"+
77 "\1\46\1\23\1\30\1\36\1\31\1\1\1\42\1\27\2\1\1\5"+
78 "\1\0\1\50\uff82\0";
79
80 /**
81 * Translates characters to character classes
82 */
83 private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
84
85 /**
86 * Translates DFA states to action switch labels.
87 */
88 private static final int [] ZZ_ACTION = zzUnpackAction();
89
90 private static final String ZZ_ACTION_PACKED_0 =
91 "\2\0\2\1\1\2\2\1\1\3\1\4\1\5\1\6"+
92 "\1\1\1\7\1\10\14\1\2\11\1\12\1\13\1\14"+
93 "\1\15\1\16\1\17\1\20\1\5\1\6\1\21\2\0"+
94 "\1\22\23\1\1\23\1\24\1\20\1\21\1\22\2\1"+
95 "\1\25\43\1\1\25\14\1\1\25\5\1\1\0\2\1"+
96 "\1\0\1\1\1\0\1\25";
97
98 private static int [] zzUnpackAction() {
99 int [] result = new int[129];
100 int offset = 0;
101 offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
102 return result;
103 }
104
105 private static int zzUnpackAction(String packed, int offset, int [] result) {
106 int i = 0; /* index in packed string */
107 int j = offset; /* index in unpacked array */
108 int l = packed.length();
109 while (i < l) {
110 int count = packed.charAt(i++);
111 int value = packed.charAt(i++);
112 do result[j++] = value; while (--count > 0);
113 }
114 return j;
115 }
116
117
118 /**
119 * Translates a state to a row index in the transition table
120 */
121 private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
122
123 private static final String ZZ_ROWMAP_PACKED_0 =
124 "\0\0\0\51\0\122\0\173\0\244\0\315\0\366\0\122"+
125 "\0\u011f\0\u0148\0\u0171\0\u019a\0\u01c3\0\122\0\u01ec\0\u0215"+
126 "\0\u023e\0\u0267\0\u0290\0\u02b9\0\u02e2\0\u030b\0\u0334\0\u035d"+
127 "\0\u0386\0\u03af\0\u03d8\0\u0401\0\u042a\0\122\0\122\0\122"+
128 "\0\122\0\122\0\122\0\u0453\0\u047c\0\122\0\u019a\0\u04a5"+
129 "\0\122\0\u04ce\0\u04f7\0\u0520\0\u0549\0\u0572\0\u059b\0\u05c4"+
130 "\0\u05ed\0\u0616\0\u063f\0\u0668\0\u0691\0\u06ba\0\u06e3\0\u070c"+
131 "\0\u0735\0\u075e\0\u0787\0\u07b0\0\122\0\122\0\u0148\0\u0171"+
132 "\0\u019a\0\u07d9\0\u0802\0\173\0\u082b\0\u0854\0\u087d\0\u08a6"+
133 "\0\u08cf\0\u08f8\0\u0921\0\u094a\0\u0973\0\u099c\0\u09c5\0\u09ee"+
134 "\0\u0a17\0\u0a40\0\u0a69\0\u0a92\0\u0abb\0\u0ae4\0\u0b0d\0\u0b36"+
135 "\0\u0b5f\0\u0b88\0\u0bb1\0\u0bda\0\u0c03\0\u0c2c\0\u0c55\0\u0c7e"+
136 "\0\u0ca7\0\u0cd0\0\u0cf9\0\u0d22\0\u0d4b\0\u0d74\0\u0d9d\0\u0dc6"+
137 "\0\u0def\0\u0e18\0\u0e41\0\u0e6a\0\u0e93\0\u0ebc\0\u0ee5\0\u0f0e"+
138 "\0\u0f37\0\u0f60\0\u0f89\0\u0fb2\0\u0fdb\0\u1004\0\u102d\0\u1056"+
139 "\0\u107f\0\u10a8\0\u10d1\0\u10fa\0\u1123\0\u114c\0\u1175\0\u119e"+
140 "\0\122";
141
142 private static int [] zzUnpackRowMap() {
143 int [] result = new int[129];
144 int offset = 0;
145 offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
146 return result;
147 }
148
149 private static int zzUnpackRowMap(String packed, int offset, int [] result) {
150 int i = 0; /* index in packed string */
151 int j = offset; /* index in unpacked array */
152 int l = packed.length();
153 while (i < l) {
154 int high = packed.charAt(i++) << 16;
155 result[j++] = high | packed.charAt(i++);
156 }
157 return j;
158 }
159
160 /**
161 * The transition table of the DFA
162 */
163 private static final int [] ZZ_TRANS = zzUnpackTrans();
164
165 private static final String ZZ_TRANS_PACKED_0 =
166 "\1\3\1\4\1\5\1\6\1\7\2\3\1\10\1\11"+
167 "\1\12\1\3\1\13\1\14\1\15\1\6\1\16\1\17"+
168 "\1\20\1\21\1\4\1\22\1\23\1\24\1\4\1\25"+
169 "\1\4\1\26\1\27\3\4\1\3\1\30\1\4\1\31"+
170 "\2\4\1\32\1\4\2\3\4\33\1\34\10\33\1\35"+
171 "\31\33\1\36\1\37\52\0\2\4\1\40\14\0\17\4"+
172 "\1\0\7\4\4\0\1\5\65\0\1\16\36\0\1\41"+
173 "\1\42\52\0\1\11\40\0\7\12\1\0\1\12\1\43"+
174 "\1\44\36\12\7\13\1\0\2\13\1\45\1\46\35\13"+
175 "\7\47\1\0\2\47\1\50\1\47\1\51\34\47\7\15"+
176 "\1\0\41\15\1\0\2\4\1\40\14\0\1\4\1\52"+
177 "\15\4\1\0\7\4\3\0\2\4\1\40\14\0\4\4"+
178 "\1\53\1\4\1\54\10\4\1\0\7\4\3\0\2\4"+
179 "\1\40\14\0\1\55\16\4\1\0\7\4\3\0\2\4"+
180 "\1\40\14\0\13\4\1\56\1\4\1\57\1\4\1\0"+
181 "\7\4\3\0\2\4\1\40\14\0\6\4\1\60\10\4"+
182 "\1\0\1\61\6\4\3\0\2\4\1\40\14\0\5\4"+
183 "\1\62\11\4\1\0\7\4\3\0\2\4\1\40\14\0"+
184 "\11\4\1\63\4\4\1\64\1\0\1\65\3\4\1\66"+
185 "\2\4\3\0\2\4\1\40\14\0\1\67\16\4\1\0"+
186 "\7\4\3\0\2\4\1\40\14\0\17\4\1\0\1\70"+
187 "\6\4\3\0\2\4\1\40\14\0\3\4\1\71\13\4"+
188 "\1\0\7\4\3\0\2\4\1\40\14\0\6\4\1\72"+
189 "\10\4\1\0\1\73\6\4\3\0\2\4\1\40\14\0"+
190 "\17\4\1\0\1\74\6\4\2\0\4\33\1\0\10\33"+
191 "\1\0\31\33\7\0\1\75\1\76\42\0\7\35\1\0"+
192 "\41\35\7\12\1\0\1\12\1\77\1\44\36\12\7\13"+
193 "\1\0\2\13\1\45\1\100\35\13\7\47\1\0\2\47"+
194 "\1\50\1\47\1\101\34\47\1\0\2\4\1\40\14\0"+
195 "\1\4\1\102\15\4\1\0\7\4\3\0\2\4\1\40"+
196 "\14\0\5\4\1\103\11\4\1\0\7\4\3\0\2\4"+
197 "\1\40\14\0\3\4\1\104\13\4\1\0\7\4\3\0"+
198 "\2\4\1\40\14\0\16\4\1\105\1\0\7\4\3\0"+
199 "\2\4\1\40\14\0\1\4\1\106\15\4\1\0\7\4"+
200 "\3\0\2\4\1\40\14\0\10\4\1\107\6\4\1\0"+
201 "\7\4\3\0\2\4\1\40\14\0\3\4\1\110\7\4"+
202 "\1\111\1\4\1\112\1\4\1\0\7\4\3\0\2\4"+
203 "\1\40\14\0\3\4\1\113\13\4\1\0\7\4\3\0"+
204 "\2\4\1\40\14\0\1\4\1\114\2\4\1\115\6\4"+
205 "\1\116\3\4\1\0\7\4\3\0\2\4\1\40\14\0"+
206 "\5\4\1\117\11\4\1\0\7\4\3\0\2\4\1\40"+
207 "\14\0\3\4\1\120\13\4\1\0\7\4\3\0\2\4"+
208 "\1\40\14\0\3\4\1\121\13\4\1\0\7\4\3\0"+
209 "\2\4\1\40\14\0\4\4\1\122\12\4\1\0\7\4"+
210 "\3\0\2\4\1\40\14\0\10\4\1\123\6\4\1\0"+
211 "\7\4\3\0\2\4\1\40\14\0\16\4\1\124\1\0"+
212 "\7\4\3\0\2\4\1\40\14\0\6\4\1\125\10\4"+
213 "\1\0\7\4\3\0\2\4\1\40\14\0\15\4\1\126"+
214 "\1\4\1\0\7\4\3\0\2\4\1\40\14\0\3\4"+
215 "\1\127\13\4\1\0\7\4\3\0\2\4\1\40\14\0"+
216 "\6\4\1\130\10\4\1\0\7\4\3\0\2\4\1\40"+
217 "\14\0\2\4\1\131\5\4\1\132\6\4\1\0\7\4"+
218 "\3\0\2\4\1\40\14\0\6\4\1\133\10\4\1\0"+
219 "\7\4\3\0\2\4\1\40\14\0\17\4\1\0\4\4"+
220 "\1\134\2\4\3\0\2\4\1\40\14\0\4\4\1\135"+
221 "\1\4\1\135\10\4\1\0\7\4\3\0\2\4\1\40"+
222 "\14\0\4\4\1\104\12\4\1\0\7\4\3\0\2\4"+
223 "\1\40\14\0\10\4\1\136\6\4\1\0\7\4\3\0"+
224 "\2\4\1\40\14\0\1\4\1\137\15\4\1\0\7\4"+
225 "\3\0\2\4\1\40\14\0\16\4\1\140\1\0\7\4"+
226 "\3\0\2\4\1\40\14\0\4\4\1\141\12\4\1\0"+
227 "\7\4\3\0\2\4\1\40\14\0\4\4\1\135\12\4"+
228 "\1\0\7\4\3\0\2\4\1\40\14\0\17\4\1\0"+
229 "\6\4\1\104\3\0\2\4\1\40\14\0\1\4\1\114"+
230 "\2\4\1\115\12\4\1\0\7\4\3\0\2\4\1\40"+
231 "\14\0\5\4\1\142\11\4\1\0\7\4\3\0\2\4"+
232 "\1\40\14\0\6\4\1\143\10\4\1\0\7\4\3\0"+
233 "\2\4\1\40\14\0\16\4\1\104\1\0\7\4\3\0"+
234 "\2\4\1\40\14\0\15\4\1\144\1\4\1\0\7\4"+
235 "\3\0\2\4\1\40\14\0\4\4\1\145\12\4\1\0"+
236 "\7\4\3\0\2\4\1\40\14\0\1\4\1\146\15\4"+
237 "\1\0\7\4\3\0\2\4\1\40\14\0\17\4\1\0"+
238 "\1\4\1\74\5\4\3\0\2\4\1\40\14\0\1\4"+
239 "\1\147\15\4\1\0\7\4\3\0\2\4\1\40\14\0"+
240 "\1\4\1\150\15\4\1\0\7\4\3\0\2\4\1\40"+
241 "\14\0\13\4\1\104\3\4\1\0\7\4\3\0\2\4"+
242 "\1\40\14\0\3\4\1\151\13\4\1\0\7\4\3\0"+
243 "\2\4\1\40\14\0\11\4\1\63\5\4\1\0\7\4"+
244 "\3\0\2\4\1\40\14\0\13\4\1\107\3\4\1\0"+
245 "\7\4\3\0\2\4\1\40\14\0\10\4\1\152\6\4"+
246 "\1\0\7\4\3\0\2\4\1\40\14\0\5\4\1\104"+
247 "\11\4\1\0\7\4\3\0\2\4\1\40\14\0\16\4"+
248 "\1\153\1\0\7\4\3\0\2\4\1\40\14\0\10\4"+
249 "\1\154\6\4\1\0\7\4\3\0\2\4\1\40\14\0"+
250 "\4\4\1\155\12\4\1\0\7\4\3\0\2\4\1\40"+
251 "\14\0\1\156\16\4\1\0\7\4\3\0\2\4\1\40"+
252 "\14\0\6\4\1\157\10\4\1\0\7\4\3\0\2\4"+
253 "\1\40\14\0\2\4\1\104\14\4\1\0\7\4\3\0"+
254 "\2\4\1\40\14\0\15\4\1\104\1\4\1\0\7\4"+
255 "\3\0\2\4\1\40\14\0\13\4\1\160\3\4\1\0"+
256 "\7\4\3\0\2\4\1\40\14\0\6\4\1\54\10\4"+
257 "\1\0\7\4\3\0\2\4\1\40\14\0\17\4\1\0"+
258 "\3\4\1\161\3\4\3\0\2\4\1\40\14\0\10\4"+
259 "\1\104\6\4\1\0\7\4\3\0\2\4\1\40\14\0"+
260 "\4\4\1\117\12\4\1\0\7\4\3\0\2\4\1\40"+
261 "\14\0\11\4\1\162\5\4\1\0\7\4\3\0\2\4"+
262 "\1\40\14\0\17\4\1\0\2\4\1\163\4\4\3\0"+
263 "\2\4\1\40\14\0\16\4\1\164\1\0\7\4\3\0"+
264 "\2\4\1\40\14\0\3\4\1\165\13\4\1\0\7\4"+
265 "\3\0\2\4\1\40\14\0\17\4\1\0\3\4\1\166"+
266 "\3\4\3\0\2\4\1\40\14\0\7\4\1\104\7\4"+
267 "\1\0\7\4\3\0\2\4\1\40\14\0\1\167\16\4"+
268 "\1\0\7\4\3\0\2\4\1\40\14\0\1\170\16\4"+
269 "\1\0\7\4\3\0\2\4\1\40\14\0\12\4\1\171"+
270 "\4\4\1\0\7\4\3\0\2\4\1\40\14\0\17\4"+
271 "\1\0\1\170\6\4\3\0\2\4\1\40\14\0\3\4"+
272 "\1\172\13\4\1\0\7\4\3\0\2\4\1\40\14\0"+
273 "\17\4\1\173\7\4\3\0\2\4\1\40\14\0\17\4"+
274 "\1\0\4\4\1\104\2\4\3\0\2\4\1\40\14\0"+
275 "\14\4\1\107\2\4\1\0\7\4\3\0\2\4\1\40"+
276 "\14\0\3\4\1\174\13\4\1\0\7\4\3\0\2\4"+
277 "\1\40\14\0\10\4\1\121\6\4\1\0\7\4\3\0"+
278 "\2\4\1\40\14\0\6\4\1\175\10\4\1\0\7\4"+
279 "\42\0\1\176\11\0\2\4\1\40\14\0\1\4\1\104"+
280 "\15\4\1\0\7\4\3\0\2\4\1\40\14\0\13\4"+
281 "\1\177\3\4\1\0\7\4\33\0\1\200\20\0\2\4"+
282 "\1\40\14\0\17\4\1\0\1\4\1\104\5\4\40\0"+
283 "\1\201\12\0";
284
285 private static int [] zzUnpackTrans() {
286 int [] result = new int[4551];
287 int offset = 0;
288 offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
289 return result;
290 }
291
292 private static int zzUnpackTrans(String packed, int offset, int [] result) {
293 int i = 0; /* index in packed string */
294 int j = offset; /* index in unpacked array */
295 int l = packed.length();
296 while (i < l) {
297 int count = packed.charAt(i++);
298 int value = packed.charAt(i++);
299 value--;
300 do result[j++] = value; while (--count > 0);
301 }
302 return j;
303 }
304
305
306 /* error codes */
307 private static final int ZZ_UNKNOWN_ERROR = 0;
308 private static final int ZZ_NO_MATCH = 1;
309 private static final int ZZ_PUSHBACK_2BIG = 2;
310
311 /* error messages for the codes above */
312 private static final String ZZ_ERROR_MSG[] = {
313 "Unkown internal scanner error",
314 "Error: could not match input",
315 "Error: pushback value was too large"
316 };
317
318 /**
319 * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
320 */
321 private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
322
323 private static final String ZZ_ATTRIBUTE_PACKED_0 =
324 "\2\0\1\11\4\1\1\11\5\1\1\11\17\1\6\11"+
325 "\2\1\1\11\2\0\1\11\23\1\2\11\74\1\1\0"+
326 "\2\1\1\0\1\1\1\0\1\11";
327
328 private static int [] zzUnpackAttribute() {
329 int [] result = new int[129];
330 int offset = 0;
331 offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
332 return result;
333 }
334
335 private static int zzUnpackAttribute(String packed, int offset, int [] result) {
336 int i = 0; /* index in packed string */
337 int j = offset; /* index in unpacked array */
338 int l = packed.length();
339 while (i < l) {
340 int count = packed.charAt(i++);
341 int value = packed.charAt(i++);
342 do result[j++] = value; while (--count > 0);
343 }
344 return j;
345 }
346
347 /** the input device */
348 private java.io.Reader zzReader;
349
350 /** the current state of the DFA */
351 private int zzState;
352
353 /** the current lexical state */
354 private int zzLexicalState = YYINITIAL;
355
356 /** this buffer contains the current text to be matched and is
357 the source of the yytext() string */
358 private char zzBuffer[];
359
360 /** the textposition at the last accepting state */
361 private int zzMarkedPos;
362
363 /** the current text position in the buffer */
364 private int zzCurrentPos;
365
366 /** startRead marks the beginning of the yytext() string in the buffer */
367 private int zzStartRead;
368
369 /** endRead marks the last character in the buffer, that has been read
370 from input */
371 private int zzEndRead;
372
373 /** zzAtEOF == true <=> the scanner is at the EOF */
374 private boolean zzAtEOF;
375
376 /* user code: */
377
378 private Stack varDepths;
379
380
381 /**
382 * Constructor. This must be here because JFlex does not generate a
383 * no-parameter constructor.
384 */
385 public MakefileTokenMaker() {
386 }
387
388
389 /**
390 * Adds the token specified to the current linked list of tokens.
391 *
392 * @param tokenType The token's type.
393 */
394 private void addToken(int tokenType) {
395 addToken(zzStartRead, zzMarkedPos-1, tokenType);
396 }
397
398
399 /**
400 * Adds the token specified to the current linked list of tokens.
401 *
402 * @param tokenType The token's type.
403 */
404 private void addToken(int start, int end, int tokenType) {
405 int so = start + offsetShift;
406 addToken(zzBuffer, start,end, tokenType, so);
407 }
408
409
410 /**
411 * Adds the token specified to the current linked list of tokens.
412 *
413 * @param array The character array.
414 * @param start The starting offset in the array.
415 * @param end The ending offset in the array.
416 * @param tokenType The token's type.
417 * @param startOffset The offset in the document at which this token
418 * occurs.
419 */
420 public void addToken(char[] array, int start, int end, int tokenType, int startOffset) {
421 super.addToken(array, start,end, tokenType, startOffset);
422 zzStartRead = zzMarkedPos;
423 }
424
425
426 /**
427 * Returns the text to place at the beginning and end of a
428 * line to "comment" it in a this programming language.
429 *
430 * @return The start and end strings to add to a line to "comment"
431 * it out.
432 */
433 public String[] getLineCommentStartAndEnd() {
434 return new String[] { "#", null };
435 }
436
437
438 /**
439 * Returns whether tokens of the specified type should have "mark
440 * occurrences" enabled for the current programming language.
441 *
442 * @param type The token type.
443 * @return Whether tokens of this type should have "mark occurrences"
444 * enabled.
445 */
446 public boolean getMarkOccurrencesOfTokenType(int type) {
447 return type==Token.IDENTIFIER || type==Token.VARIABLE;
448 }
449
450
451 /**
452 * Returns the first token in the linked list of tokens generated
453 * from <code>text</code>. This method must be implemented by
454 * subclasses so they can correctly implement syntax highlighting.
455 *
456 * @param text The text from which to get tokens.
457 * @param initialTokenType The token type we should start with.
458 * @param startOffset The offset into the document at which
459 * <code>text</code> starts.
460 * @return The first <code>Token</code> in a linked list representing
461 * the syntax highlighted text.
462 */
463 public Token getTokenList(Segment text, int initialTokenType, int startOffset) {
464
465 resetTokenList();
466 this.offsetShift = -text.offset + startOffset;
467
468 s = text;
469 try {
470 yyreset(zzReader);
471 yybegin(Token.NULL);
472 return yylex();
473 } catch (IOException ioe) {
474 ioe.printStackTrace();
475 return new DefaultToken();
476 }
477
478 }
479
480
481 /**
482 * Refills the input buffer.
483 *
484 * @return <code>true</code> if EOF was reached, otherwise
485 * <code>false</code>.
486 * @exception IOException if any I/O-Error occurs.
487 */
488 private boolean zzRefill() throws java.io.IOException {
489 return zzCurrentPos>=s.offset+s.count;
490 }
491
492
493 /**
494 * Resets the scanner to read from a new input stream.
495 * Does not close the old reader.
496 *
497 * All internal variables are reset, the old input stream
498 * <b>cannot</b> be reused (internal buffer is discarded and lost).
499 * Lexical state is set to <tt>YY_INITIAL</tt>.
500 *
501 * @param reader the new input stream
502 */
503 public final void yyreset(java.io.Reader reader) throws java.io.IOException {
504 // 's' has been updated.
505 zzBuffer = s.array;
506 /*
507 * We replaced the line below with the two below it because zzRefill
508 * no longer "refills" the buffer (since the way we do it, it's always
509 * "full" the first time through, since it points to the segment's
510 * array). So, we assign zzEndRead here.
511 */
512 //zzStartRead = zzEndRead = s.offset;
513 zzStartRead = s.offset;
514 zzEndRead = zzStartRead + s.count - 1;
515 zzCurrentPos = zzMarkedPos = s.offset;
516 zzLexicalState = YYINITIAL;
517 zzReader = reader;
518 zzAtEOF = false;
519 }
520
521
522
523
524 /**
525 * Creates a new scanner
526 * There is also a java.io.InputStream version of this constructor.
527 *
528 * @param in the java.io.Reader to read input from.
529 */
530 public MakefileTokenMaker(java.io.Reader in) {
531 this.zzReader = in;
532 }
533
534 /**
535 * Creates a new scanner.
536 * There is also java.io.Reader version of this constructor.
537 *
538 * @param in the java.io.Inputstream to read input from.
539 */
540 public MakefileTokenMaker(java.io.InputStream in) {
541 this(new java.io.InputStreamReader(in));
542 }
543
544 /**
545 * Unpacks the compressed character translation table.
546 *
547 * @param packed the packed character translation table
548 * @return the unpacked character translation table
549 */
550 private static char [] zzUnpackCMap(String packed) {
551 char [] map = new char[0x10000];
552 int i = 0; /* index in packed string */
553 int j = 0; /* index in unpacked array */
554 while (i < 126) {
555 int count = packed.charAt(i++);
556 char value = packed.charAt(i++);
557 do map[j++] = value; while (--count > 0);
558 }
559 return map;
560 }
561
562
563 /**
564 * Closes the input stream.
565 */
566 public final void yyclose() throws java.io.IOException {
567 zzAtEOF = true; /* indicate end of file */
568 zzEndRead = zzStartRead; /* invalidate buffer */
569
570 if (zzReader != null)
571 zzReader.close();
572 }
573
574
575 /**
576 * Returns the current lexical state.
577 */
578 public final int yystate() {
579 return zzLexicalState;
580 }
581
582
583 /**
584 * Enters a new lexical state
585 *
586 * @param newState the new lexical state
587 */
588 public final void yybegin(int newState) {
589 zzLexicalState = newState;
590 }
591
592
593 /**
594 * Returns the text matched by the current regular expression.
595 */
596 public final String yytext() {
597 return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
598 }
599
600
601 /**
602 * Returns the character at position <tt>pos</tt> from the
603 * matched text.
604 *
605 * It is equivalent to yytext().charAt(pos), but faster
606 *
607 * @param pos the position of the character to fetch.
608 * A value from 0 to yylength()-1.
609 *
610 * @return the character at position pos
611 */
612 public final char yycharat(int pos) {
613 return zzBuffer[zzStartRead+pos];
614 }
615
616
617 /**
618 * Returns the length of the matched text region.
619 */
620 public final int yylength() {
621 return zzMarkedPos-zzStartRead;
622 }
623
624
625 /**
626 * Reports an error that occured while scanning.
627 *
628 * In a wellformed scanner (no or only correct usage of
629 * yypushback(int) and a match-all fallback rule) this method
630 * will only be called with things that "Can't Possibly Happen".
631 * If this method is called, something is seriously wrong
632 * (e.g. a JFlex bug producing a faulty scanner etc.).
633 *
634 * Usual syntax/scanner level error handling should be done
635 * in error fallback rules.
636 *
637 * @param errorCode the code of the errormessage to display
638 */
639 private void zzScanError(int errorCode) {
640 String message;
641 try {
642 message = ZZ_ERROR_MSG[errorCode];
643 }
644 catch (ArrayIndexOutOfBoundsException e) {
645 message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
646 }
647
648 throw new Error(message);
649 }
650
651
652 /**
653 * Pushes the specified amount of characters back into the input stream.
654 *
655 * They will be read again by then next call of the scanning method
656 *
657 * @param number the number of characters to be read again.
658 * This number must not be greater than yylength()!
659 */
660 public void yypushback(int number) {
661 if ( number > yylength() )
662 zzScanError(ZZ_PUSHBACK_2BIG);
663
664 zzMarkedPos -= number;
665 }
666
667
668 /**
669 * Resumes scanning until the next regular expression is matched,
670 * the end of input is encountered or an I/O-Error occurs.
671 *
672 * @return the next token
673 * @exception java.io.IOException if any I/O-Error occurs
674 */
675 public org.fife.ui.rsyntaxtextarea.Token yylex() throws java.io.IOException {
676 int zzInput;
677 int zzAction;
678
679 // cached fields:
680 int zzCurrentPosL;
681 int zzMarkedPosL;
682 int zzEndReadL = zzEndRead;
683 char [] zzBufferL = zzBuffer;
684 char [] zzCMapL = ZZ_CMAP;
685
686 int [] zzTransL = ZZ_TRANS;
687 int [] zzRowMapL = ZZ_ROWMAP;
688 int [] zzAttrL = ZZ_ATTRIBUTE;
689
690 while (true) {
691 zzMarkedPosL = zzMarkedPos;
692
693 zzAction = -1;
694
695 zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
696
697 zzState = zzLexicalState;
698
699
700 zzForAction: {
701 while (true) {
702
703 if (zzCurrentPosL < zzEndReadL)
704 zzInput = zzBufferL[zzCurrentPosL++];
705 else if (zzAtEOF) {
706 zzInput = YYEOF;
707 break zzForAction;
708 }
709 else {
710 // store back cached positions
711 zzCurrentPos = zzCurrentPosL;
712 zzMarkedPos = zzMarkedPosL;
713 boolean eof = zzRefill();
714 // get translated positions and possibly new buffer
715 zzCurrentPosL = zzCurrentPos;
716 zzMarkedPosL = zzMarkedPos;
717 zzBufferL = zzBuffer;
718 zzEndReadL = zzEndRead;
719 if (eof) {
720 zzInput = YYEOF;
721 break zzForAction;
722 }
723 else {
724 zzInput = zzBufferL[zzCurrentPosL++];
725 }
726 }
727 int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
728 if (zzNext == -1) break zzForAction;
729 zzState = zzNext;
730
731 int zzAttributes = zzAttrL[zzState];
732 if ( (zzAttributes & 1) == 1 ) {
733 zzAction = zzState;
734 zzMarkedPosL = zzCurrentPosL;
735 if ( (zzAttributes & 8) == 8 ) break zzForAction;
736 }
737
738 }
739 }
740
741 // store back cached position
742 zzMarkedPos = zzMarkedPosL;
743
744 switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
745 case 13:
746 { addToken(Token.PREPROCESSOR);
747 }
748 case 22: break;
749 case 3:
750 { addNullToken(); return firstToken;
751 }
752 case 23: break;
753 case 16:
754 { addToken(Token.LITERAL_CHAR);
755 }
756 case 24: break;
757 case 15:
758 { if (varDepths==null) { varDepths = new Stack(); } else { varDepths.clear(); } varDepths.push(Boolean.FALSE); start = zzMarkedPos-2; yybegin(VAR);
759 }
760 case 25: break;
761 case 12:
762 { if (!varDepths.empty() && varDepths.peek()==Boolean.TRUE) {
763 varDepths.pop();
764 if (varDepths.empty()) {
765 addToken(start,zzStartRead, Token.VARIABLE); yybegin(YYINITIAL);
766 }
767 }
768 }
769 case 26: break;
770 case 11:
771 { if (!varDepths.empty() && varDepths.peek()==Boolean.FALSE) {
772 varDepths.pop();
773 if (varDepths.empty()) {
774 addToken(start,zzStartRead, Token.VARIABLE); yybegin(YYINITIAL);
775 }
776 }
777 }
778 case 27: break;
779 case 4:
780 { addToken(Token.WHITESPACE);
781 }
782 case 28: break;
783 case 21:
784 { addToken(Token.RESERVED_WORD);
785 }
786 case 29: break;
787 case 20:
788 { varDepths.push(Boolean.FALSE);
789 }
790 case 30: break;
791 case 18:
792 { addToken(Token.LITERAL_BACKQUOTE);
793 }
794 case 31: break;
795 case 19:
796 { varDepths.push(Boolean.TRUE);
797 }
798 case 32: break;
799 case 1:
800 { addToken(Token.IDENTIFIER);
801 }
802 case 33: break;
803 case 5:
804 { addToken(Token.ERROR_CHAR); addNullToken(); return firstToken;
805 }
806 case 34: break;
807 case 6:
808 { addToken(Token.ERROR_STRING_DOUBLE); addNullToken(); return firstToken;
809 }
810 case 35: break;
811 case 10:
812 { int temp1 = zzStartRead; int temp2 = zzMarkedPos; addToken(start,zzStartRead-1, Token.VARIABLE); addToken(temp1, temp2-1, Token.COMMENT_EOL); addNullToken(); return firstToken;
813 }
814 case 36: break;
815 case 17:
816 { addToken(Token.LITERAL_STRING_DOUBLE_QUOTE);
817 }
818 case 37: break;
819 case 14:
820 { if (varDepths==null) { varDepths = new Stack(); } else { varDepths.clear(); } varDepths.push(Boolean.TRUE); start = zzMarkedPos-2; yybegin(VAR);
821 }
822 case 38: break;
823 case 7:
824 { addToken(Token.COMMENT_EOL); addNullToken(); return firstToken;
825 }
826 case 39: break;
827 case 2:
828 { addToken(Token.LITERAL_NUMBER_DECIMAL_INT);
829 }
830 case 40: break;
831 case 8:
832 { addToken(Token.OPERATOR);
833 }
834 case 41: break;
835 case 9:
836 {
837 }
838 case 42: break;
839 default:
840 if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
841 zzAtEOF = true;
842 switch (zzLexicalState) {
843 case VAR: {
844 addToken(start,zzStartRead-1, Token.VARIABLE); addNullToken(); return firstToken;
845 }
846 case 130: break;
847 case YYINITIAL: {
848 addNullToken(); return firstToken;
849 }
850 case 131: break;
851 default:
852 return null;
853 }
854 }
855 else {
856 zzScanError(ZZ_NO_MATCH);
857 }
858 }
859 }
860 }
861
862
863}
Note: See TracBrowser for help on using the repository browser.