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-2003 Gareth Cronin
008:
009: This program is free software; you can redistribute it and/or modify
010: it under the terms of the GNU Lesser 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 Lesser 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 java.io.*;
025: import org.apache.log4j.Logger;
026: import vqwiki.lex.Lexer;
027: import vqwiki.Environment;
028: import vqwiki.WikiBase;
029:
030: /**
031: * This class is a scanner generated by
032: * <a href="http://www.jflex.de/">JFlex</a> 1.3.5
033: * on 13-9-06 0:53 from the specification file
034: * <tt>file:/C:/SourceForge/VQWiki_2X/vqwiki-classic/jflex/layout.jflex</tt>
035: */
036: public class LayoutLex implements vqwiki.lex.Lexer {
037:
038: /** This character denotes the end of file */
039: final public static int YYEOF = -1;
040:
041: /** initial size of the lookahead buffer */
042: final private static int YY_BUFFERSIZE = 16384;
043:
044: /** lexical states */
045: final public static int LIST = 8;
046: final public static int YYINITIAL = 0;
047: final public static int EXTERNAL = 12;
048: final public static int PRE = 6;
049: final public static int TABLE = 10;
050: final public static int OFF = 4;
051: final public static int NORMAL = 2;
052:
053: /**
054: * YY_LEXSTATE[l] is the state in the DFA for the lexical state l
055: * YY_LEXSTATE[l+1] is the state in the DFA for the lexical state l
056: * at the beginning of a line
057: * l is of the form l = 2*k, k a non negative integer
058: */
059: private final static int YY_LEXSTATE[] = { 0, 0, 1, 2, 3, 3, 4, 4,
060: 5, 6, 7, 7, 8, 8 };
061:
062: /**
063: * Translates characters to character classes
064: */
065: final private static String yycmap_packed = "\11\0\1\7\1\1\2\0\1\2\22\0\1\3\2\0\1\6\6\0"
066: + "\1\10\2\0\1\4\1\0\1\16\14\0\1\12\1\0\1\14\1\0"
067: + "\1\20\32\13\1\11\1\17\1\15\1\0\1\5\1\0\32\13\57\0"
068: + "\1\13\12\0\1\13\4\0\1\13\5\0\27\13\1\0\37\13\1\0"
069: + "\u0128\13\2\0\22\13\34\0\136\13\2\0\11\13\2\0\7\13\16\0"
070: + "\2\13\16\0\5\13\11\0\1\13\213\0\1\13\13\0\1\13\1\0"
071: + "\3\13\1\0\1\13\1\0\24\13\1\0\54\13\1\0\10\13\2\0"
072: + "\32\13\14\0\202\13\12\0\71\13\2\0\2\13\2\0\2\13\3\0"
073: + "\46\13\2\0\2\13\67\0\46\13\2\0\1\13\7\0\47\13\110\0"
074: + "\33\13\5\0\3\13\56\0\32\13\5\0\13\13\46\0\143\13\1\0"
075: + "\1\13\17\0\2\13\23\0\3\13\23\0\1\13\1\0\33\13\123\0"
076: + "\46\13\u015f\0\65\13\3\0\1\13\22\0\1\13\7\0\12\13\43\0"
077: + "\10\13\2\0\2\13\2\0\26\13\1\0\7\13\1\0\1\13\3\0"
078: + "\4\13\42\0\2\13\1\0\3\13\16\0\2\13\23\0\6\13\4\0"
079: + "\2\13\2\0\26\13\1\0\7\13\1\0\2\13\1\0\2\13\1\0"
080: + "\2\13\37\0\4\13\1\0\1\13\23\0\3\13\20\0\7\13\1\0"
081: + "\1\13\1\0\3\13\1\0\26\13\1\0\7\13\1\0\2\13\1\0"
082: + "\5\13\3\0\1\13\22\0\1\13\17\0\1\13\44\0\10\13\2\0"
083: + "\2\13\2\0\26\13\1\0\7\13\1\0\2\13\2\0\4\13\3\0"
084: + "\1\13\36\0\2\13\1\0\3\13\43\0\6\13\3\0\3\13\1\0"
085: + "\4\13\3\0\2\13\1\0\1\13\1\0\2\13\3\0\2\13\3\0"
086: + "\3\13\3\0\10\13\1\0\3\13\113\0\10\13\1\0\3\13\1\0"
087: + "\27\13\1\0\12\13\1\0\5\13\46\0\2\13\43\0\10\13\1\0"
088: + "\3\13\1\0\27\13\1\0\12\13\1\0\5\13\44\0\1\13\1\0"
089: + "\2\13\43\0\10\13\1\0\3\13\1\0\27\13\1\0\20\13\46\0"
090: + "\2\13\43\0\22\13\3\0\30\13\1\0\11\13\1\0\1\13\2\0"
091: + "\7\13\72\0\60\13\1\0\2\13\14\0\7\13\72\0\2\13\1\0"
092: + "\1\13\2\0\2\13\1\0\1\13\2\0\1\13\6\0\4\13\1\0"
093: + "\7\13\1\0\3\13\1\0\1\13\1\0\1\13\2\0\2\13\1\0"
094: + "\4\13\1\0\2\13\11\0\1\13\2\0\5\13\1\0\1\13\25\0"
095: + "\2\13\42\0\1\13\77\0\10\13\1\0\42\13\35\0\4\13\164\0"
096: + "\42\13\1\0\5\13\1\0\2\13\45\0\6\13\112\0\46\13\12\0"
097: + "\47\13\11\0\132\13\5\0\104\13\5\0\122\13\6\0\7\13\1\0"
098: + "\77\13\1\0\1\13\1\0\4\13\2\0\7\13\1\0\1\13\1\0"
099: + "\4\13\2\0\47\13\1\0\1\13\1\0\4\13\2\0\37\13\1\0"
100: + "\1\13\1\0\4\13\2\0\7\13\1\0\1\13\1\0\4\13\2\0"
101: + "\7\13\1\0\7\13\1\0\27\13\1\0\37\13\1\0\1\13\1\0"
102: + "\4\13\2\0\7\13\1\0\47\13\1\0\23\13\105\0\125\13\14\0"
103: + "\u026c\13\2\0\10\13\12\0\32\13\5\0\113\13\225\0\64\13\154\0"
104: + "\130\13\10\0\51\13\u0557\0\234\13\4\0\132\13\6\0\26\13\2\0"
105: + "\6\13\2\0\46\13\2\0\6\13\2\0\10\13\1\0\1\13\1\0"
106: + "\1\13\1\0\1\13\1\0\37\13\2\0\65\13\1\0\7\13\1\0"
107: + "\1\13\3\0\3\13\1\0\7\13\3\0\4\13\2\0\6\13\4\0"
108: + "\15\13\5\0\3\13\1\0\7\13\202\0\1\13\202\0\1\13\4\0"
109: + "\1\13\2\0\12\13\1\0\1\13\3\0\5\13\6\0\1\13\1\0"
110: + "\1\13\1\0\1\13\1\0\4\13\1\0\3\13\1\0\7\13\u0ecb\0"
111: + "\2\13\52\0\5\13\13\0\124\13\10\0\2\13\2\0\132\13\1\0"
112: + "\3\13\6\0\50\13\4\0\136\13\21\0\30\13\u0248\0\u19b6\13\112\0"
113: + "\u51a6\13\132\0\u048d\13\u0773\0\u2ba4\13\u215c\0\u012e\13\322\0\7\13\14\0"
114: + "\5\13\5\0\1\13\1\0\12\13\1\0\15\13\1\0\5\13\1\0"
115: + "\1\13\1\0\2\13\1\0\2\13\1\0\154\13\41\0\u016b\13\22\0"
116: + "\100\13\2\0\66\13\50\0\14\13\164\0\3\13\1\0\1\13\1\0"
117: + "\207\13\44\0\32\13\6\0\32\13\13\0\131\13\3\0\6\13\2\0"
118: + "\6\13\2\0\6\13\2\0\3\13\43\0";
119:
120: /**
121: * Translates characters to character classes
122: */
123: final private static char[] yycmap = yy_unpack_cmap(yycmap_packed);
124:
125: /**
126: * Translates a state to a row index in the transition table
127: */
128: final private static int yy_rowMap[] = { 0, 17, 34, 51, 68, 85,
129: 102, 119, 136, 0, 153, 170, 0, 187, 204, 221, 238, 255,
130: 272, 289, 306, 323, 340, 0, 357, 374, 391, 408, 0, 0, 425,
131: 442, 459, 476, 0, 493, 476, 510, 238, 527, 0, 544, 561,
132: 578, 595, 612, 340, 629, 0, 0, 646, 391, 663, 442, 680,
133: 476, 697, 714, 731, 748, 765, 782, 0, 799, 816, 833, 850,
134: 867, 884, 901, 918, 0, 935, 952, 0, 459, 969, 986, 1003, 0,
135: 1020, 0, 1037, 0, 0, 1054, 1071, 1088, 1105, 0, 1122, 1139,
136: 0, 1156 };
137:
138: /**
139: * The packed transition table of the DFA (part 0)
140: */
141: final private static String yy_packed0 = "\21\0\1\12\1\13\1\14\1\15\1\16\1\17\1\20"
142: + "\1\21\1\12\1\22\5\12\1\23\1\24\1\12\1\25"
143: + "\1\26\1\27\1\16\1\17\1\20\1\21\1\12\1\22"
144: + "\5\12\1\23\1\24\1\12\1\30\1\31\1\15\1\12"
145: + "\1\32\1\12\1\15\12\12\1\33\1\34\1\35\1\12"
146: + "\1\17\1\12\1\35\1\12\1\22\5\12\1\23\2\12"
147: + "\1\36\1\37\1\15\3\12\1\40\12\12\1\36\1\37"
148: + "\1\41\3\12\1\40\11\12\1\42\1\43\1\44\1\45"
149: + "\2\42\1\12\1\45\11\42\1\12\3\35\3\12\1\35"
150: + "\1\12\1\46\7\12\7\0\1\47\12\0\1\13\23\0"
151: + "\1\50\21\0\1\51\21\0\1\52\20\0\1\53\1\47"
152: + "\1\53\22\0\1\54\13\0\1\55\33\0\1\56\3\0"
153: + "\1\57\3\0\1\47\12\0\1\25\22\0\1\60\16\0"
154: + "\1\30\24\0\1\61\14\0\1\62\1\63\17\0\1\64"
155: + "\20\0\1\36\25\0\1\65\1\66\1\65\13\0\1\67"
156: + "\15\0\1\70\1\0\4\70\1\71\13\70\1\43\4\70"
157: + "\1\71\12\70\12\0\1\72\12\0\1\73\22\0\1\74"
158: + "\12\0\1\75\1\0\17\75\13\0\1\76\12\0\1\77"
159: + "\33\0\1\100\3\0\1\101\16\0\1\62\17\0\1\102"
160: + "\1\0\17\102\3\0\1\103\23\0\1\104\30\0\1\105"
161: + "\6\0\1\106\22\0\1\107\12\0\1\75\1\110\17\75"
162: + "\13\0\1\76\1\111\24\0\1\112\3\0\1\57\2\0"
163: + "\1\53\1\0\1\53\10\0\1\102\1\113\17\102\3\0"
164: + "\1\114\2\0\1\65\1\0\1\65\11\0\1\115\1\116"
165: + "\31\0\1\117\6\0\1\120\1\121\17\0\1\122\1\123"
166: + "\33\0\1\124\4\0\1\125\1\126\24\0\1\127\13\0"
167: + "\1\115\32\0\1\117\1\130\5\0\1\120\20\0\1\122"
168: + "\20\0\1\125\25\0\1\131\27\0\1\132\11\0\1\133"
169: + "\20\0\1\134\13\0\1\135\1\136\17\0\1\135\17\0";
170:
171: /**
172: * The transition table of the DFA
173: */
174: final private static int yytrans[] = yy_unpack();
175:
176: /* error codes */
177: final private static int YY_UNKNOWN_ERROR = 0;
178: final private static int YY_ILLEGAL_STATE = 1;
179: final private static int YY_NO_MATCH = 2;
180: final private static int YY_PUSHBACK_2BIG = 3;
181:
182: /* error messages for the codes above */
183: final private static String YY_ERROR_MSG[] = {
184: "Unkown internal scanner error",
185: "Internal error: unknown state",
186: "Error: could not match input",
187: "Error: pushback value was too large" };
188:
189: /**
190: * YY_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
191: */
192: private final static byte YY_ATTRIBUTE[] = { 8, 0, 0, 0, 0, 0, 0,
193: 0, 0, 9, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1,
194: 1, 9, 9, 1, 1, 1, 1, 9, 1, 1, 1, 0, 0, 9, 0, 0, 0, 0, 0, 0,
195: 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0,
196: 1, 0, 0, 0, 9, 0, 0, 9, 0, 0, 0, 0, 9, 0, 9, 0, 9, 9, 0, 0,
197: 0, 0, 9, 0, 0, 9, 0 };
198:
199: /** the input device */
200: private java.io.Reader yy_reader;
201:
202: /** the current state of the DFA */
203: private int yy_state;
204:
205: /** the current lexical state */
206: private int yy_lexical_state = YYINITIAL;
207:
208: /** this buffer contains the current text to be matched and is
209: the source of the yytext() string */
210: private char yy_buffer[] = new char[YY_BUFFERSIZE];
211:
212: /** the textposition at the last accepting state */
213: private int yy_markedPos;
214:
215: /** the textposition at the last state to be included in yytext */
216: private int yy_pushbackPos;
217:
218: /** the current text position in the buffer */
219: private int yy_currentPos;
220:
221: /** startRead marks the beginning of the yytext() string in the buffer */
222: private int yy_startRead;
223:
224: /** endRead marks the last character in the buffer, that has been read
225: from input */
226: private int yy_endRead;
227:
228: /** number of newlines encountered up to the start of the matched text */
229: private int yyline;
230:
231: /** the number of characters up to the start of the matched text */
232: private int yychar;
233:
234: /**
235: * the number of characters from the last newline up to the start of the
236: * matched text
237: */
238: private int yycolumn;
239:
240: /**
241: * yy_atBOL == true <=> the scanner is currently at the beginning of a line
242: */
243: private boolean yy_atBOL = true;
244:
245: /** yy_atEOF == true <=> the scanner is at the EOF */
246: private boolean yy_atEOF;
247:
248: /* user code: */
249: protected boolean allowHtml;
250: protected int listLevel;
251: protected boolean ordered;
252: protected static Logger cat = Logger.getLogger(LayoutLex.class);
253: protected String virtualWiki;
254:
255: protected boolean exists(String topic) {
256: try {
257: return WikiBase.getInstance().exists(virtualWiki, topic);
258: } catch (Exception err) {
259: cat.error(err);
260: }
261: return false;
262: }
263:
264: public void setVirtualWiki(String vWiki) {
265: this .virtualWiki = vWiki;
266: }
267:
268: protected String getListEntry(String text) {
269: cat.debug("first list item: " + text);
270: int count = 0;
271: ordered = false;
272:
273: cat.debug("First char='" + text.charAt(0) + "'");
274: if (text.charAt(0) == '#')
275: ordered = true;
276:
277: listLevel = 1;
278: StringBuffer buffer = new StringBuffer();
279: if (ordered)
280: buffer.append("<ol>");
281: else
282: buffer.append("<ul>");
283: buffer.append("<li>");
284: buffer.append(text.substring(count + 1).trim());
285: return buffer.toString();
286: }
287:
288: protected String getListSingleEntry(String text) {
289: cat.debug("another list item: " + text);
290: boolean tabs = false;
291: int count = 0;
292: if (text.charAt(0) == '\t') {
293: tabs = true;
294: for (int i = 0; i < text.length(); i++) {
295: if (text.charAt(i) == '\t')
296: count++;
297: else
298: break;
299: }
300: } else {
301: tabs = false;
302: for (int i = 0; i < text.length(); i += 3) {
303: if ((i + 3 <= text.length())
304: && (text.substring(i, i + 3).equals(" ")))
305: count++;
306: else
307: break;
308: }
309: }
310: StringBuffer buffer = new StringBuffer();
311: if (count > listLevel) {
312: for (int i = count - listLevel; i > 0; i--) {
313: if (ordered)
314: buffer.append("\n<ol>");
315: else
316: buffer.append("\n<ul>");
317: }
318: listLevel = count;
319: } else if (count < listLevel) {
320: buffer.append("</li>");
321: for (int i = listLevel - count; i > 0; i--) {
322: if (ordered)
323: buffer.append("</ol>");
324: else
325: buffer.append("</ul>");
326: }
327: listLevel = count;
328: buffer.append("\n");
329: } else {
330: buffer.append("</li>\n");
331: }
332: buffer.append("<li>");
333: if (tabs) {
334: buffer.append(text.substring(count + 1).trim());
335: } else {
336: buffer.append(text.substring((count * 3) + 1).trim());
337: }
338: return buffer.toString();
339: }
340:
341: /**
342: * Creates a new scanner
343: * There is also a java.io.InputStream version of this constructor.
344: *
345: * @param in the java.io.Reader to read input from.
346: */
347: public LayoutLex(java.io.Reader in) {
348: yybegin(NORMAL);
349: this .yy_reader = in;
350: }
351:
352: /**
353: * Creates a new scanner.
354: * There is also java.io.Reader version of this constructor.
355: *
356: * @param in the java.io.Inputstream to read input from.
357: */
358: public LayoutLex(java.io.InputStream in) {
359: this (new java.io.InputStreamReader(in));
360: }
361:
362: /**
363: * Unpacks the split, compressed DFA transition table.
364: *
365: * @return the unpacked transition table
366: */
367: private static int[] yy_unpack() {
368: int[] trans = new int[1173];
369: int offset = 0;
370: offset = yy_unpack(yy_packed0, offset, trans);
371: return trans;
372: }
373:
374: /**
375: * Unpacks the compressed DFA transition table.
376: *
377: * @param packed the packed transition table
378: * @return the index of the last entry
379: */
380: private static int yy_unpack(String packed, int offset, int[] trans) {
381: int i = 0; /* index in packed string */
382: int j = offset; /* index in unpacked array */
383: int l = packed.length();
384: while (i < l) {
385: int count = packed.charAt(i++);
386: int value = packed.charAt(i++);
387: value--;
388: do
389: trans[j++] = value;
390: while (--count > 0);
391: }
392: return j;
393: }
394:
395: /**
396: * Unpacks the compressed character translation table.
397: *
398: * @param packed the packed character translation table
399: * @return the unpacked character translation table
400: */
401: private static char[] yy_unpack_cmap(String packed) {
402: char[] map = new char[0x10000];
403: int i = 0; /* index in packed string */
404: int j = 0; /* index in unpacked array */
405: while (i < 1072) {
406: int count = packed.charAt(i++);
407: char value = packed.charAt(i++);
408: do
409: map[j++] = value;
410: while (--count > 0);
411: }
412: return map;
413: }
414:
415: /**
416: * Refills the input buffer.
417: *
418: * @return <code>false</code>, iff there was new input.
419: *
420: * @exception IOException if any I/O-Error occurs
421: */
422: private boolean yy_refill() throws java.io.IOException {
423:
424: /* first: make room (if you can) */
425: if (yy_startRead > 0) {
426: System.arraycopy(yy_buffer, yy_startRead, yy_buffer, 0,
427: yy_endRead - yy_startRead);
428:
429: /* translate stored positions */
430: yy_endRead -= yy_startRead;
431: yy_currentPos -= yy_startRead;
432: yy_markedPos -= yy_startRead;
433: yy_pushbackPos -= yy_startRead;
434: yy_startRead = 0;
435: }
436:
437: /* is the buffer big enough? */
438: if (yy_currentPos >= yy_buffer.length) {
439: /* if not: blow it up */
440: char newBuffer[] = new char[yy_currentPos * 2];
441: System.arraycopy(yy_buffer, 0, newBuffer, 0,
442: yy_buffer.length);
443: yy_buffer = newBuffer;
444: }
445:
446: /* finally: fill the buffer with new input */
447: int numRead = yy_reader.read(yy_buffer, yy_endRead,
448: yy_buffer.length - yy_endRead);
449:
450: if (numRead < 0) {
451: return true;
452: } else {
453: yy_endRead += numRead;
454: return false;
455: }
456: }
457:
458: /**
459: * Closes the input stream.
460: */
461: final public void yyclose() throws java.io.IOException {
462: yy_atEOF = true; /* indicate end of file */
463: yy_endRead = yy_startRead; /* invalidate buffer */
464:
465: if (yy_reader != null)
466: yy_reader.close();
467: }
468:
469: /**
470: * Closes the current stream, and resets the
471: * scanner to read from a new input stream.
472: *
473: * All internal variables are reset, the old input stream
474: * <b>cannot</b> be reused (internal buffer is discarded and lost).
475: * Lexical state is set to <tt>YY_INITIAL</tt>.
476: *
477: * @param reader the new input stream
478: */
479: final public void yyreset(java.io.Reader reader)
480: throws java.io.IOException {
481: yyclose();
482: yy_reader = reader;
483: yy_atBOL = true;
484: yy_atEOF = false;
485: yy_endRead = yy_startRead = 0;
486: yy_currentPos = yy_markedPos = yy_pushbackPos = 0;
487: yyline = yychar = yycolumn = 0;
488: yy_lexical_state = YYINITIAL;
489: }
490:
491: /**
492: * Returns the current lexical state.
493: */
494: final public int yystate() {
495: return yy_lexical_state;
496: }
497:
498: /**
499: * Enters a new lexical state
500: *
501: * @param newState the new lexical state
502: */
503: final public void yybegin(int newState) {
504: yy_lexical_state = newState;
505: }
506:
507: /**
508: * Returns the text matched by the current regular expression.
509: */
510: final public String yytext() {
511: return new String(yy_buffer, yy_startRead, yy_markedPos
512: - yy_startRead);
513: }
514:
515: /**
516: * Returns the character at position <tt>pos</tt> from the
517: * matched text.
518: *
519: * It is equivalent to yytext().charAt(pos), but faster
520: *
521: * @param pos the position of the character to fetch.
522: * A value from 0 to yylength()-1.
523: *
524: * @return the character at position pos
525: */
526: final public char yycharat(int pos) {
527: return yy_buffer[yy_startRead + pos];
528: }
529:
530: /**
531: * Returns the length of the matched text region.
532: */
533: final public int yylength() {
534: return yy_markedPos - yy_startRead;
535: }
536:
537: /**
538: * Reports an error that occured while scanning.
539: *
540: * In a wellformed scanner (no or only correct usage of
541: * yypushback(int) and a match-all fallback rule) this method
542: * will only be called with things that "Can't Possibly Happen".
543: * If this method is called, something is seriously wrong
544: * (e.g. a JFlex bug producing a faulty scanner etc.).
545: *
546: * Usual syntax/scanner level error handling should be done
547: * in error fallback rules.
548: *
549: * @param errorCode the code of the errormessage to display
550: */
551: private void yy_ScanError(int errorCode) {
552: String message;
553: try {
554: message = YY_ERROR_MSG[errorCode];
555: } catch (ArrayIndexOutOfBoundsException e) {
556: message = YY_ERROR_MSG[YY_UNKNOWN_ERROR];
557: }
558:
559: throw new Error(message);
560: }
561:
562: /**
563: * Pushes the specified amount of characters back into the input stream.
564: *
565: * They will be read again by then next call of the scanning method
566: *
567: * @param number the number of characters to be read again.
568: * This number must not be greater than yylength()!
569: */
570: private void yypushback(int number) {
571: if (number > yylength())
572: yy_ScanError(YY_PUSHBACK_2BIG);
573:
574: yy_markedPos -= number;
575: }
576:
577: /**
578: * Resumes scanning until the next regular expression is matched,
579: * the end of input is encountered or an I/O-Error occurs.
580: *
581: * @return the next token
582: * @exception IOException if any I/O-Error occurs
583: */
584: public String yylex() throws java.io.IOException {
585: int yy_input;
586: int yy_action;
587:
588: // cached fields:
589: int yy_currentPos_l;
590: int yy_startRead_l;
591: int yy_markedPos_l;
592: int yy_endRead_l = yy_endRead;
593: char[] yy_buffer_l = yy_buffer;
594: char[] yycmap_l = yycmap;
595:
596: int[] yytrans_l = yytrans;
597: int[] yy_rowMap_l = yy_rowMap;
598: byte[] yy_attr_l = YY_ATTRIBUTE;
599:
600: while (true) {
601: yy_markedPos_l = yy_markedPos;
602:
603: if (yy_markedPos_l > yy_startRead) {
604: switch (yy_buffer_l[yy_markedPos_l - 1]) {
605: case '\n':
606: case '\u000B':
607: case '\u000C':
608: case '\u0085':
609: case '\u2028':
610: case '\u2029':
611: yy_atBOL = true;
612: break;
613: case '\r':
614: if (yy_markedPos_l < yy_endRead_l)
615: yy_atBOL = yy_buffer_l[yy_markedPos_l] != '\n';
616: else if (yy_atEOF)
617: yy_atBOL = false;
618: else {
619: boolean eof = yy_refill();
620: yy_markedPos_l = yy_markedPos;
621: yy_buffer_l = yy_buffer;
622: if (eof)
623: yy_atBOL = false;
624: else
625: yy_atBOL = yy_buffer_l[yy_markedPos_l] != '\n';
626: }
627: break;
628: default:
629: yy_atBOL = false;
630: }
631: }
632: yy_action = -1;
633:
634: yy_startRead_l = yy_currentPos_l = yy_currentPos = yy_startRead = yy_markedPos_l;
635:
636: if (yy_atBOL)
637: yy_state = YY_LEXSTATE[yy_lexical_state + 1];
638: else
639: yy_state = YY_LEXSTATE[yy_lexical_state];
640:
641: yy_forAction: {
642: while (true) {
643:
644: if (yy_currentPos_l < yy_endRead_l)
645: yy_input = yy_buffer_l[yy_currentPos_l++];
646: else if (yy_atEOF) {
647: yy_input = YYEOF;
648: break yy_forAction;
649: } else {
650: // store back cached positions
651: yy_currentPos = yy_currentPos_l;
652: yy_markedPos = yy_markedPos_l;
653: boolean eof = yy_refill();
654: // get translated positions and possibly new buffer
655: yy_currentPos_l = yy_currentPos;
656: yy_markedPos_l = yy_markedPos;
657: yy_buffer_l = yy_buffer;
658: yy_endRead_l = yy_endRead;
659: if (eof) {
660: yy_input = YYEOF;
661: break yy_forAction;
662: } else {
663: yy_input = yy_buffer_l[yy_currentPos_l++];
664: }
665: }
666: int yy_next = yytrans_l[yy_rowMap_l[yy_state]
667: + yycmap_l[yy_input]];
668: if (yy_next == -1)
669: break yy_forAction;
670: yy_state = yy_next;
671:
672: int yy_attributes = yy_attr_l[yy_state];
673: if ((yy_attributes & 1) == 1) {
674: yy_action = yy_state;
675: yy_markedPos_l = yy_currentPos_l;
676: if ((yy_attributes & 8) == 8)
677: break yy_forAction;
678: }
679:
680: }
681: }
682:
683: // store back cached position
684: yy_markedPos = yy_markedPos_l;
685:
686: switch (yy_action) {
687:
688: case 40: {
689: cat.debug("Format off");
690: yybegin(OFF);
691: return "__";
692: }
693: case 95:
694: break;
695: case 34: {
696: cat.debug("tablerowend");
697: return "</tr><tr>";
698: }
699: case 96:
700: break;
701: case 9:
702: case 13:
703: case 14:
704: case 15:
705: case 17:
706: case 18:
707: case 19:
708: case 25:
709: case 33:
710: case 37: {
711: cat.debug(". (" + yytext() + ")");
712: return yytext();
713: }
714: case 97:
715: break;
716: case 84: {
717: cat.debug("@@@@{newline} entering PRE");
718: yybegin(PRE);
719: return "<pre>";
720: }
721: case 98:
722: break;
723: case 48: {
724: cat.debug("Format on");
725: yybegin(NORMAL);
726: return "__";
727: }
728: case 99:
729: break;
730: case 26:
731: case 27:
732: case 28: {
733: cat.debug("PRE, EXTERNAL {whitespace}");
734: return yytext();
735: }
736: case 100:
737: break;
738: case 81: {
739: cat.debug("table start");
740: yybegin(TABLE);
741: return "<table class=\"wikitable\" border=\"1\"><tr>";
742: }
743: case 101:
744: break;
745: case 67: {
746: cat.debug("tablecell");
747: String text = yytext();
748: StringBuffer buffer = new StringBuffer();
749: buffer.append("<td>");
750: buffer.append(text.substring(0, text.length() - 2));
751: buffer.append("</td>");
752: return buffer.toString();
753: }
754: case 102:
755: break;
756: case 11:
757: case 12:
758: case 16:
759: case 21:
760: case 22:
761: case 24:
762: case 30:
763: case 31:
764: case 32:
765: case 35:
766: case 36: {
767: String text = yytext();
768: StringBuffer buffer = new StringBuffer();
769: for (int i = 0; i < text.length(); i++) {
770: buffer.append((int) text.charAt(i));
771: }
772: cat.debug("{whitespace} " + buffer.toString());
773: return " ";
774: }
775: case 103:
776: break;
777: case 79: {
778: cat.debug("{hr}");
779: return "\n<hr>\n";
780: }
781: case 104:
782: break;
783: case 29: {
784: cat.debug("end of list");
785: yybegin(NORMAL);
786: StringBuffer buffer = new StringBuffer();
787: for (int i = listLevel; i > 0; i--) {
788: buffer.append("</li>");
789: if (ordered)
790: buffer.append("</ol>");
791: else
792: buffer.append("</ul>");
793: buffer.append("\n");
794: }
795: return buffer.toString();
796: }
797: case 105:
798: break;
799: case 83: {
800: cat.debug("external");
801: yybegin(EXTERNAL);
802: return yytext();
803: }
804: case 106:
805: break;
806: case 92: {
807: cat.debug("table end");
808: yybegin(NORMAL);
809: String text = yytext().trim();
810: StringBuffer buffer = new StringBuffer();
811: buffer.append("<td>");
812: buffer.append(text.substring(0, text.indexOf("##")));
813: buffer.append("</td>");
814: buffer.append("</tr></table>\n");
815: return buffer.toString();
816: }
817: case 107:
818: break;
819: case 49: {
820: cat.debug("{newline}x2 leaving pre");
821: yybegin(NORMAL);
822: return "</pre>\n";
823: }
824: case 108:
825: break;
826: case 10:
827: case 20:
828: case 23: {
829: cat.debug("{newline}");
830: StringBuffer buffer = new StringBuffer();
831: for (int i = 0; i < Environment.getInstance()
832: .getIntSetting(
833: Environment.PROPERTY_NEW_LINE_BREAKS); i++)
834: buffer.append("<br/>");
835: buffer.append("\n");
836: return buffer.toString();
837: }
838: case 109:
839: break;
840: case 71: {
841: yybegin(LIST);
842: return getListEntry(yytext().trim());
843: }
844: case 110:
845: break;
846: case 74: {
847: return getListSingleEntry(yytext());
848: }
849: case 111:
850: break;
851: case 89: {
852: cat.debug("external end");
853: yybegin(NORMAL);
854: return yytext();
855: }
856: case 112:
857: break;
858: case 62: {
859:
860: cat.debug("escaped double backslash");
861: return "\\__";
862: }
863: case 113:
864: break;
865: default:
866: if (yy_input == YYEOF && yy_startRead == yy_currentPos) {
867: yy_atEOF = true;
868: {
869: cat.debug("Ending at list level: " + listLevel);
870: if (yy_lexical_state == LIST) {
871: yybegin(NORMAL);
872: StringBuffer buffer = new StringBuffer();
873: for (int i = listLevel; i > 0; i--) {
874: buffer.append("</li>");
875: if (ordered)
876: buffer.append("</ol>");
877: else
878: buffer.append("</ul>");
879: buffer.append("\n");
880: }
881: return buffer.toString();
882: }
883: if (yy_lexical_state == TABLE) {
884: yybegin(NORMAL);
885: return "</tr></table>";
886: }
887:
888: return null;
889: }
890: } else {
891: yy_ScanError(YY_NO_MATCH);
892: }
893: }
894: }
895: }
896:
897: }
|