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