View Javadoc
1   // DO NOT EDIT
2   // Generated by JFlex 1.9.1 http://jflex.de/
3   // source: src/main/jflex/testpanel/er7.flex
4   
5   package testpanel;
6   
7   import jsyntaxpane.lexers.*;
8   import jsyntaxpane.Token;
9   import jsyntaxpane.TokenType;
10  
11  
12  @SuppressWarnings("fallthrough")
13  public final class Er7Lexer extends DefaultJFlexLexer {
14  
15    /** This character denotes the end of file. */
16    public static final int YYEOF = -1;
17  
18    /** Initial size of the lookahead buffer. */
19    private static final int ZZ_BUFFERSIZE = 16384;
20  
21    // Lexical states.
22    public static final int YYINITIAL = 0;
23    public static final int AT_START_OF_VALUE = 2;
24    public static final int WITHIN_VALUE = 4;
25    public static final int AT_DELIM = 6;
26  
27    /**
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
32     */
33    private static final int ZZ_LEXSTATE[] = {
34       0,  0,  1,  1,  2,  2,  3, 3
35    };
36  
37    /**
38     * Top-level table for translating characters to character classes
39     */
40    private static final int [] ZZ_CMAP_TOP = zzUnpackcmap_top();
41  
42    private static final String ZZ_CMAP_TOP_PACKED_0 =
43      "\1\0\1\u0100\36\u0200\1\u0300\267\u0200\10\u0400\u1020\u0200";
44  
45    private static int [] zzUnpackcmap_top() {
46      int [] result = new int[4352];
47      int offset = 0;
48      offset = zzUnpackcmap_top(ZZ_CMAP_TOP_PACKED_0, offset, result);
49      return result;
50    }
51  
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();
56      while (i < l) {
57        int count = packed.charAt(i++);
58        int value = packed.charAt(i++);
59        do result[j++] = value; while (--count > 0);
60      }
61      return j;
62    }
63  
64  
65    /**
66     * Second-level tables for translating characters to character classes
67     */
68    private static final int [] ZZ_CMAP_BLOCKS = zzUnpackcmap_blocks();
69  
70    private static final String ZZ_CMAP_BLOCKS_PACKED_0 =
71      "\12\0\1\1\2\2\1\3\22\0\1\4\2\0\1\5"+
72      "\2\0\1\6\6\0\1\7\1\10\1\0\12\11\7\0"+
73      "\7\12\1\13\4\12\1\14\5\12\1\15\7\12\1\0"+
74      "\1\16\1\0\1\6\2\0\7\4\1\17\4\4\1\20"+
75      "\5\4\1\21\7\4\1\0\1\6\1\0\1\6\6\0"+
76      "\1\2\371\0\1\22\u01a8\0\2\2\326\0\u0100\2";
77  
78    private static int [] zzUnpackcmap_blocks() {
79      int [] result = new int[1280];
80      int offset = 0;
81      offset = zzUnpackcmap_blocks(ZZ_CMAP_BLOCKS_PACKED_0, offset, result);
82      return result;
83    }
84  
85    private static int zzUnpackcmap_blocks(String packed, int offset, int [] result) {
86      int i = 0;       /* index in packed string  */
87      int j = offset;  /* index in unpacked array */
88      int l = packed.length();
89      while (i < l) {
90        int count = packed.charAt(i++);
91        int value = packed.charAt(i++);
92        do result[j++] = value; while (--count > 0);
93      }
94      return j;
95    }
96  
97    /**
98     * Translates DFA states to action switch labels.
99     */
100   private static final int [] ZZ_ACTION = zzUnpackAction();
101 
102   private static final String ZZ_ACTION_PACKED_0 =
103     "\4\0\1\1\1\2\1\3\3\1\1\4\2\5\1\4"+
104     "\1\3\2\2\3\0\2\6\1\7\2\0\1\10\1\11";
105 
106   private static int [] zzUnpackAction() {
107     int [] result = new int[27];
108     int offset = 0;
109     offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
110     return result;
111   }
112 
113   private static int zzUnpackAction(String packed, int offset, int [] result) {
114     int i = 0;       /* index in packed string  */
115     int j = offset;  /* index in unpacked array */
116     int l = packed.length();
117     while (i < l) {
118       int count = packed.charAt(i++);
119       int value = packed.charAt(i++);
120       do result[j++] = value; while (--count > 0);
121     }
122     return j;
123   }
124 
125 
126   /**
127    * Translates a state to a row index in the transition table
128    */
129   private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
130 
131   private static final String ZZ_ROWMAP_PACKED_0 =
132     "\0\0\0\23\0\46\0\71\0\114\0\137\0\114\0\162"+
133     "\0\205\0\230\0\114\0\114\0\253\0\276\0\321\0\114"+
134     "\0\344\0\367\0\u010a\0\u011d\0\114\0\u0130\0\114\0\276"+
135     "\0\u0143\0\114\0\114";
136 
137   private static int [] zzUnpackRowMap() {
138     int [] result = new int[27];
139     int offset = 0;
140     offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
141     return result;
142   }
143 
144   private static int zzUnpackRowMap(String packed, int offset, int [] result) {
145     int i = 0;  /* index in packed string  */
146     int j = offset;  /* index in unpacked array */
147     int l = packed.length() - 1;
148     while (i < l) {
149       int high = packed.charAt(i++) << 16;
150       result[j++] = high | packed.charAt(i++);
151     }
152     return j;
153   }
154 
155   /**
156    * The transition table of the DFA
157    */
158   private static final int [] ZZ_TRANS = zzUnpacktrans();
159 
160   private static final String ZZ_TRANS_PACKED_0 =
161     "\2\5\2\0\1\5\1\6\1\7\3\5\2\10\1\11"+
162     "\1\10\1\7\1\5\1\12\2\5\1\13\1\14\1\0"+
163     "\1\15\2\13\1\7\3\16\4\13\1\17\5\13\1\14"+
164     "\1\0\1\15\2\13\1\7\7\13\1\17\4\13\1\7"+
165     "\1\5\2\0\17\7\23\0\1\6\1\20\1\6\1\21"+
166     "\17\6\11\0\5\22\16\0\4\22\1\23\3\0\2\24"+
167     "\15\0\1\24\3\0\2\24\1\0\1\14\22\0\1\25"+
168     "\1\0\1\26\2\0\1\27\3\30\4\0\1\27\10\0"+
169     "\1\31\3\0\6\31\1\0\3\31\2\0\1\20\32\0"+
170     "\5\32\16\0\5\32\1\0\1\32\16\0\1\32\3\0"+
171     "\1\32\4\0\1\25\25\0\1\31\3\0\6\31\1\33"+
172     "\3\31\1\0";
173 
174   private static int [] zzUnpacktrans() {
175     int [] result = new int[342];
176     int offset = 0;
177     offset = zzUnpacktrans(ZZ_TRANS_PACKED_0, offset, result);
178     return result;
179   }
180 
181   private static int zzUnpacktrans(String packed, int offset, int [] result) {
182     int i = 0;       /* index in packed string  */
183     int j = offset;  /* index in unpacked array */
184     int l = packed.length();
185     while (i < l) {
186       int count = packed.charAt(i++);
187       int value = packed.charAt(i++);
188       value--;
189       do result[j++] = value; while (--count > 0);
190     }
191     return j;
192   }
193 
194 
195   /** Error code for "Unknown internal scanner error". */
196   private static final int ZZ_UNKNOWN_ERROR = 0;
197   /** Error code for "could not match input". */
198   private static final int ZZ_NO_MATCH = 1;
199   /** Error code for "pushback value was too large". */
200   private static final int ZZ_PUSHBACK_2BIG = 2;
201 
202   /**
203    * Error messages for {@link #ZZ_UNKNOWN_ERROR}, {@link #ZZ_NO_MATCH}, and
204    * {@link #ZZ_PUSHBACK_2BIG} respectively.
205    */
206   private static final String ZZ_ERROR_MSG[] = {
207     "Unknown internal scanner error",
208     "Error: could not match input",
209     "Error: pushback value was too large"
210   };
211 
212   /**
213    * ZZ_ATTRIBUTE[aState] contains the attributes of state {@code aState}
214    */
215   private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
216 
217   private static final String ZZ_ATTRIBUTE_PACKED_0 =
218     "\4\0\1\11\1\1\1\11\3\1\2\11\3\1\1\11"+
219     "\1\1\3\0\1\11\1\1\1\11\2\0\2\11";
220 
221   private static int [] zzUnpackAttribute() {
222     int [] result = new int[27];
223     int offset = 0;
224     offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
225     return result;
226   }
227 
228   private static int zzUnpackAttribute(String packed, int offset, int [] result) {
229     int i = 0;       /* index in packed string  */
230     int j = offset;  /* index in unpacked array */
231     int l = packed.length();
232     while (i < l) {
233       int count = packed.charAt(i++);
234       int value = packed.charAt(i++);
235       do result[j++] = value; while (--count > 0);
236     }
237     return j;
238   }
239 
240   /** Input device. */
241   private java.io.Reader zzReader;
242 
243   /** Current state of the DFA. */
244   private int zzState;
245 
246   /** Current lexical state. */
247   private int zzLexicalState = YYINITIAL;
248 
249   /**
250    * This buffer contains the current text to be matched and is the source of the {@link #yytext()}
251    * string.
252    */
253   private char zzBuffer[] = new char[Math.min(ZZ_BUFFERSIZE, zzMaxBufferLen())];
254 
255   /** Text position at the last accepting state. */
256   private int zzMarkedPos;
257 
258   /** Current text position in the buffer. */
259   private int zzCurrentPos;
260 
261   /** Marks the beginning of the {@link #yytext()} string in the buffer. */
262   private int zzStartRead;
263 
264   /** Marks the last character in the buffer, that has been read from input. */
265   private int zzEndRead;
266 
267   /**
268    * Whether the scanner is at the end of file.
269    * @see #yyatEOF
270    */
271   private boolean zzAtEOF;
272 
273   /**
274    * The number of occupied positions in {@link #zzBuffer} beyond {@link #zzEndRead}.
275    *
276    * <p>When a lead/high surrogate has been read from the input stream into the final
277    * {@link #zzBuffer} position, this will have a value of 1; otherwise, it will have a value of 0.
278    */
279   private int zzFinalHighSurrogate = 0;
280 
281   /** Number of newlines encountered up to the start of the matched text. */
282   @SuppressWarnings("unused")
283   private int yyline;
284 
285   /** Number of characters from the last newline up to the start of the matched text. */
286   @SuppressWarnings("unused")
287   private int yycolumn;
288 
289   /** Number of characters up to the start of the matched text. */
290   private long yychar;
291 
292   /** Whether the scanner is currently at the beginning of a line. */
293   @SuppressWarnings("unused")
294   private boolean zzAtBOL = true;
295 
296   /** Whether the user-EOF-code has already been executed. */
297   @SuppressWarnings("unused")
298   private boolean zzEOFDone;
299 
300   /* user code: */
301 
302 	private boolean myReturnNewlines;
303 	
304     /**
305      * Default constructor is needed as we will always call the yyreset
306      */
307     public Er7Lexer() {
308         super();
309     }
310 
311     /**
312      * Default constructor is needed as we will always call the yyreset
313      */
314     public Er7Lexer(boolean theReturnNewlines) {
315         super();
316         myReturnNewlines = theReturnNewlines;
317     }
318 
319 	@Override
320     public int yychar() {
321         return (int)yychar;
322     }
323     
324 
325 
326 
327   /**
328    * Creates a new scanner
329    *
330    * @param   in  the java.io.Reader to read input from.
331    */
332   public Er7Lexer(java.io.Reader in) {
333     this.zzReader = in;
334   }
335 
336 
337   /** Returns the maximum size of the scanner buffer, which limits the size of tokens. */
338   private int zzMaxBufferLen() {
339     return Integer.MAX_VALUE;
340   }
341 
342   /**  Whether the scanner buffer can grow to accommodate a larger token. */
343   private boolean zzCanGrow() {
344     return true;
345   }
346 
347   /**
348    * Translates raw input code points to DFA table row
349    */
350   private static int zzCMap(int input) {
351     int offset = input & 255;
352     return offset == input ? ZZ_CMAP_BLOCKS[offset] : ZZ_CMAP_BLOCKS[ZZ_CMAP_TOP[input >> 8] | offset];
353   }
354 
355   /**
356    * Refills the input buffer.
357    *
358    * @return {@code false} iff there was new input.
359    * @exception java.io.IOException  if any I/O-Error occurs
360    */
361   private boolean zzRefill() throws java.io.IOException {
362 
363     /* first: make room (if you can) */
364     if (zzStartRead > 0) {
365       zzEndRead += zzFinalHighSurrogate;
366       zzFinalHighSurrogate = 0;
367       System.arraycopy(zzBuffer, zzStartRead,
368                        zzBuffer, 0,
369                        zzEndRead - zzStartRead);
370 
371       /* translate stored positions */
372       zzEndRead -= zzStartRead;
373       zzCurrentPos -= zzStartRead;
374       zzMarkedPos -= zzStartRead;
375       zzStartRead = 0;
376     }
377 
378     /* is the buffer big enough? */
379     if (zzCurrentPos >= zzBuffer.length - zzFinalHighSurrogate && zzCanGrow()) {
380       /* if not, and it can grow: blow it up */
381       char newBuffer[] = new char[Math.min(zzBuffer.length * 2, zzMaxBufferLen())];
382       System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
383       zzBuffer = newBuffer;
384       zzEndRead += zzFinalHighSurrogate;
385       zzFinalHighSurrogate = 0;
386     }
387 
388     /* fill the buffer with new input */
389     int requested = zzBuffer.length - zzEndRead;
390     int numRead = zzReader.read(zzBuffer, zzEndRead, requested);
391 
392     /* not supposed to occur according to specification of java.io.Reader */
393     if (numRead == 0) {
394       if (requested == 0) {
395         throw new java.io.EOFException("Scan buffer limit reached ["+zzBuffer.length+"]");
396       }
397       else {
398         throw new java.io.IOException(
399             "Reader returned 0 characters. See JFlex examples/zero-reader for a workaround.");
400       }
401     }
402     if (numRead > 0) {
403       zzEndRead += numRead;
404       if (Character.isHighSurrogate(zzBuffer[zzEndRead - 1])) {
405         if (numRead == requested) { // We requested too few chars to encode a full Unicode character
406           --zzEndRead;
407           zzFinalHighSurrogate = 1;
408         } else {                    // There is room in the buffer for at least one more char
409           int c = zzReader.read();  // Expecting to read a paired low surrogate char
410           if (c == -1) {
411             return true;
412           } else {
413             zzBuffer[zzEndRead++] = (char)c;
414           }
415         }
416       }
417       /* potentially more input available */
418       return false;
419     }
420 
421     /* numRead < 0 ==> end of stream */
422     return true;
423   }
424 
425 
426   /**
427    * Closes the input reader.
428    *
429    * @throws java.io.IOException if the reader could not be closed.
430    */
431   public final void yyclose() throws java.io.IOException {
432     zzAtEOF = true; // indicate end of file
433     zzEndRead = zzStartRead; // invalidate buffer
434 
435     if (zzReader != null) {
436       zzReader.close();
437     }
438   }
439 
440 
441   /**
442    * Resets the scanner to read from a new input stream.
443    *
444    * <p>Does not close the old reader.
445    *
446    * <p>All internal variables are reset, the old input stream <b>cannot</b> be reused (internal
447    * buffer is discarded and lost). Lexical state is set to {@code ZZ_INITIAL}.
448    *
449    * <p>Internal scan buffer is resized down to its initial length, if it has grown.
450    *
451    * @param reader The new input stream.
452    */
453   public final void yyreset(java.io.Reader reader) {
454     zzReader = reader;
455     zzEOFDone = false;
456     yyResetPosition();
457     zzLexicalState = YYINITIAL;
458     int initBufferSize = Math.min(ZZ_BUFFERSIZE, zzMaxBufferLen());
459     if (zzBuffer.length > initBufferSize) {
460       zzBuffer = new char[initBufferSize];
461     }
462   }
463 
464   /**
465    * Resets the input position.
466    */
467   private final void yyResetPosition() {
468       zzAtBOL  = true;
469       zzAtEOF  = false;
470       zzCurrentPos = 0;
471       zzMarkedPos = 0;
472       zzStartRead = 0;
473       zzEndRead = 0;
474       zzFinalHighSurrogate = 0;
475       yyline = 0;
476       yycolumn = 0;
477       yychar = 0L;
478   }
479 
480 
481   /**
482    * Returns whether the scanner has reached the end of the reader it reads from.
483    *
484    * @return whether the scanner has reached EOF.
485    */
486   public final boolean yyatEOF() {
487     return zzAtEOF;
488   }
489 
490 
491   /**
492    * Returns the current lexical state.
493    *
494    * @return the current lexical state.
495    */
496   public final int yystate() {
497     return zzLexicalState;
498   }
499 
500 
501   /**
502    * Enters a new lexical state.
503    *
504    * @param newState the new lexical state
505    */
506   public final void yybegin(int newState) {
507     zzLexicalState = newState;
508   }
509 
510 
511   /**
512    * Returns the text matched by the current regular expression.
513    *
514    * @return the matched text.
515    */
516   public final String yytext() {
517     return new String(zzBuffer, zzStartRead, zzMarkedPos-zzStartRead);
518   }
519 
520 
521   /**
522    * Returns the character at the given position from the matched text.
523    *
524    * <p>It is equivalent to {@code yytext().charAt(pos)}, but faster.
525    *
526    * @param position the position of the character to fetch. A value from 0 to {@code yylength()-1}.
527    *
528    * @return the character at {@code position}.
529    */
530   public final char yycharat(int position) {
531     return zzBuffer[zzStartRead + position];
532   }
533 
534 
535   /**
536    * How many characters were matched.
537    *
538    * @return the length of the matched text region.
539    */
540   public final int yylength() {
541     return zzMarkedPos-zzStartRead;
542   }
543 
544 
545   /**
546    * Reports an error that occurred while scanning.
547    *
548    * <p>In a well-formed scanner (no or only correct usage of {@code yypushback(int)} and a
549    * match-all fallback rule) this method will only be called with things that
550    * "Can't Possibly Happen".
551    *
552    * <p>If this method is called, something is seriously wrong (e.g. a JFlex bug producing a faulty
553    * scanner etc.).
554    *
555    * <p>Usual syntax/scanner level error handling should be done in error fallback rules.
556    *
557    * @param errorCode the code of the error message to display.
558    */
559   private static void zzScanError(int errorCode) {
560     String message;
561     try {
562       message = ZZ_ERROR_MSG[errorCode];
563     } catch (ArrayIndexOutOfBoundsException e) {
564       message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
565     }
566 
567     throw new Error(message);
568   }
569 
570 
571   /**
572    * Pushes the specified amount of characters back into the input stream.
573    *
574    * <p>They will be read again by then next call of the scanning method.
575    *
576    * @param number the number of characters to be read again. This number must not be greater than
577    *     {@link #yylength()}.
578    */
579   public void yypushback(int number)  {
580     if ( number > yylength() )
581       zzScanError(ZZ_PUSHBACK_2BIG);
582 
583     zzMarkedPos -= number;
584   }
585 
586 
587 
588 
589   /**
590    * Resumes scanning until the next regular expression is matched, the end of input is encountered
591    * or an I/O-Error occurs.
592    *
593    * @return the next token.
594    * @exception java.io.IOException if any I/O-Error occurs.
595    */
596   public Token yylex() throws java.io.IOException
597   {
598     int zzInput;
599     int zzAction;
600 
601     // cached fields:
602     int zzCurrentPosL;
603     int zzMarkedPosL;
604     int zzEndReadL = zzEndRead;
605     char[] zzBufferL = zzBuffer;
606 
607     int [] zzTransL = ZZ_TRANS;
608     int [] zzRowMapL = ZZ_ROWMAP;
609     int [] zzAttrL = ZZ_ATTRIBUTE;
610 
611     while (true) {
612       zzMarkedPosL = zzMarkedPos;
613 
614       yychar+= zzMarkedPosL-zzStartRead;
615 
616       zzAction = -1;
617 
618       zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
619 
620       zzState = ZZ_LEXSTATE[zzLexicalState];
621 
622       // set up zzAction for empty match case:
623       int zzAttributes = zzAttrL[zzState];
624       if ( (zzAttributes & 1) == 1 ) {
625         zzAction = zzState;
626       }
627 
628 
629       zzForAction: {
630         while (true) {
631 
632           if (zzCurrentPosL < zzEndReadL) {
633             zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL);
634             zzCurrentPosL += Character.charCount(zzInput);
635           }
636           else if (zzAtEOF) {
637             zzInput = YYEOF;
638             break zzForAction;
639           }
640           else {
641             // store back cached positions
642             zzCurrentPos  = zzCurrentPosL;
643             zzMarkedPos   = zzMarkedPosL;
644             boolean eof = zzRefill();
645             // get translated positions and possibly new buffer
646             zzCurrentPosL  = zzCurrentPos;
647             zzMarkedPosL   = zzMarkedPos;
648             zzBufferL      = zzBuffer;
649             zzEndReadL     = zzEndRead;
650             if (eof) {
651               zzInput = YYEOF;
652               break zzForAction;
653             }
654             else {
655               zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL);
656               zzCurrentPosL += Character.charCount(zzInput);
657             }
658           }
659           int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMap(zzInput) ];
660           if (zzNext == -1) break zzForAction;
661           zzState = zzNext;
662 
663           zzAttributes = zzAttrL[zzState];
664           if ( (zzAttributes & 1) == 1 ) {
665             zzAction = zzState;
666             zzMarkedPosL = zzCurrentPosL;
667             if ( (zzAttributes & 8) == 8 ) break zzForAction;
668           }
669 
670         }
671       }
672 
673       // store back cached position
674       zzMarkedPos = zzMarkedPosL;
675 
676       if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
677         zzAtEOF = true;
678               {
679                 return null;
680               }
681       }
682       else {
683         switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
684           case 1:
685             { return token(TokenType.OPERATOR);
686             }
687           // fall through
688           case 10: break;
689           case 2:
690             { return token(TokenType.COMMENT);
691             }
692           // fall through
693           case 11: break;
694           case 3:
695             { yybegin(AT_START_OF_VALUE); return token(TokenType.TYPE);
696             }
697           // fall through
698           case 12: break;
699           case 4:
700             { yybegin(WITHIN_VALUE); return token(TokenType.DEFAULT);
701             }
702           // fall through
703           case 13: break;
704           case 5:
705             { yybegin(YYINITIAL); return token(TokenType.DEFAULT);
706             }
707           // fall through
708           case 14: break;
709           case 6:
710             { yybegin(YYINITIAL); return token(TokenType.TYPE2);
711             }
712           // fall through
713           case 15: break;
714           case 7:
715             { yypushback(1); yybegin(AT_DELIM); return token(TokenType.TYPE2);
716             }
717           // fall through
718           case 16: break;
719           case 8:
720             { return token(TokenType.KEYWORD);
721             }
722           // fall through
723           case 17: break;
724           case 9:
725             { return token(TokenType.TYPE3);
726             }
727           // fall through
728           case 18: break;
729           default:
730             zzScanError(ZZ_NO_MATCH);
731         }
732       }
733     }
734   }
735 
736 
737 }