1 /* The following code was generated by JFlex 1.4.3 on 23/05/12 15:21 */
5 package org.scilab.modules.helptools.c;
8 import java.io.StringReader;
9 import java.io.IOException;
11 @javax.annotation.Generated("JFlex")
12 @SuppressWarnings("fallthrough")
15 * This class is a scanner generated by
16 * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
17 * on 23/05/12 15:21 from the specification file
18 * <tt>./jflex/c.jflex</tt>
20 public final class CLexer {
22 /** This character denotes the end of file */
23 public static final int YYEOF = -1;
25 /** initial size of the lookahead buffer */
26 private static final int ZZ_BUFFERSIZE = 16384;
29 public static final int STRING = 4;
30 public static final int CLEANFIRST = 8;
31 public static final int CLEAN = 6;
32 public static final int YYINITIAL = 0;
33 public static final int COMMENT = 2;
36 * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
37 * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
38 * at the beginning of a line
39 * l is of the form l = 2*k, k a non negative integer
41 private static final int ZZ_LEXSTATE[] = {
42 0, 0, 1, 1, 2, 2, 3, 3, 4, 4
46 * Translates characters to character classes
48 private static final String ZZ_CMAP_PACKED =
49 "\11\0\1\31\1\2\1\0\1\3\1\1\22\0\1\3\1\61\1\26" +
50 "\1\57\1\0\2\61\1\30\2\60\1\5\1\21\1\61\1\21\1\24" +
51 "\1\4\1\22\11\11\2\61\1\63\1\61\1\62\1\61\1\0\4\10" +
52 "\1\20\1\17\5\6\1\15\1\6\1\25\6\6\1\13\2\6\1\23" +
53 "\2\6\1\60\1\27\1\60\1\61\1\7\1\0\1\32\1\35\1\41" +
54 "\1\46\1\37\1\16\1\51\1\43\1\44\1\6\1\40\1\14\1\50" +
55 "\1\45\1\34\1\52\1\64\1\36\1\42\1\33\1\12\1\55\1\53" +
56 "\1\56\1\47\1\54\1\60\1\61\1\60\1\61\uff81\0";
59 * Translates characters to character classes
61 private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
64 * Translates DFA states to action switch labels.
66 private static final int [] ZZ_ACTION = zzUnpackAction();
68 private static final String ZZ_ACTION_PACKED_0 =
69 "\1\0\1\1\1\2\2\0\2\3\1\4\1\5\1\6" +
70 "\1\7\3\6\1\7\1\5\1\6\1\10\1\3\21\6" +
71 "\1\3\1\11\3\5\1\1\2\12\2\0\1\2\2\13" +
72 "\1\14\1\0\1\15\1\16\1\17\1\20\1\21\1\22" +
73 "\1\1\1\23\2\7\7\6\1\0\1\6\2\0\6\6" +
74 "\1\5\20\6\1\24\4\6\1\24\11\6\7\0\1\1" +
75 "\2\25\1\26\1\0\1\7\1\0\6\6\1\7\1\6" +
76 "\2\2\34\6\1\27\16\6\6\0\1\30\4\0\1\7" +
77 "\1\0\5\6\1\7\40\6\11\0\4\6\1\5\5\6" +
78 "\1\31\15\6\1\0\1\30\4\0\1\31\11\6\3\0" +
81 private static int [] zzUnpackAction() {
82 int [] result = new int[290];
84 offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
88 private static int zzUnpackAction(String packed, int offset, int [] result) {
89 int i = 0; /* index in packed string */
90 int j = offset; /* index in unpacked array */
91 int l = packed.length();
93 int count = packed.charAt(i++);
94 int value = packed.charAt(i++);
97 } while (--count > 0);
104 private static final int ZZ_UNKNOWN_ERROR = 0;
105 private static final int ZZ_NO_MATCH = 1;
106 private static final int ZZ_PUSHBACK_2BIG = 2;
108 /* error messages for the codes above */
109 private static final String ZZ_ERROR_MSG[] = {
110 "Unkown internal scanner error",
111 "Error: could not match input",
112 "Error: pushback value was too large"
115 /** the input device */
116 private java.io.Reader zzReader;
118 /** the current state of the DFA */
121 /** the current lexical state */
122 private int zzLexicalState = YYINITIAL;
124 /** this buffer contains the current text to be matched and is
125 the source of the yytext() string */
126 private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
128 /** the textposition at the last accepting state */
129 private int zzMarkedPos;
131 /** the current text position in the buffer */
132 private int zzCurrentPos;
134 /** startRead marks the beginning of the yytext() string in the buffer */
135 private int zzStartRead;
137 /** endRead marks the last character in the buffer, that has been read
139 private int zzEndRead;
141 /** number of newlines encountered up to the start of the matched text */
144 /** the number of characters up to the start of the matched text */
148 * the number of characters from the last newline up to the start of the
151 private int yycolumn;
154 * zzAtBOL == true <=> the scanner is currently at the beginning of a line
156 private boolean zzAtBOL = true;
158 /** zzAtEOF == true <=> the scanner is at the EOF */
159 private boolean zzAtEOF;
161 /** denotes if the user-EOF-code has already been executed */
162 private boolean zzEOFDone;
166 private int whitesOnFirstLine;
167 private int saveLexState;
168 private AbstractCCodeHandler handler;
172 private String trimEnd(String str) {
173 int end = str.length() - 1;
175 for (; i >= 0; i--) {
176 char c = str.charAt(i);
177 if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
182 return str.substring(0, i + 1);
188 public String convert(AbstractCCodeHandler h, String code) {
189 Reader reader = new StringReader(trimEnd(code));
190 String str = convert(h, reader, true);
193 } catch (IOException e) { }
198 public String convert(AbstractCCodeHandler h, Reader code, boolean ret) {
203 whitesOnFirstLine = 0;
208 } catch (IOException e) {
220 * Creates a new scanner
221 * There is also a java.io.InputStream version of this constructor.
223 * @param in the java.io.Reader to read input from.
225 public CLexer(java.io.Reader in) {
230 * Creates a new scanner.
231 * There is also java.io.Reader version of this constructor.
233 * @param in the java.io.Inputstream to read input from.
235 public CLexer(java.io.InputStream in) {
236 this(new java.io.InputStreamReader(in));
240 * Unpacks the compressed character translation table.
242 * @param packed the packed character translation table
243 * @return the unpacked character translation table
245 private static char [] zzUnpackCMap(String packed) {
246 char [] map = new char[0x10000];
247 int i = 0; /* index in packed string */
248 int j = 0; /* index in unpacked array */
250 int count = packed.charAt(i++);
251 char value = packed.charAt(i++);
254 } while (--count > 0);
261 * Refills the input buffer.
263 * @return <code>false</code>, iff there was new input.
265 * @exception java.io.IOException if any I/O-Error occurs
267 private boolean zzRefill() throws java.io.IOException {
269 /* first: make room (if you can) */
270 if (zzStartRead > 0) {
271 System.arraycopy(zzBuffer, zzStartRead,
273 zzEndRead - zzStartRead);
275 /* translate stored positions */
276 zzEndRead -= zzStartRead;
277 zzCurrentPos -= zzStartRead;
278 zzMarkedPos -= zzStartRead;
282 /* is the buffer big enough? */
283 if (zzCurrentPos >= zzBuffer.length) {
284 /* if not: blow it up */
285 char newBuffer[] = new char[zzCurrentPos * 2];
286 System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
287 zzBuffer = newBuffer;
290 /* finally: fill the buffer with new input */
291 int numRead = zzReader.read(zzBuffer, zzEndRead,
292 zzBuffer.length - zzEndRead);
295 zzEndRead += numRead;
298 // unlikely but not impossible: read 0 characters, but not at end of stream
300 int c = zzReader.read();
304 zzBuffer[zzEndRead++] = (char) c;
315 * Closes the input stream.
317 public final void yyclose() throws java.io.IOException {
318 zzAtEOF = true; /* indicate end of file */
319 zzEndRead = zzStartRead; /* invalidate buffer */
321 if (zzReader != null) {
328 * Resets the scanner to read from a new input stream.
329 * Does not close the old reader.
331 * All internal variables are reset, the old input stream
332 * <b>cannot</b> be reused (internal buffer is discarded and lost).
333 * Lexical state is set to <tt>ZZ_INITIAL</tt>.
335 * @param reader the new input stream
337 public final void yyreset(java.io.Reader reader) {
342 zzEndRead = zzStartRead = 0;
343 zzCurrentPos = zzMarkedPos = 0;
344 yyline = yychar = yycolumn = 0;
345 zzLexicalState = YYINITIAL;
350 * Returns the current lexical state.
352 public final int yystate() {
353 return zzLexicalState;
358 * Enters a new lexical state
360 * @param newState the new lexical state
362 public final void yybegin(int newState) {
363 zzLexicalState = newState;
368 * Returns the text matched by the current regular expression.
370 public final String yytext() {
371 return new String( zzBuffer, zzStartRead, zzMarkedPos - zzStartRead );
376 * Returns the character at position <tt>pos</tt> from the
379 * It is equivalent to yytext().charAt(pos), but faster
381 * @param pos the position of the character to fetch.
382 * A value from 0 to yylength()-1.
384 * @return the character at position pos
386 public final char yycharat(int pos) {
387 return zzBuffer[zzStartRead + pos];
392 * Returns the length of the matched text region.
394 public final int yylength() {
395 return zzMarkedPos - zzStartRead;
400 * Reports an error that occurred while scanning.
402 * In a wellformed scanner (no or only correct usage of
403 * yypushback(int) and a match-all fallback rule) this method
404 * will only be called with things that "Can't Possibly Happen".
405 * If this method is called, something is seriously wrong
406 * (e.g. a JFlex bug producing a faulty scanner etc.).
408 * Usual syntax/scanner level error handling should be done
409 * in error fallback rules.
411 * @param errorCode the code of the errormessage to display
413 private void zzScanError(int errorCode) {
416 message = ZZ_ERROR_MSG[errorCode];
417 } catch (ArrayIndexOutOfBoundsException e) {
418 message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
421 throw new Error(message);
426 * Pushes the specified amount of characters back into the input stream.
428 * They will be read again by then next call of the scanning method
430 * @param number the number of characters to be read again.
431 * This number must not be greater than yylength()!
433 public void yypushback(int number) {
434 if ( number > yylength() ) {
435 zzScanError(ZZ_PUSHBACK_2BIG);
438 zzMarkedPos -= number;
443 * Resumes scanning until the next regular expression is matched,
444 * the end of input is encountered or an I/O-Error occurs.
446 * @return the next token
447 * @exception java.io.IOException if any I/O-Error occurs
449 public void yylex() throws java.io.IOException {
456 int zzEndReadL = zzEndRead;
457 char [] zzBufferL = zzBuffer;
458 char [] zzCMapL = ZZ_CMAP;
462 zzMarkedPosL = zzMarkedPos;
464 yychar += zzMarkedPosL - zzStartRead;
468 zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
470 zzState = ZZ_LEXSTATE[zzLexicalState];
476 if (zzCurrentPosL < zzEndReadL) {
477 zzInput = zzBufferL[zzCurrentPosL++];
478 } else if (zzAtEOF) {
482 // store back cached positions
483 zzCurrentPos = zzCurrentPosL;
484 zzMarkedPos = zzMarkedPosL;
485 boolean eof = zzRefill();
486 // get translated positions and possibly new buffer
487 zzCurrentPosL = zzCurrentPos;
488 zzMarkedPosL = zzMarkedPos;
489 zzBufferL = zzBuffer;
490 zzEndReadL = zzEndRead;
495 zzInput = zzBufferL[zzCurrentPosL++];
498 zzInput = zzCMapL[zzInput];
500 boolean zzIsFinal = false;
501 boolean zzNoLookAhead = false;
515 zzNoLookAhead = true;
524 zzNoLookAhead = true;
561 zzNoLookAhead = true;
642 zzNoLookAhead = true;
647 zzNoLookAhead = true;
672 zzNoLookAhead = true;
695 zzNoLookAhead = true;
700 zzNoLookAhead = true;
726 zzNoLookAhead = true;
745 zzNoLookAhead = true;
754 zzNoLookAhead = true;
1634 zzNoLookAhead = true;
1645 zzNoLookAhead = true;
1669 zzNoLookAhead = true;
1694 zzNoLookAhead = true;
1699 zzNoLookAhead = true;
1729 zzNoLookAhead = true;
1834 zzNoLookAhead = true;
2113 zzNoLookAhead = true;
3432 zzNoLookAhead = true;
3443 zzNoLookAhead = true;