2 // Generated by JFlex 1.8.2 http://jflex.de/
3 // source: jflex/function.jflex
7 package org.scilab.modules.helptools ;
9 import java.io.IOException;
10 import java.io.StringReader;
12 @javax.annotation.Generated("JFlex")
14 // See https://github.com/jflex-de/jflex/issues/222
15 @SuppressWarnings("FallThrough")
16 public final class SynopsisLexer {
18 /** This character denotes the end of file. */
19 public static final int YYEOF = -1;
21 /** Initial size of the lookahead buffer. */
22 private static final int ZZ_BUFFERSIZE = 16384;
25 public static final int YYINITIAL = 0;
28 * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
29 * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
30 * at the beginning of a line
31 * l is of the form l = 2*k, k a non negative integer
33 private static final int ZZ_LEXSTATE[] = {
38 * Top-level table for translating characters to character classes
40 private static final int [] ZZ_CMAP_TOP = zzUnpackcmap_top();
42 private static final String ZZ_CMAP_TOP_PACKED_0 =
45 private static int [] zzUnpackcmap_top() {
46 int [] result = new int[4352];
48 offset = zzUnpackcmap_top(ZZ_CMAP_TOP_PACKED_0, offset, result);
52 private static int zzUnpackcmap_top(String packed, int offset, int [] result) {
53 int i = 0; /* index in packed string */
54 int j = offset; /* index in unpacked array */
55 int l = packed.length();
57 int count = packed.charAt(i++);
58 int value = packed.charAt(i++);
59 do result[j++] = value; while (--count > 0);
66 * Second-level tables for translating characters to character classes
68 private static final int [] ZZ_CMAP_BLOCKS = zzUnpackcmap_blocks();
70 private static final String ZZ_CMAP_BLOCKS_PACKED_0 =
71 "\11\0\1\1\1\2\2\0\1\3\22\0\1\1\1\4"+
72 "\1\5\1\4\1\6\1\7\1\10\1\11\7\0\1\12"+
73 "\12\13\2\0\1\14\1\0\1\15\1\4\1\0\32\4"+
74 "\4\0\1\4\1\0\32\4\u0185\0";
76 private static int [] zzUnpackcmap_blocks() {
77 int [] result = new int[512];
79 offset = zzUnpackcmap_blocks(ZZ_CMAP_BLOCKS_PACKED_0, offset, result);
83 private static int zzUnpackcmap_blocks(String packed, int offset, int [] result) {
84 int i = 0; /* index in packed string */
85 int j = offset; /* index in unpacked array */
86 int l = packed.length();
88 int count = packed.charAt(i++);
89 int value = packed.charAt(i++);
90 do result[j++] = value; while (--count > 0);
96 * Translates DFA states to action switch labels.
98 private static final int [] ZZ_ACTION = zzUnpackAction();
100 private static final String ZZ_ACTION_PACKED_0 =
101 "\1\0\1\1\1\2\2\3\1\4\1\5\1\1\1\6"+
102 "\1\7\1\1\1\10\1\11\1\4\1\12";
104 private static int [] zzUnpackAction() {
105 int [] result = new int[15];
107 offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
111 private static int zzUnpackAction(String packed, int offset, int [] result) {
112 int i = 0; /* index in packed string */
113 int j = offset; /* index in unpacked array */
114 int l = packed.length();
116 int count = packed.charAt(i++);
117 int value = packed.charAt(i++);
118 do result[j++] = value; while (--count > 0);
125 * Translates a state to a row index in the transition table
127 private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
129 private static final String ZZ_ROWMAP_PACKED_0 =
130 "\0\0\0\16\0\34\0\52\0\70\0\106\0\124\0\142"+
131 "\0\124\0\124\0\160\0\124\0\124\0\142\0\176";
133 private static int [] zzUnpackRowMap() {
134 int [] result = new int[15];
136 offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
140 private static int zzUnpackRowMap(String packed, int offset, int [] result) {
141 int i = 0; /* index in packed string */
142 int j = offset; /* index in unpacked array */
143 int l = packed.length();
145 int high = packed.charAt(i++) << 16;
146 result[j++] = high | packed.charAt(i++);
152 * The transition table of the DFA
154 private static final int [] ZZ_TRANS = zzUnpackTrans();
156 private static final String ZZ_TRANS_PACKED_0 =
157 "\1\2\1\3\1\4\1\5\1\6\1\7\1\10\1\6"+
158 "\1\11\1\12\1\13\1\2\1\14\1\15\2\2\4\0"+
159 "\1\2\4\0\1\2\2\0\1\2\1\3\4\0\1\2"+
160 "\4\0\1\2\3\0\1\4\15\0\2\4\17\0\1\6"+
161 "\1\0\1\6\4\0\1\6\20\0\2\2\2\0\1\6"+
162 "\1\0\1\16\4\0\1\16\14\0\1\17\3\0\2\17"+
165 private static int [] zzUnpackTrans() {
166 int [] result = new int[140];
168 offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
172 private static int zzUnpackTrans(String packed, int offset, int [] result) {
173 int i = 0; /* index in packed string */
174 int j = offset; /* index in unpacked array */
175 int l = packed.length();
177 int count = packed.charAt(i++);
178 int value = packed.charAt(i++);
180 do result[j++] = value; while (--count > 0);
186 /** Error code for "Unknown internal scanner error". */
187 private static final int ZZ_UNKNOWN_ERROR = 0;
188 /** Error code for "could not match input". */
189 private static final int ZZ_NO_MATCH = 1;
190 /** Error code for "pushback value was too large". */
191 private static final int ZZ_PUSHBACK_2BIG = 2;
194 * Error messages for {@link #ZZ_UNKNOWN_ERROR}, {@link #ZZ_NO_MATCH}, and
195 * {@link #ZZ_PUSHBACK_2BIG} respectively.
197 private static final String ZZ_ERROR_MSG[] = {
198 "Unknown internal scanner error",
199 "Error: could not match input",
200 "Error: pushback value was too large"
204 * ZZ_ATTRIBUTE[aState] contains the attributes of state {@code aState}
206 private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
208 private static final String ZZ_ATTRIBUTE_PACKED_0 =
209 "\1\0\5\1\1\11\1\1\2\11\1\1\2\11\2\1";
211 private static int [] zzUnpackAttribute() {
212 int [] result = new int[15];
214 offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
218 private static int zzUnpackAttribute(String packed, int offset, int [] result) {
219 int i = 0; /* index in packed string */
220 int j = offset; /* index in unpacked array */
221 int l = packed.length();
223 int count = packed.charAt(i++);
224 int value = packed.charAt(i++);
225 do result[j++] = value; while (--count > 0);
231 private java.io.Reader zzReader;
233 /** Current state of the DFA. */
236 /** Current lexical state. */
237 private int zzLexicalState = YYINITIAL;
240 * This buffer contains the current text to be matched and is the source of the {@link #yytext()}
243 private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
245 /** Text position at the last accepting state. */
246 private int zzMarkedPos;
248 /** Current text position in the buffer. */
249 private int zzCurrentPos;
251 /** Marks the beginning of the {@link #yytext()} string in the buffer. */
252 private int zzStartRead;
254 /** Marks the last character in the buffer, that has been read from input. */
255 private int zzEndRead;
258 * Whether the scanner is at the end of file.
261 private boolean zzAtEOF;
264 * The number of occupied positions in {@link #zzBuffer} beyond {@link #zzEndRead}.
266 * <p>When a lead/high surrogate has been read from the input stream into the final
267 * {@link #zzBuffer} position, this will have a value of 1; otherwise, it will have a value of 0.
269 private int zzFinalHighSurrogate = 0;
271 /** Number of newlines encountered up to the start of the matched text. */
272 @SuppressWarnings("unused")
275 /** Number of characters from the last newline up to the start of the matched text. */
276 @SuppressWarnings("unused")
277 private int yycolumn;
279 /** Number of characters up to the start of the matched text. */
282 /** Whether the scanner is currently at the beginning of a line. */
283 @SuppressWarnings("unused")
284 private boolean zzAtBOL = true;
286 /** Whether the user-EOF-code has already been executed. */
287 @SuppressWarnings("unused")
288 private boolean zzEOFDone;
291 private static String currentName;
292 private static StringBuilder htmlBuffer = new StringBuilder(512);
293 private static SynopsisLexer lexer = new SynopsisLexer();
295 private SynopsisLexer() { }
297 public static String convert(String name, String str) {
300 lexer.yyreset(new StringReader(str.trim()));
301 lexer.yybegin(YYINITIAL);
302 htmlBuffer.setLength(0);
305 return htmlBuffer.toString();
306 } catch (IOException e) {
314 * Creates a new scanner
316 * @param in the java.io.Reader to read input from.
318 public SynopsisLexer(java.io.Reader in) {
323 * Translates raw input code points to DFA table row
325 private static int zzCMap(int input) {
326 int offset = input & 255;
327 return offset == input ? ZZ_CMAP_BLOCKS[offset] : ZZ_CMAP_BLOCKS[ZZ_CMAP_TOP[input >> 8] | offset];
331 * Refills the input buffer.
333 * @return {@code false} iff there was new input.
334 * @exception java.io.IOException if any I/O-Error occurs
336 private boolean zzRefill() throws java.io.IOException {
338 /* first: make room (if you can) */
339 if (zzStartRead > 0) {
340 zzEndRead += zzFinalHighSurrogate;
341 zzFinalHighSurrogate = 0;
342 System.arraycopy(zzBuffer, zzStartRead,
344 zzEndRead - zzStartRead);
346 /* translate stored positions */
347 zzEndRead -= zzStartRead;
348 zzCurrentPos -= zzStartRead;
349 zzMarkedPos -= zzStartRead;
353 /* is the buffer big enough? */
354 if (zzCurrentPos >= zzBuffer.length - zzFinalHighSurrogate) {
355 /* if not: blow it up */
356 char newBuffer[] = new char[zzBuffer.length * 2];
357 System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
358 zzBuffer = newBuffer;
359 zzEndRead += zzFinalHighSurrogate;
360 zzFinalHighSurrogate = 0;
363 /* fill the buffer with new input */
364 int requested = zzBuffer.length - zzEndRead;
365 int numRead = zzReader.read(zzBuffer, zzEndRead, requested);
367 /* not supposed to occur according to specification of java.io.Reader */
369 throw new java.io.IOException(
370 "Reader returned 0 characters. See JFlex examples/zero-reader for a workaround.");
373 zzEndRead += numRead;
374 if (Character.isHighSurrogate(zzBuffer[zzEndRead - 1])) {
375 if (numRead == requested) { // We requested too few chars to encode a full Unicode character
377 zzFinalHighSurrogate = 1;
378 } else { // There is room in the buffer for at least one more char
379 int c = zzReader.read(); // Expecting to read a paired low surrogate char
383 zzBuffer[zzEndRead++] = (char)c;
387 /* potentially more input available */
391 /* numRead < 0 ==> end of stream */
397 * Closes the input reader.
399 * @throws java.io.IOException if the reader could not be closed.
401 public final void yyclose() throws java.io.IOException {
402 zzAtEOF = true; // indicate end of file
403 zzEndRead = zzStartRead; // invalidate buffer
405 if (zzReader != null) {
412 * Resets the scanner to read from a new input stream.
414 * <p>Does not close the old reader.
416 * <p>All internal variables are reset, the old input stream <b>cannot</b> be reused (internal
417 * buffer is discarded and lost). Lexical state is set to {@code ZZ_INITIAL}.
419 * <p>Internal scan buffer is resized down to its initial length, if it has grown.
421 * @param reader The new input stream.
423 public final void yyreset(java.io.Reader reader) {
427 zzLexicalState = YYINITIAL;
428 if (zzBuffer.length > ZZ_BUFFERSIZE) {
429 zzBuffer = new char[ZZ_BUFFERSIZE];
434 * Resets the input position.
436 private final void yyResetPosition() {
443 zzFinalHighSurrogate = 0;
451 * Returns whether the scanner has reached the end of the reader it reads from.
453 * @return whether the scanner has reached EOF.
455 public final boolean yyatEOF() {
461 * Returns the current lexical state.
463 * @return the current lexical state.
465 public final int yystate() {
466 return zzLexicalState;
471 * Enters a new lexical state.
473 * @param newState the new lexical state
475 public final void yybegin(int newState) {
476 zzLexicalState = newState;
481 * Returns the text matched by the current regular expression.
483 * @return the matched text.
485 public final String yytext() {
486 return new String(zzBuffer, zzStartRead, zzMarkedPos-zzStartRead);
491 * Returns the character at the given position from the matched text.
493 * <p>It is equivalent to {@code yytext().charAt(pos)}, but faster.
495 * @param position the position of the character to fetch. A value from 0 to {@code yylength()-1}.
497 * @return the character at {@code position}.
499 public final char yycharat(int position) {
500 return zzBuffer[zzStartRead + position];
505 * How many characters were matched.
507 * @return the length of the matched text region.
509 public final int yylength() {
510 return zzMarkedPos-zzStartRead;
515 * Reports an error that occurred while scanning.
517 * <p>In a well-formed scanner (no or only correct usage of {@code yypushback(int)} and a
518 * match-all fallback rule) this method will only be called with things that
519 * "Can't Possibly Happen".
521 * <p>If this method is called, something is seriously wrong (e.g. a JFlex bug producing a faulty
524 * <p>Usual syntax/scanner level error handling should be done in error fallback rules.
526 * @param errorCode the code of the error message to display.
528 private static void zzScanError(int errorCode) {
531 message = ZZ_ERROR_MSG[errorCode];
532 } catch (ArrayIndexOutOfBoundsException e) {
533 message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
536 throw new Error(message);
541 * Pushes the specified amount of characters back into the input stream.
543 * <p>They will be read again by then next call of the scanning method.
545 * @param number the number of characters to be read again. This number must not be greater than
546 * {@link #yylength()}.
548 public void yypushback(int number) {
549 if ( number > yylength() )
550 zzScanError(ZZ_PUSHBACK_2BIG);
552 zzMarkedPos -= number;
559 * Resumes scanning until the next regular expression is matched, the end of input is encountered
560 * or an I/O-Error occurs.
562 * @return the next token.
563 * @exception java.io.IOException if any I/O-Error occurs.
565 public void yylex() throws java.io.IOException {
572 int zzEndReadL = zzEndRead;
573 char[] zzBufferL = zzBuffer;
575 int [] zzTransL = ZZ_TRANS;
576 int [] zzRowMapL = ZZ_ROWMAP;
577 int [] zzAttrL = ZZ_ATTRIBUTE;
580 zzMarkedPosL = zzMarkedPos;
582 yychar+= zzMarkedPosL-zzStartRead;
586 zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
588 zzState = ZZ_LEXSTATE[zzLexicalState];
590 // set up zzAction for empty match case:
591 int zzAttributes = zzAttrL[zzState];
592 if ( (zzAttributes & 1) == 1 ) {
600 if (zzCurrentPosL < zzEndReadL) {
601 zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL);
602 zzCurrentPosL += Character.charCount(zzInput);
609 // store back cached positions
610 zzCurrentPos = zzCurrentPosL;
611 zzMarkedPos = zzMarkedPosL;
612 boolean eof = zzRefill();
613 // get translated positions and possibly new buffer
614 zzCurrentPosL = zzCurrentPos;
615 zzMarkedPosL = zzMarkedPos;
616 zzBufferL = zzBuffer;
617 zzEndReadL = zzEndRead;
623 zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL);
624 zzCurrentPosL += Character.charCount(zzInput);
627 int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMap(zzInput) ];
628 if (zzNext == -1) break zzForAction;
631 zzAttributes = zzAttrL[zzState];
632 if ( (zzAttributes & 1) == 1 ) {
634 zzMarkedPosL = zzCurrentPosL;
635 if ( (zzAttributes & 8) == 8 ) break zzForAction;
641 // store back cached position
642 zzMarkedPos = zzMarkedPosL;
644 if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
650 switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
652 { htmlBuffer.append("<span class=\"default\">");
653 htmlBuffer.append(yytext());
654 htmlBuffer.append("</span>");
659 { htmlBuffer.append(" ");
664 { htmlBuffer.append("\n");
669 { String str = yytext();
670 if (str.equals(currentName)) {
671 htmlBuffer.append("<span class=\"functionid\">");
673 htmlBuffer.append("<span class=\"default\">");
675 htmlBuffer.append(str);
676 htmlBuffer.append("</span>");
681 { htmlBuffer.append(""");
686 { htmlBuffer.append("&");
691 { htmlBuffer.append("'");
696 { htmlBuffer.append("<");
701 { htmlBuffer.append(">");
706 { htmlBuffer.append("<span class=\"comment\">");
707 htmlBuffer.append(yytext());
708 htmlBuffer.append("</span>");
713 zzScanError(ZZ_NO_MATCH);