]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/documentation/DocumentationLexer.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / parsing / documentation / DocumentationLexer.java
1 /* The following code was generated by JFlex 1.4.3 on 26.5.2013 19:20 */
2
3 package org.simantics.scl.compiler.internal.parsing.documentation;
4
5
6 /**
7  * This class is a scanner generated by 
8  * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
9  * on 26.5.2013 19:20 from the specification file
10  * <tt>C:/Documents and Settings/Hannu/git/scl/org.simantics.scl.compiler/src/org/simantics/scl/compiler/parsing/documentation/DocumentationLexer.flex</tt>
11  */
12 public class DocumentationLexer {
13
14   /** This character denotes the end of file */
15   public static final int YYEOF = -1;
16
17   /** initial size of the lookahead buffer */
18   private static final int ZZ_BUFFERSIZE = 16384;
19
20   /** lexical states */
21   public static final int YYINITIAL = 0;
22
23   /**
24    * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
25    * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
26    *                  at the beginning of a line
27    * l is of the form l = 2*k, k a non negative integer
28    */
29   private static final int ZZ_LEXSTATE[] = { 
30      0, 0
31   };
32
33   /** 
34    * Translates characters to character classes
35    */
36   private static final String ZZ_CMAP_PACKED = 
37     "\11\0\1\1\1\2\2\0\1\3\22\0\1\5\2\0\1\0\6\0"+
38     "\1\7\2\0\1\4\17\0\1\6\1\10\uffc1\0";
39
40   /** 
41    * Translates characters to character classes
42    */
43   private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
44
45   /** 
46    * Translates DFA states to action switch labels.
47    */
48   private static final int [] ZZ_ACTION = zzUnpackAction();
49
50   private static final String ZZ_ACTION_PACKED_0 =
51     "\1\0\1\1\2\2\2\1\1\2\3\1\1\0\1\3"+
52     "\2\0\1\4\4\0\1\5\2\0\1\6\11\0\1\7"+
53     "\6\0\1\10\4\0\1\11\1\0";
54
55   private static int [] zzUnpackAction() {
56     int [] result = new int[46];
57     int offset = 0;
58     offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
59     return result;
60   }
61
62   private static int zzUnpackAction(String packed, int offset, int [] result) {
63     int i = 0;       /* index in packed string  */
64     int j = offset;  /* index in unpacked array */
65     int l = packed.length();
66     while (i < l) {
67       int count = packed.charAt(i++);
68       int value = packed.charAt(i++);
69       do result[j++] = value; while (--count > 0);
70     }
71     return j;
72   }
73
74
75   /** 
76    * Translates a state to a row index in the transition table
77    */
78   private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
79
80   private static final String ZZ_ROWMAP_PACKED_0 =
81     "\0\0\0\11\0\22\0\33\0\44\0\55\0\66\0\77"+
82     "\0\110\0\121\0\11\0\132\0\143\0\55\0\33\0\154"+
83     "\0\165\0\176\0\110\0\33\0\207\0\121\0\220\0\231"+
84     "\0\132\0\242\0\253\0\264\0\275\0\306\0\317\0\330"+
85     "\0\33\0\341\0\352\0\363\0\374\0\u0105\0\u010e\0\33"+
86     "\0\u0117\0\u0120\0\u0129\0\u0132\0\33\0\u013b";
87
88   private static int [] zzUnpackRowMap() {
89     int [] result = new int[46];
90     int offset = 0;
91     offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
92     return result;
93   }
94
95   private static int zzUnpackRowMap(String packed, int offset, int [] result) {
96     int i = 0;  /* index in packed string  */
97     int j = offset;  /* index in unpacked array */
98     int l = packed.length();
99     while (i < l) {
100       int high = packed.charAt(i++) << 16;
101       result[j++] = high | packed.charAt(i++);
102     }
103     return j;
104   }
105
106   /** 
107    * The transition table of the DFA
108    */
109   private static final int [] ZZ_TRANS = zzUnpackTrans();
110
111   private static final String ZZ_TRANS_PACKED_0 =
112     "\1\2\1\3\1\4\1\5\1\6\1\7\1\10\1\11"+
113     "\1\12\2\13\1\14\1\15\6\13\1\3\1\14\1\15"+
114     "\1\13\1\3\3\13\13\0\1\4\6\0\2\16\1\17"+
115     "\1\20\5\16\1\13\1\3\3\0\1\7\3\0\2\21"+
116     "\2\0\2\21\1\22\2\21\2\23\1\24\1\25\5\23"+
117     "\2\26\1\27\1\30\5\26\2\13\3\0\1\31\5\0"+
118     "\1\14\10\0\1\17\6\0\2\32\2\0\2\32\1\21"+
119     "\2\32\2\33\2\0\2\33\1\34\2\33\2\0\1\24"+
120     "\16\0\1\26\2\0\1\27\6\0\2\32\2\0\2\32"+
121     "\1\35\2\32\2\36\2\0\2\36\1\33\2\36\2\37"+
122     "\2\0\2\37\1\0\2\37\1\32\1\40\1\41\1\42"+
123     "\1\32\1\40\1\21\2\32\2\36\2\0\2\36\1\43"+
124     "\2\36\2\44\2\0\2\44\1\37\2\44\1\32\1\40"+
125     "\1\41\1\42\1\32\1\40\1\35\2\32\2\0\1\41"+
126     "\6\0\2\36\2\0\2\36\1\45\2\36\2\44\2\0"+
127     "\2\44\1\46\2\44\1\36\1\47\1\50\1\51\1\36"+
128     "\1\47\1\33\2\36\2\44\2\0\2\44\1\52\2\44"+
129     "\1\36\1\47\1\50\1\51\1\36\1\47\1\43\2\36"+
130     "\2\0\1\50\6\0\2\44\2\0\2\44\1\53\3\44"+
131     "\1\54\1\55\1\56\1\44\1\54\1\37\3\44\1\54"+
132     "\1\55\1\56\1\44\1\54\1\46\2\44\2\0\1\55"+
133     "\6\0";
134
135   private static int [] zzUnpackTrans() {
136     int [] result = new int[324];
137     int offset = 0;
138     offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
139     return result;
140   }
141
142   private static int zzUnpackTrans(String packed, int offset, int [] result) {
143     int i = 0;       /* index in packed string  */
144     int j = offset;  /* index in unpacked array */
145     int l = packed.length();
146     while (i < l) {
147       int count = packed.charAt(i++);
148       int value = packed.charAt(i++);
149       value--;
150       do result[j++] = value; while (--count > 0);
151     }
152     return j;
153   }
154
155
156   /* error codes */
157   private static final int ZZ_UNKNOWN_ERROR = 0;
158   private static final int ZZ_NO_MATCH = 1;
159   private static final int ZZ_PUSHBACK_2BIG = 2;
160
161   /* error messages for the codes above */
162   private static final String ZZ_ERROR_MSG[] = {
163     "Unkown internal scanner error",
164     "Error: could not match input",
165     "Error: pushback value was too large"
166   };
167
168   /**
169    * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
170    */
171   private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
172
173   private static final String ZZ_ATTRIBUTE_PACKED_0 =
174     "\1\0\2\1\1\11\6\1\1\0\1\1\2\0\1\11"+
175     "\4\0\1\11\2\0\1\1\11\0\1\11\6\0\1\11"+
176     "\4\0\1\11\1\0";
177
178   private static int [] zzUnpackAttribute() {
179     int [] result = new int[46];
180     int offset = 0;
181     offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
182     return result;
183   }
184
185   private static int zzUnpackAttribute(String packed, int offset, int [] result) {
186     int i = 0;       /* index in packed string  */
187     int j = offset;  /* index in unpacked array */
188     int l = packed.length();
189     while (i < l) {
190       int count = packed.charAt(i++);
191       int value = packed.charAt(i++);
192       do result[j++] = value; while (--count > 0);
193     }
194     return j;
195   }
196
197   /** the input device */
198   private java.io.Reader zzReader;
199
200   /** the current state of the DFA */
201   private int zzState;
202
203   /** the current lexical state */
204   private int zzLexicalState = YYINITIAL;
205
206   /** this buffer contains the current text to be matched and is
207       the source of the yytext() string */
208   private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
209
210   /** the textposition at the last accepting state */
211   private int zzMarkedPos;
212
213   /** the current text position in the buffer */
214   private int zzCurrentPos;
215
216   /** startRead marks the beginning of the yytext() string in the buffer */
217   private int zzStartRead;
218
219   /** endRead marks the last character in the buffer, that has been read
220       from input */
221   private int zzEndRead;
222
223   /** number of newlines encountered up to the start of the matched text */
224   private int yyline;
225
226   /** the number of characters up to the start of the matched text */
227   private int yychar;
228
229   /**
230    * the number of characters from the last newline up to the start of the 
231    * matched text
232    */
233   private int yycolumn;
234
235   /** 
236    * zzAtBOL == true <=> the scanner is currently at the beginning of a line
237    */
238   private boolean zzAtBOL = true;
239
240   /** zzAtEOF == true <=> the scanner is at the EOF */
241   private boolean zzAtEOF;
242
243   /** denotes if the user-EOF-code has already been executed */
244   private boolean zzEOFDone;
245
246   /* user code: */
247     public static String trimW(String text) {
248         int a = 0, b = text.length();
249         while(a < b) {
250             char c = text.charAt(a);
251             if(c != ' ' && c != '\t' && c != '\r' && c != '\n')
252                 break;
253             ++a;
254         }
255         while(a < b) {
256             char c = text.charAt(b-1);
257             if(c != ' ' && c != '\t' && c != '\r' && c != '\n')
258                 break;
259             --b;
260         }
261         return text.substring(a, b);
262     }
263
264     public static String trimN(String text, int amount) {        
265         text = trimW(text);
266         return text.substring(amount, text.length()-amount).trim();
267     }
268
269
270   /**
271    * Creates a new scanner
272    * There is also a java.io.InputStream version of this constructor.
273    *
274    * @param   in  the java.io.Reader to read input from.
275    */
276   public DocumentationLexer(java.io.Reader in) {
277     this.zzReader = in;
278   }
279
280   /**
281    * Creates a new scanner.
282    * There is also java.io.Reader version of this constructor.
283    *
284    * @param   in  the java.io.Inputstream to read input from.
285    */
286   public DocumentationLexer(java.io.InputStream in) {
287     this(new java.io.InputStreamReader(in));
288   }
289
290   /** 
291    * Unpacks the compressed character translation table.
292    *
293    * @param packed   the packed character translation table
294    * @return         the unpacked character translation table
295    */
296   private static char [] zzUnpackCMap(String packed) {
297     char [] map = new char[0x10000];
298     int i = 0;  /* index in packed string  */
299     int j = 0;  /* index in unpacked array */
300     while (i < 34) {
301       int  count = packed.charAt(i++);
302       char value = packed.charAt(i++);
303       do map[j++] = value; while (--count > 0);
304     }
305     return map;
306   }
307
308
309   /**
310    * Refills the input buffer.
311    *
312    * @return      <code>false</code>, iff there was new input.
313    * 
314    * @exception   java.io.IOException  if any I/O-Error occurs
315    */
316   private boolean zzRefill() throws java.io.IOException {
317
318     /* first: make room (if you can) */
319     if (zzStartRead > 0) {
320       System.arraycopy(zzBuffer, zzStartRead,
321                        zzBuffer, 0,
322                        zzEndRead-zzStartRead);
323
324       /* translate stored positions */
325       zzEndRead-= zzStartRead;
326       zzCurrentPos-= zzStartRead;
327       zzMarkedPos-= zzStartRead;
328       zzStartRead = 0;
329     }
330
331     /* is the buffer big enough? */
332     if (zzCurrentPos >= zzBuffer.length) {
333       /* if not: blow it up */
334       char newBuffer[] = new char[zzCurrentPos*2];
335       System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
336       zzBuffer = newBuffer;
337     }
338
339     /* finally: fill the buffer with new input */
340     int numRead = zzReader.read(zzBuffer, zzEndRead,
341                                             zzBuffer.length-zzEndRead);
342
343     if (numRead > 0) {
344       zzEndRead+= numRead;
345       return false;
346     }
347     // unlikely but not impossible: read 0 characters, but not at end of stream    
348     if (numRead == 0) {
349       int c = zzReader.read();
350       if (c == -1) {
351         return true;
352       } else {
353         zzBuffer[zzEndRead++] = (char) c;
354         return false;
355       }     
356     }
357
358         // numRead < 0
359     return true;
360   }
361
362     
363   /**
364    * Closes the input stream.
365    */
366   public final void yyclose() throws java.io.IOException {
367     zzAtEOF = true;            /* indicate end of file */
368     zzEndRead = zzStartRead;  /* invalidate buffer    */
369
370     if (zzReader != null)
371       zzReader.close();
372   }
373
374
375   /**
376    * Resets the scanner to read from a new input stream.
377    * Does not close the old reader.
378    *
379    * All internal variables are reset, the old input stream 
380    * <b>cannot</b> be reused (internal buffer is discarded and lost).
381    * Lexical state is set to <tt>ZZ_INITIAL</tt>.
382    *
383    * @param reader   the new input stream 
384    */
385   public final void yyreset(java.io.Reader reader) {
386     zzReader = reader;
387     zzAtBOL  = true;
388     zzAtEOF  = false;
389     zzEOFDone = false;
390     zzEndRead = zzStartRead = 0;
391     zzCurrentPos = zzMarkedPos = 0;
392     yyline = yychar = yycolumn = 0;
393     zzLexicalState = YYINITIAL;
394   }
395
396
397   /**
398    * Returns the current lexical state.
399    */
400   public final int yystate() {
401     return zzLexicalState;
402   }
403
404
405   /**
406    * Enters a new lexical state
407    *
408    * @param newState the new lexical state
409    */
410   public final void yybegin(int newState) {
411     zzLexicalState = newState;
412   }
413
414
415   /**
416    * Returns the text matched by the current regular expression.
417    */
418   public final String yytext() {
419     return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
420   }
421
422
423   /**
424    * Returns the character at position <tt>pos</tt> from the 
425    * matched text. 
426    * 
427    * It is equivalent to yytext().charAt(pos), but faster
428    *
429    * @param pos the position of the character to fetch. 
430    *            A value from 0 to yylength()-1.
431    *
432    * @return the character at position pos
433    */
434   public final char yycharat(int pos) {
435     return zzBuffer[zzStartRead+pos];
436   }
437
438
439   /**
440    * Returns the length of the matched text region.
441    */
442   public final int yylength() {
443     return zzMarkedPos-zzStartRead;
444   }
445
446
447   /**
448    * Reports an error that occured while scanning.
449    *
450    * In a wellformed scanner (no or only correct usage of 
451    * yypushback(int) and a match-all fallback rule) this method 
452    * will only be called with things that "Can't Possibly Happen".
453    * If this method is called, something is seriously wrong
454    * (e.g. a JFlex bug producing a faulty scanner etc.).
455    *
456    * Usual syntax/scanner level error handling should be done
457    * in error fallback rules.
458    *
459    * @param   errorCode  the code of the errormessage to display
460    */
461   private void zzScanError(int errorCode) {
462     String message;
463     try {
464       message = ZZ_ERROR_MSG[errorCode];
465     }
466     catch (ArrayIndexOutOfBoundsException e) {
467       message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
468     }
469
470     throw new Error(message);
471   } 
472
473
474   /**
475    * Pushes the specified amount of characters back into the input stream.
476    *
477    * They will be read again by then next call of the scanning method
478    *
479    * @param number  the number of characters to be read again.
480    *                This number must not be greater than yylength()!
481    */
482   public void yypushback(int number)  {
483     if ( number > yylength() )
484       zzScanError(ZZ_PUSHBACK_2BIG);
485
486     zzMarkedPos -= number;
487   }
488
489
490   /**
491    * Resumes scanning until the next regular expression is matched,
492    * the end of input is encountered or an I/O-Error occurs.
493    *
494    * @return      the next token
495    * @exception   java.io.IOException  if any I/O-Error occurs
496    */
497   public DocumentationElement nextToken() throws java.io.IOException, DocumentationParsingException {
498     int zzInput;
499     int zzAction;
500
501     // cached fields:
502     int zzCurrentPosL;
503     int zzMarkedPosL;
504     int zzEndReadL = zzEndRead;
505     char [] zzBufferL = zzBuffer;
506     char [] zzCMapL = ZZ_CMAP;
507
508     int [] zzTransL = ZZ_TRANS;
509     int [] zzRowMapL = ZZ_ROWMAP;
510     int [] zzAttrL = ZZ_ATTRIBUTE;
511
512     while (true) {
513       zzMarkedPosL = zzMarkedPos;
514
515       yychar+= zzMarkedPosL-zzStartRead;
516
517       zzAction = -1;
518
519       zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
520   
521       zzState = ZZ_LEXSTATE[zzLexicalState];
522
523
524       zzForAction: {
525         while (true) {
526     
527           if (zzCurrentPosL < zzEndReadL)
528             zzInput = zzBufferL[zzCurrentPosL++];
529           else if (zzAtEOF) {
530             zzInput = YYEOF;
531             break zzForAction;
532           }
533           else {
534             // store back cached positions
535             zzCurrentPos  = zzCurrentPosL;
536             zzMarkedPos   = zzMarkedPosL;
537             boolean eof = zzRefill();
538             // get translated positions and possibly new buffer
539             zzCurrentPosL  = zzCurrentPos;
540             zzMarkedPosL   = zzMarkedPos;
541             zzBufferL      = zzBuffer;
542             zzEndReadL     = zzEndRead;
543             if (eof) {
544               zzInput = YYEOF;
545               break zzForAction;
546             }
547             else {
548               zzInput = zzBufferL[zzCurrentPosL++];
549             }
550           }
551           int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
552           if (zzNext == -1) break zzForAction;
553           zzState = zzNext;
554
555           int zzAttributes = zzAttrL[zzState];
556           if ( (zzAttributes & 1) == 1 ) {
557             zzAction = zzState;
558             zzMarkedPosL = zzCurrentPosL;
559             if ( (zzAttributes & 8) == 8 ) break zzForAction;
560           }
561
562         }
563       }
564
565       // store back cached position
566       zzMarkedPos = zzMarkedPosL;
567
568       switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
569         case 4: 
570           { return new EntityRef(trimW(yytext().substring(1)));
571           }
572         case 10: break;
573         case 8: 
574           { return new Header(2, trimN(yytext(), 2));
575           }
576         case 11: break;
577         case 7: 
578           { return new Header(1, trimN(yytext(), 1));
579           }
580         case 12: break;
581         case 3: 
582           { return new Paragraph(yytext().trim());
583           }
584         case 13: break;
585         case 9: 
586           { return new Header(3, trimN(yytext(), 3));
587           }
588         case 14: break;
589         case 1: 
590           { System.err.println("At " + yychar + ": Illegal character '" + yytext() + "'.");
591           }
592         case 15: break;
593         case 5: 
594           { return new ListItem(trimW(yytext()));
595           }
596         case 16: break;
597         case 6: 
598           { return new Preformatted(yytext());
599           }
600         case 17: break;
601         case 2: 
602           { 
603           }
604         case 18: break;
605         default: 
606           if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
607             zzAtEOF = true;
608               {     return null;
609  }
610           } 
611           else {
612             zzScanError(ZZ_NO_MATCH);
613           }
614       }
615     }
616   }
617
618
619 }