001: /* The following code was generated by JFlex 1.3.5 on 13-9-06 0:53 */
002:
003: package vqwiki.lex;
004:
005: /*
006: Very Quick Wiki - WikiWikiWeb clone
007: Copyright (C) 2001 Gareth Cronin
008:
009: This program is free software; you can redistribute it and/or modify
010: it under the terms of the GNU General Public License as published by
011: the Free Software Foundation; either version 2 of the License, or
012: (at your option) any later version.
013:
014: This program is distributed in the hope that it will be useful,
015: but WITHOUT ANY WARRANTY; without even the implied warranty of
016: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
017: GNU General Public License for more details.
018:
019: You should have received a copy of the GNU General Public License
020: along with this program (gpl.txt); if not, write to the Free Software
021: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
022: */
023:
024: import vqwiki.*;
025:
026: /**
027: * This class is a scanner generated by
028: * <a href="http://www.jflex.de/">JFlex</a> 1.3.5
029: * on 13-9-06 0:53 from the specification file
030: * <tt>file:/C:/SourceForge/VQWiki_2X/vqwiki-classic/jlex/ToDoLexer</tt>
031: */
032: public class ToDoLexer {
033:
034: /** This character denotes the end of file */
035: final public static int YYEOF = -1;
036:
037: /** initial size of the lookahead buffer */
038: final private static int YY_BUFFERSIZE = 16384;
039:
040: /** lexical states */
041: final public static int YYINITIAL = 0;
042: final public static int NORMAL = 1;
043:
044: /**
045: * Translates characters to character classes
046: */
047: final private static String yycmap_packed = "\11\0\1\1\1\1\2\0\1\1\22\0\1\1\17\0\12\2\7\0"
048: + "\32\5\5\0\1\3\32\6\145\0\27\4\2\0\5\4\1\0\1\4"
049: + "\uff00\0";
050:
051: /**
052: * Translates characters to character classes
053: */
054: final private static char[] yycmap = yy_unpack_cmap(yycmap_packed);
055:
056: /**
057: * Translates a state to a row index in the transition table
058: */
059: final private static int yy_rowMap[] = { 0, 7, 0, 14, 21, 28, 35,
060: 42, 0, 49, 56 };
061:
062: /**
063: * The packed transition table of the DFA (part 0)
064: */
065: final private static String yy_packed0 = "\7\0\1\3\1\4\1\3\1\5\1\3\1\6\1\3"
066: + "\1\0\1\4\7\0\1\7\2\0\2\7\4\0\1\10"
067: + "\1\0\1\10\2\0\1\7\1\11\1\0\2\7\4\0"
068: + "\1\10\1\12\1\10\4\0\1\13\1\0\1\13\4\0"
069: + "\1\13\1\12\1\13";
070:
071: /**
072: * The transition table of the DFA
073: */
074: final private static int yytrans[] = yy_unpack();
075:
076: /* error codes */
077: final private static int YY_UNKNOWN_ERROR = 0;
078: final private static int YY_ILLEGAL_STATE = 1;
079: final private static int YY_NO_MATCH = 2;
080: final private static int YY_PUSHBACK_2BIG = 3;
081:
082: /* error messages for the codes above */
083: final private static String YY_ERROR_MSG[] = {
084: "Unkown internal scanner error",
085: "Internal error: unknown state",
086: "Error: could not match input",
087: "Error: pushback value was too large" };
088:
089: /**
090: * YY_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
091: */
092: private final static byte YY_ATTRIBUTE[] = { 8, 0, 9, 1, 1, 1, 0,
093: 0, 9, 0, 1 };
094:
095: /** the input device */
096: private java.io.Reader yy_reader;
097:
098: /** the current state of the DFA */
099: private int yy_state;
100:
101: /** the current lexical state */
102: private int yy_lexical_state = YYINITIAL;
103:
104: /** this buffer contains the current text to be matched and is
105: the source of the yytext() string */
106: private char yy_buffer[] = new char[YY_BUFFERSIZE];
107:
108: /** the textposition at the last accepting state */
109: private int yy_markedPos;
110:
111: /** the textposition at the last state to be included in yytext */
112: private int yy_pushbackPos;
113:
114: /** the current text position in the buffer */
115: private int yy_currentPos;
116:
117: /** startRead marks the beginning of the yytext() string in the buffer */
118: private int yy_startRead;
119:
120: /** endRead marks the last character in the buffer, that has been read
121: from input */
122: private int yy_endRead;
123:
124: /** number of newlines encountered up to the start of the matched text */
125: private int yyline;
126:
127: /** the number of characters up to the start of the matched text */
128: private int yychar;
129:
130: /**
131: * the number of characters from the last newline up to the start of the
132: * matched text
133: */
134: private int yycolumn;
135:
136: /**
137: * yy_atBOL == true <=> the scanner is currently at the beginning of a line
138: */
139: private boolean yy_atBOL = true;
140:
141: /** yy_atEOF == true <=> the scanner is at the EOF */
142: private boolean yy_atEOF;
143:
144: /* user code: */
145: protected String virtualWiki;
146:
147: protected boolean exists(String topic) {
148: try {
149: return WikiBase.getInstance().exists(virtualWiki, topic);
150: } catch (Exception err) {
151: err.printStackTrace();
152: }
153: return false;
154: }
155:
156: public void setVirtualWiki(String vWiki) {
157: this .virtualWiki = vWiki;
158: }
159:
160: /**
161: * Creates a new scanner
162: * There is also a java.io.InputStream version of this constructor.
163: *
164: * @param in the java.io.Reader to read input from.
165: */
166: public ToDoLexer(java.io.Reader in) {
167: yybegin(NORMAL);
168: this .yy_reader = in;
169: }
170:
171: /**
172: * Creates a new scanner.
173: * There is also java.io.Reader version of this constructor.
174: *
175: * @param in the java.io.Inputstream to read input from.
176: */
177: public ToDoLexer(java.io.InputStream in) {
178: this (new java.io.InputStreamReader(in));
179: }
180:
181: /**
182: * Unpacks the split, compressed DFA transition table.
183: *
184: * @return the unpacked transition table
185: */
186: private static int[] yy_unpack() {
187: int[] trans = new int[63];
188: int offset = 0;
189: offset = yy_unpack(yy_packed0, offset, trans);
190: return trans;
191: }
192:
193: /**
194: * Unpacks the compressed DFA transition table.
195: *
196: * @param packed the packed transition table
197: * @return the index of the last entry
198: */
199: private static int yy_unpack(String packed, int offset, int[] trans) {
200: int i = 0; /* index in packed string */
201: int j = offset; /* index in unpacked array */
202: int l = packed.length();
203: while (i < l) {
204: int count = packed.charAt(i++);
205: int value = packed.charAt(i++);
206: value--;
207: do
208: trans[j++] = value;
209: while (--count > 0);
210: }
211: return j;
212: }
213:
214: /**
215: * Unpacks the compressed character translation table.
216: *
217: * @param packed the packed character translation table
218: * @return the unpacked character translation table
219: */
220: private static char[] yy_unpack_cmap(String packed) {
221: char[] map = new char[0x10000];
222: int i = 0; /* index in packed string */
223: int j = 0; /* index in unpacked array */
224: while (i < 42) {
225: int count = packed.charAt(i++);
226: char value = packed.charAt(i++);
227: do
228: map[j++] = value;
229: while (--count > 0);
230: }
231: return map;
232: }
233:
234: /**
235: * Refills the input buffer.
236: *
237: * @return <code>false</code>, iff there was new input.
238: *
239: * @exception IOException if any I/O-Error occurs
240: */
241: private boolean yy_refill() throws java.io.IOException {
242:
243: /* first: make room (if you can) */
244: if (yy_startRead > 0) {
245: System.arraycopy(yy_buffer, yy_startRead, yy_buffer, 0,
246: yy_endRead - yy_startRead);
247:
248: /* translate stored positions */
249: yy_endRead -= yy_startRead;
250: yy_currentPos -= yy_startRead;
251: yy_markedPos -= yy_startRead;
252: yy_pushbackPos -= yy_startRead;
253: yy_startRead = 0;
254: }
255:
256: /* is the buffer big enough? */
257: if (yy_currentPos >= yy_buffer.length) {
258: /* if not: blow it up */
259: char newBuffer[] = new char[yy_currentPos * 2];
260: System.arraycopy(yy_buffer, 0, newBuffer, 0,
261: yy_buffer.length);
262: yy_buffer = newBuffer;
263: }
264:
265: /* finally: fill the buffer with new input */
266: int numRead = yy_reader.read(yy_buffer, yy_endRead,
267: yy_buffer.length - yy_endRead);
268:
269: if (numRead < 0) {
270: return true;
271: } else {
272: yy_endRead += numRead;
273: return false;
274: }
275: }
276:
277: /**
278: * Closes the input stream.
279: */
280: final public void yyclose() throws java.io.IOException {
281: yy_atEOF = true; /* indicate end of file */
282: yy_endRead = yy_startRead; /* invalidate buffer */
283:
284: if (yy_reader != null)
285: yy_reader.close();
286: }
287:
288: /**
289: * Closes the current stream, and resets the
290: * scanner to read from a new input stream.
291: *
292: * All internal variables are reset, the old input stream
293: * <b>cannot</b> be reused (internal buffer is discarded and lost).
294: * Lexical state is set to <tt>YY_INITIAL</tt>.
295: *
296: * @param reader the new input stream
297: */
298: final public void yyreset(java.io.Reader reader)
299: throws java.io.IOException {
300: yyclose();
301: yy_reader = reader;
302: yy_atBOL = true;
303: yy_atEOF = false;
304: yy_endRead = yy_startRead = 0;
305: yy_currentPos = yy_markedPos = yy_pushbackPos = 0;
306: yyline = yychar = yycolumn = 0;
307: yy_lexical_state = YYINITIAL;
308: }
309:
310: /**
311: * Returns the current lexical state.
312: */
313: final public int yystate() {
314: return yy_lexical_state;
315: }
316:
317: /**
318: * Enters a new lexical state
319: *
320: * @param newState the new lexical state
321: */
322: final public void yybegin(int newState) {
323: yy_lexical_state = newState;
324: }
325:
326: /**
327: * Returns the text matched by the current regular expression.
328: */
329: final public String yytext() {
330: return new String(yy_buffer, yy_startRead, yy_markedPos
331: - yy_startRead);
332: }
333:
334: /**
335: * Returns the character at position <tt>pos</tt> from the
336: * matched text.
337: *
338: * It is equivalent to yytext().charAt(pos), but faster
339: *
340: * @param pos the position of the character to fetch.
341: * A value from 0 to yylength()-1.
342: *
343: * @return the character at position pos
344: */
345: final public char yycharat(int pos) {
346: return yy_buffer[yy_startRead + pos];
347: }
348:
349: /**
350: * Returns the length of the matched text region.
351: */
352: final public int yylength() {
353: return yy_markedPos - yy_startRead;
354: }
355:
356: /**
357: * Reports an error that occured while scanning.
358: *
359: * In a wellformed scanner (no or only correct usage of
360: * yypushback(int) and a match-all fallback rule) this method
361: * will only be called with things that "Can't Possibly Happen".
362: * If this method is called, something is seriously wrong
363: * (e.g. a JFlex bug producing a faulty scanner etc.).
364: *
365: * Usual syntax/scanner level error handling should be done
366: * in error fallback rules.
367: *
368: * @param errorCode the code of the errormessage to display
369: */
370: private void yy_ScanError(int errorCode) {
371: String message;
372: try {
373: message = YY_ERROR_MSG[errorCode];
374: } catch (ArrayIndexOutOfBoundsException e) {
375: message = YY_ERROR_MSG[YY_UNKNOWN_ERROR];
376: }
377:
378: throw new Error(message);
379: }
380:
381: /**
382: * Pushes the specified amount of characters back into the input stream.
383: *
384: * They will be read again by then next call of the scanning method
385: *
386: * @param number the number of characters to be read again.
387: * This number must not be greater than yylength()!
388: */
389: private void yypushback(int number) {
390: if (number > yylength())
391: yy_ScanError(YY_PUSHBACK_2BIG);
392:
393: yy_markedPos -= number;
394: }
395:
396: /**
397: * Resumes scanning until the next regular expression is matched,
398: * the end of input is encountered or an I/O-Error occurs.
399: *
400: * @return the next token
401: * @exception IOException if any I/O-Error occurs
402: */
403: public String yylex() throws java.io.IOException {
404: int yy_input;
405: int yy_action;
406:
407: // cached fields:
408: int yy_currentPos_l;
409: int yy_startRead_l;
410: int yy_markedPos_l;
411: int yy_endRead_l = yy_endRead;
412: char[] yy_buffer_l = yy_buffer;
413: char[] yycmap_l = yycmap;
414:
415: int[] yytrans_l = yytrans;
416: int[] yy_rowMap_l = yy_rowMap;
417: byte[] yy_attr_l = YY_ATTRIBUTE;
418:
419: while (true) {
420: yy_markedPos_l = yy_markedPos;
421:
422: yy_action = -1;
423:
424: yy_startRead_l = yy_currentPos_l = yy_currentPos = yy_startRead = yy_markedPos_l;
425:
426: yy_state = yy_lexical_state;
427:
428: yy_forAction: {
429: while (true) {
430:
431: if (yy_currentPos_l < yy_endRead_l)
432: yy_input = yy_buffer_l[yy_currentPos_l++];
433: else if (yy_atEOF) {
434: yy_input = YYEOF;
435: break yy_forAction;
436: } else {
437: // store back cached positions
438: yy_currentPos = yy_currentPos_l;
439: yy_markedPos = yy_markedPos_l;
440: boolean eof = yy_refill();
441: // get translated positions and possibly new buffer
442: yy_currentPos_l = yy_currentPos;
443: yy_markedPos_l = yy_markedPos;
444: yy_buffer_l = yy_buffer;
445: yy_endRead_l = yy_endRead;
446: if (eof) {
447: yy_input = YYEOF;
448: break yy_forAction;
449: } else {
450: yy_input = yy_buffer_l[yy_currentPos_l++];
451: }
452: }
453: int yy_next = yytrans_l[yy_rowMap_l[yy_state]
454: + yycmap_l[yy_input]];
455: if (yy_next == -1)
456: break yy_forAction;
457: yy_state = yy_next;
458:
459: int yy_attributes = yy_attr_l[yy_state];
460: if ((yy_attributes & 1) == 1) {
461: yy_action = yy_state;
462: yy_markedPos_l = yy_currentPos_l;
463: if ((yy_attributes & 8) == 8)
464: break yy_forAction;
465: }
466:
467: }
468: }
469:
470: // store back cached position
471: yy_markedPos = yy_markedPos_l;
472:
473: switch (yy_action) {
474:
475: case 10: {
476: String link = yytext();
477: if (exists(link.trim())) {
478: return "";
479: } else {
480: return link;
481: }
482: }
483: case 12:
484: break;
485: case 8: {
486: if (!Environment.getInstance().isAllowBackTick()) {
487: return "";
488: }
489: String link = yytext();
490: link = link.substring(1);
491: link = link.substring(0, link.length() - 1);
492: if (exists(link)) {
493: return "";
494: } else {
495: return link;
496: }
497: }
498: case 13:
499: break;
500: case 3: {
501:
502: }
503: case 14:
504: break;
505: case 2:
506: case 4:
507: case 5: {
508:
509: }
510: case 15:
511: break;
512: default:
513: if (yy_input == YYEOF && yy_startRead == yy_currentPos) {
514: yy_atEOF = true;
515: {
516: return null;
517: }
518: } else {
519: yy_ScanError(YY_NO_MATCH);
520: }
521: }
522: }
523: }
524:
525: }
|