Perfecting parser, lexer, and parse-tree handling for policy files; Generating skelet...
[iot2.git] / iotjava / iotpolicy / parser / Lexer.java
1 package iotpolicy.parser;
2
3 /* The following code was generated by JFlex 1.6.1 */
4
5 // JFlex parser specification written by
6 // Rahmadi Trimananda
7 // for Sentinel system
8 // University of California, Irvine
9
10 // Technische Universitaet Muenchen 
11 // Fakultaet fuer Informatik 
12
13 import java_cup.runtime.Symbol;
14 import java_cup.runtime.ComplexSymbolFactory;
15 import java_cup.runtime.ComplexSymbolFactory.Location;
16
17
18 /**
19  * This class is a scanner generated by 
20  * <a href="http://www.jflex.de/">JFlex</a> 1.6.1
21  * from the specification file <tt>iotparser.jflex</tt>
22  */
23 public class Lexer implements java_cup.runtime.Scanner, sym {
24
25   /** This character denotes the end of file */
26   public static final int YYEOF = -1;
27
28   /** initial size of the lookahead buffer */
29   private static final int ZZ_BUFFERSIZE = 16384;
30
31   /** lexical states */
32   public static final int YYINITIAL = 0;
33   public static final int STRING = 2;
34
35   /**
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
40    */
41   private static final int ZZ_LEXSTATE[] = { 
42      0,  0,  1, 1
43   };
44
45   /** 
46    * Translates characters to character classes
47    */
48   private static final String ZZ_CMAP_PACKED = 
49     "\11\0\1\6\1\4\1\47\1\6\1\3\22\0\1\6\1\0\1\36"+
50     "\1\0\1\1\3\0\1\41\1\42\2\0\1\37\1\0\1\40\1\0"+
51     "\12\2\1\0\1\5\1\0\1\45\3\0\22\1\1\30\7\1\1\0"+
52     "\1\46\2\0\1\1\1\0\1\24\1\16\1\27\1\25\1\20\1\23"+
53     "\1\22\1\13\1\7\2\1\1\21\1\33\1\10\1\14\1\32\1\34"+
54     "\1\15\1\12\1\11\1\26\1\31\1\35\1\1\1\17\1\1\1\43"+
55     "\1\0\1\44\7\0\1\47\u1fa2\0\1\47\1\47\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\udfe6\0";
56
57   /** 
58    * Translates characters to character classes
59    */
60   private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
61
62   /** 
63    * Translates DFA states to action switch labels.
64    */
65   private static final int [] ZZ_ACTION = zzUnpackAction();
66
67   private static final String ZZ_ACTION_PACKED_0 =
68     "\2\0\1\1\1\2\2\3\1\4\16\2\1\5\1\6"+
69     "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\1\16"+
70     "\1\17\1\0\10\2\1\20\11\2\1\21\1\22\1\23"+
71     "\1\24\1\25\25\2\1\26\1\27\3\2\1\30\2\2"+
72     "\1\31\2\2\1\32\2\2\1\33\2\2\1\34\7\2"+
73     "\1\35\2\2\1\36\2\2\1\37\1\40\1\41\2\2"+
74     "\1\42\3\2\1\43\2\2\1\44\3\2\1\45\1\46";
75
76   private static int [] zzUnpackAction() {
77     int [] result = new int[126];
78     int offset = 0;
79     offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
80     return result;
81   }
82
83   private static int zzUnpackAction(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();
87     while (i < l) {
88       int count = packed.charAt(i++);
89       int value = packed.charAt(i++);
90       do result[j++] = value; while (--count > 0);
91     }
92     return j;
93   }
94
95
96   /** 
97    * Translates a state to a row index in the transition table
98    */
99   private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
100
101   private static final String ZZ_ROWMAP_PACKED_0 =
102     "\0\0\0\50\0\120\0\170\0\240\0\120\0\120\0\310"+
103     "\0\360\0\u0118\0\u0140\0\u0168\0\u0190\0\u01b8\0\u01e0\0\u0208"+
104     "\0\u0230\0\u0258\0\u0280\0\u02a8\0\u02d0\0\120\0\120\0\120"+
105     "\0\120\0\120\0\120\0\120\0\120\0\u02f8\0\120\0\u0320"+
106     "\0\u0348\0\u0370\0\u0398\0\u03c0\0\u03e8\0\u0410\0\u0438\0\u0460"+
107     "\0\u0488\0\170\0\u04b0\0\u04d8\0\u0500\0\u0528\0\u0550\0\u0578"+
108     "\0\u05a0\0\u05c8\0\u05f0\0\120\0\120\0\120\0\120\0\u0618"+
109     "\0\u0640\0\u0668\0\u0690\0\u06b8\0\u06e0\0\u0708\0\u0730\0\u0758"+
110     "\0\u0780\0\u07a8\0\u07d0\0\u07f8\0\u0820\0\u0848\0\u0870\0\u0898"+
111     "\0\u08c0\0\u08e8\0\u0910\0\u0938\0\u0960\0\170\0\170\0\u0988"+
112     "\0\u09b0\0\u09d8\0\170\0\u0a00\0\u0a28\0\170\0\u0a50\0\u0a78"+
113     "\0\170\0\u0aa0\0\u0ac8\0\170\0\u0af0\0\u0b18\0\170\0\u0b40"+
114     "\0\u0b68\0\u0b90\0\u0bb8\0\u0be0\0\u0c08\0\u0c30\0\170\0\u0c58"+
115     "\0\u0c80\0\170\0\u0ca8\0\u0cd0\0\170\0\170\0\170\0\u0cf8"+
116     "\0\u0d20\0\170\0\u0d48\0\u0d70\0\u0d98\0\170\0\u0dc0\0\u0de8"+
117     "\0\170\0\u0e10\0\u0e38\0\u0e60\0\170\0\170";
118
119   private static int [] zzUnpackRowMap() {
120     int [] result = new int[126];
121     int offset = 0;
122     offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
123     return result;
124   }
125
126   private static int zzUnpackRowMap(String packed, int offset, int [] result) {
127     int i = 0;  /* index in packed string  */
128     int j = offset;  /* index in unpacked array */
129     int l = packed.length();
130     while (i < l) {
131       int high = packed.charAt(i++) << 16;
132       result[j++] = high | packed.charAt(i++);
133     }
134     return j;
135   }
136
137   /** 
138    * The transition table of the DFA
139    */
140   private static final int [] ZZ_TRANS = zzUnpackTrans();
141
142   private static final String ZZ_TRANS_PACKED_0 =
143     "\1\3\1\4\1\3\1\5\1\6\1\7\1\6\1\10"+
144     "\2\4\1\11\2\4\1\12\1\13\2\4\1\14\1\4"+
145     "\1\15\1\16\1\17\1\4\1\20\1\21\1\22\1\23"+
146     "\1\24\1\4\1\25\1\26\1\27\1\30\1\31\1\32"+
147     "\1\33\1\34\1\35\1\3\1\0\3\36\1\0\1\3"+
148     "\31\36\1\37\7\36\1\40\1\36\51\0\2\4\4\0"+
149     "\27\4\16\0\1\41\44\0\2\4\4\0\1\4\1\42"+
150     "\25\4\13\0\2\4\4\0\2\4\1\43\1\4\1\44"+
151     "\22\4\13\0\2\4\4\0\11\4\1\45\15\4\13\0"+
152     "\2\4\4\0\5\4\1\46\2\4\1\47\16\4\13\0"+
153     "\2\4\4\0\5\4\1\50\21\4\13\0\2\4\4\0"+
154     "\12\4\1\51\14\4\13\0\2\4\4\0\3\4\1\52"+
155     "\23\4\13\0\2\4\4\0\5\4\1\53\3\4\1\54"+
156     "\15\4\13\0\2\4\4\0\4\4\1\55\10\4\1\56"+
157     "\11\4\13\0\2\4\4\0\2\4\1\57\24\4\13\0"+
158     "\2\4\4\0\5\4\1\60\21\4\13\0\2\4\4\0"+
159     "\17\4\1\61\7\4\13\0\2\4\4\0\11\4\1\62"+
160     "\15\4\13\0\2\4\4\0\1\63\26\4\12\0\3\36"+
161     "\2\0\31\36\1\0\7\36\1\0\1\36\10\0\1\64"+
162     "\1\65\3\0\1\66\20\0\1\67\16\0\1\6\43\0"+
163     "\2\4\4\0\2\4\1\70\24\4\13\0\2\4\4\0"+
164     "\6\4\1\71\20\4\13\0\2\4\4\0\5\4\1\72"+
165     "\21\4\13\0\2\4\4\0\25\4\1\73\1\4\13\0"+
166     "\2\4\4\0\5\4\1\74\21\4\13\0\2\4\4\0"+
167     "\2\4\1\75\24\4\13\0\2\4\4\0\1\4\1\76"+
168     "\25\4\13\0\2\4\4\0\5\4\1\77\21\4\13\0"+
169     "\2\4\4\0\17\4\1\100\7\4\13\0\2\4\4\0"+
170     "\3\4\1\101\23\4\13\0\2\4\4\0\15\4\1\102"+
171     "\11\4\13\0\2\4\4\0\23\4\1\103\3\4\13\0"+
172     "\2\4\4\0\6\4\1\104\20\4\13\0\2\4\4\0"+
173     "\1\105\26\4\13\0\2\4\4\0\7\4\1\106\17\4"+
174     "\13\0\2\4\4\0\2\4\1\107\24\4\13\0\2\4"+
175     "\4\0\2\4\1\110\24\4\13\0\2\4\4\0\11\4"+
176     "\1\111\15\4\13\0\2\4\4\0\1\112\26\4\13\0"+
177     "\2\4\4\0\6\4\1\113\20\4\13\0\2\4\4\0"+
178     "\17\4\1\114\7\4\13\0\2\4\4\0\12\4\1\115"+
179     "\14\4\13\0\2\4\4\0\11\4\1\116\15\4\13\0"+
180     "\2\4\4\0\13\4\1\117\13\4\13\0\2\4\4\0"+
181     "\15\4\1\120\11\4\13\0\2\4\4\0\7\4\1\121"+
182     "\17\4\13\0\2\4\4\0\20\4\1\122\6\4\13\0"+
183     "\2\4\4\0\6\4\1\123\20\4\13\0\2\4\4\0"+
184     "\15\4\1\124\11\4\13\0\2\4\4\0\1\125\26\4"+
185     "\13\0\2\4\4\0\16\4\1\126\10\4\13\0\2\4"+
186     "\4\0\12\4\1\127\14\4\13\0\2\4\4\0\4\4"+
187     "\1\130\22\4\13\0\2\4\4\0\4\4\1\131\22\4"+
188     "\13\0\2\4\4\0\6\4\1\132\20\4\13\0\2\4"+
189     "\4\0\1\4\1\133\25\4\13\0\2\4\4\0\2\4"+
190     "\1\134\24\4\13\0\2\4\4\0\1\135\26\4\13\0"+
191     "\2\4\4\0\11\4\1\136\15\4\13\0\2\4\4\0"+
192     "\2\4\1\137\24\4\13\0\2\4\4\0\12\4\1\140"+
193     "\14\4\13\0\2\4\4\0\6\4\1\141\20\4\13\0"+
194     "\2\4\4\0\7\4\1\142\17\4\13\0\2\4\4\0"+
195     "\1\4\1\143\25\4\13\0\2\4\4\0\1\144\26\4"+
196     "\13\0\2\4\4\0\5\4\1\145\21\4\13\0\2\4"+
197     "\4\0\14\4\1\146\12\4\13\0\2\4\4\0\13\4"+
198     "\1\147\13\4\13\0\2\4\4\0\6\4\1\150\20\4"+
199     "\13\0\2\4\4\0\15\4\1\151\11\4\13\0\2\4"+
200     "\4\0\11\4\1\152\15\4\13\0\2\4\4\0\1\153"+
201     "\26\4\13\0\2\4\4\0\1\154\26\4\13\0\2\4"+
202     "\4\0\13\4\1\155\13\4\13\0\2\4\4\0\20\4"+
203     "\1\156\6\4\13\0\2\4\4\0\16\4\1\157\10\4"+
204     "\13\0\2\4\4\0\15\4\1\160\11\4\13\0\2\4"+
205     "\4\0\11\4\1\161\15\4\13\0\2\4\4\0\1\4"+
206     "\1\162\25\4\13\0\2\4\4\0\23\4\1\163\3\4"+
207     "\13\0\2\4\4\0\12\4\1\164\14\4\13\0\2\4"+
208     "\4\0\20\4\1\165\6\4\13\0\2\4\4\0\3\4"+
209     "\1\166\23\4\13\0\2\4\4\0\2\4\1\167\24\4"+
210     "\13\0\2\4\4\0\1\170\26\4\13\0\2\4\4\0"+
211     "\11\4\1\171\15\4\13\0\2\4\4\0\1\172\26\4"+
212     "\13\0\2\4\4\0\2\4\1\173\24\4\13\0\2\4"+
213     "\4\0\5\4\1\174\21\4\13\0\2\4\4\0\10\4"+
214     "\1\175\16\4\13\0\2\4\4\0\1\4\1\176\25\4"+
215     "\12\0";
216
217   private static int [] zzUnpackTrans() {
218     int [] result = new int[3720];
219     int offset = 0;
220     offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
221     return result;
222   }
223
224   private static int zzUnpackTrans(String packed, int offset, int [] result) {
225     int i = 0;       /* index in packed string  */
226     int j = offset;  /* index in unpacked array */
227     int l = packed.length();
228     while (i < l) {
229       int count = packed.charAt(i++);
230       int value = packed.charAt(i++);
231       value--;
232       do result[j++] = value; while (--count > 0);
233     }
234     return j;
235   }
236
237
238   /* error codes */
239   private static final int ZZ_UNKNOWN_ERROR = 0;
240   private static final int ZZ_NO_MATCH = 1;
241   private static final int ZZ_PUSHBACK_2BIG = 2;
242
243   /* error messages for the codes above */
244   private static final String ZZ_ERROR_MSG[] = {
245     "Unknown internal scanner error",
246     "Error: could not match input",
247     "Error: pushback value was too large"
248   };
249
250   /**
251    * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
252    */
253   private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
254
255   private static final String ZZ_ATTRIBUTE_PACKED_0 =
256     "\2\0\1\11\2\1\2\11\16\1\10\11\1\1\1\11"+
257     "\1\1\1\0\22\1\4\11\107\1";
258
259   private static int [] zzUnpackAttribute() {
260     int [] result = new int[126];
261     int offset = 0;
262     offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
263     return result;
264   }
265
266   private static int zzUnpackAttribute(String packed, int offset, int [] result) {
267     int i = 0;       /* index in packed string  */
268     int j = offset;  /* index in unpacked array */
269     int l = packed.length();
270     while (i < l) {
271       int count = packed.charAt(i++);
272       int value = packed.charAt(i++);
273       do result[j++] = value; while (--count > 0);
274     }
275     return j;
276   }
277
278   /** the input device */
279   private java.io.Reader zzReader;
280
281   /** the current state of the DFA */
282   private int zzState;
283
284   /** the current lexical state */
285   private int zzLexicalState = YYINITIAL;
286
287   /** this buffer contains the current text to be matched and is
288       the source of the yytext() string */
289   private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
290
291   /** the textposition at the last accepting state */
292   private int zzMarkedPos;
293
294   /** the current text position in the buffer */
295   private int zzCurrentPos;
296
297   /** startRead marks the beginning of the yytext() string in the buffer */
298   private int zzStartRead;
299
300   /** endRead marks the last character in the buffer, that has been read
301       from input */
302   private int zzEndRead;
303
304   /** number of newlines encountered up to the start of the matched text */
305   private int yyline;
306
307   /** the number of characters up to the start of the matched text */
308   private int yychar;
309
310   /**
311    * the number of characters from the last newline up to the start of the 
312    * matched text
313    */
314   private int yycolumn;
315
316   /** 
317    * zzAtBOL == true <=> the scanner is currently at the beginning of a line
318    */
319   private boolean zzAtBOL = true;
320
321   /** zzAtEOF == true <=> the scanner is at the EOF */
322   private boolean zzAtEOF;
323
324   /** denotes if the user-EOF-code has already been executed */
325   private boolean zzEOFDone;
326   
327   /** 
328    * The number of occupied positions in zzBuffer beyond zzEndRead.
329    * When a lead/high surrogate has been read from the input stream
330    * into the final zzBuffer position, this will have a value of 1;
331    * otherwise, it will have a value of 0.
332    */
333   private int zzFinalHighSurrogate = 0;
334
335   /* user code: */
336     StringBuffer string = new StringBuffer();
337     public Lexer(java.io.Reader in, ComplexSymbolFactory sf){
338         this(in);
339         symbolFactory = sf;
340     }
341     ComplexSymbolFactory symbolFactory;
342
343   private Symbol symbol(String name, int sym) {
344       return symbolFactory.newSymbol(name, sym, new Location(yyline+1,yycolumn+1,yychar), new Location(yyline+1,yycolumn+yylength(),yychar+yylength()));
345   }
346   
347   private Symbol symbol(String name, int sym, Object val) {
348       Location left = new Location(yyline+1,yycolumn+1,yychar);
349       Location right= new Location(yyline+1,yycolumn+yylength(), yychar+yylength());
350       return symbolFactory.newSymbol(name, sym, left, right,val);
351   } 
352   private Symbol symbol(String name, int sym, Object val,int buflength) {
353       Location left = new Location(yyline+1,yycolumn+yylength()-buflength,yychar+yylength()-buflength);
354       Location right= new Location(yyline+1,yycolumn+yylength(), yychar+yylength());
355       return symbolFactory.newSymbol(name, sym, left, right,val);
356   }       
357   private void error(String message) {
358     System.out.println("Error at line "+(yyline+1)+", column "+(yycolumn+1)+" : "+message);
359   }
360
361
362   /**
363    * Creates a new scanner
364    *
365    * @param   in  the java.io.Reader to read input from.
366    */
367   public Lexer(java.io.Reader in) {
368     this.zzReader = in;
369   }
370
371
372   /** 
373    * Unpacks the compressed character translation table.
374    *
375    * @param packed   the packed character translation table
376    * @return         the unpacked character translation table
377    */
378   private static char [] zzUnpackCMap(String packed) {
379     char [] map = new char[0x110000];
380     int i = 0;  /* index in packed string  */
381     int j = 0;  /* index in unpacked array */
382     while (i < 168) {
383       int  count = packed.charAt(i++);
384       char value = packed.charAt(i++);
385       do map[j++] = value; while (--count > 0);
386     }
387     return map;
388   }
389
390
391   /**
392    * Refills the input buffer.
393    *
394    * @return      <code>false</code>, iff there was new input.
395    * 
396    * @exception   java.io.IOException  if any I/O-Error occurs
397    */
398   private boolean zzRefill() throws java.io.IOException {
399
400     /* first: make room (if you can) */
401     if (zzStartRead > 0) {
402       zzEndRead += zzFinalHighSurrogate;
403       zzFinalHighSurrogate = 0;
404       System.arraycopy(zzBuffer, zzStartRead,
405                        zzBuffer, 0,
406                        zzEndRead-zzStartRead);
407
408       /* translate stored positions */
409       zzEndRead-= zzStartRead;
410       zzCurrentPos-= zzStartRead;
411       zzMarkedPos-= zzStartRead;
412       zzStartRead = 0;
413     }
414
415     /* is the buffer big enough? */
416     if (zzCurrentPos >= zzBuffer.length - zzFinalHighSurrogate) {
417       /* if not: blow it up */
418       char newBuffer[] = new char[zzBuffer.length*2];
419       System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
420       zzBuffer = newBuffer;
421       zzEndRead += zzFinalHighSurrogate;
422       zzFinalHighSurrogate = 0;
423     }
424
425     /* fill the buffer with new input */
426     int requested = zzBuffer.length - zzEndRead;
427     int numRead = zzReader.read(zzBuffer, zzEndRead, requested);
428
429     /* not supposed to occur according to specification of java.io.Reader */
430     if (numRead == 0) {
431       throw new java.io.IOException("Reader returned 0 characters. See JFlex examples for workaround.");
432     }
433     if (numRead > 0) {
434       zzEndRead += numRead;
435       /* If numRead == requested, we might have requested to few chars to
436          encode a full Unicode character. We assume that a Reader would
437          otherwise never return half characters. */
438       if (numRead == requested) {
439         if (Character.isHighSurrogate(zzBuffer[zzEndRead - 1])) {
440           --zzEndRead;
441           zzFinalHighSurrogate = 1;
442         }
443       }
444       /* potentially more input available */
445       return false;
446     }
447
448     /* numRead < 0 ==> end of stream */
449     return true;
450   }
451
452     
453   /**
454    * Closes the input stream.
455    */
456   public final void yyclose() throws java.io.IOException {
457     zzAtEOF = true;            /* indicate end of file */
458     zzEndRead = zzStartRead;  /* invalidate buffer    */
459
460     if (zzReader != null)
461       zzReader.close();
462   }
463
464
465   /**
466    * Resets the scanner to read from a new input stream.
467    * Does not close the old reader.
468    *
469    * All internal variables are reset, the old input stream 
470    * <b>cannot</b> be reused (internal buffer is discarded and lost).
471    * Lexical state is set to <tt>ZZ_INITIAL</tt>.
472    *
473    * Internal scan buffer is resized down to its initial length, if it has grown.
474    *
475    * @param reader   the new input stream 
476    */
477   public final void yyreset(java.io.Reader reader) {
478     zzReader = reader;
479     zzAtBOL  = true;
480     zzAtEOF  = false;
481     zzEOFDone = false;
482     zzEndRead = zzStartRead = 0;
483     zzCurrentPos = zzMarkedPos = 0;
484     zzFinalHighSurrogate = 0;
485     yyline = yychar = yycolumn = 0;
486     zzLexicalState = YYINITIAL;
487     if (zzBuffer.length > ZZ_BUFFERSIZE)
488       zzBuffer = new char[ZZ_BUFFERSIZE];
489   }
490
491
492   /**
493    * Returns the current lexical state.
494    */
495   public final int yystate() {
496     return zzLexicalState;
497   }
498
499
500   /**
501    * Enters a new lexical state
502    *
503    * @param newState the new lexical state
504    */
505   public final void yybegin(int newState) {
506     zzLexicalState = newState;
507   }
508
509
510   /**
511    * Returns the text matched by the current regular expression.
512    */
513   public final String yytext() {
514     return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
515   }
516
517
518   /**
519    * Returns the character at position <tt>pos</tt> from the 
520    * matched text. 
521    * 
522    * It is equivalent to yytext().charAt(pos), but faster
523    *
524    * @param pos the position of the character to fetch. 
525    *            A value from 0 to yylength()-1.
526    *
527    * @return the character at position pos
528    */
529   public final char yycharat(int pos) {
530     return zzBuffer[zzStartRead+pos];
531   }
532
533
534   /**
535    * Returns the length of the matched text region.
536    */
537   public final int yylength() {
538     return zzMarkedPos-zzStartRead;
539   }
540
541
542   /**
543    * Reports an error that occured while scanning.
544    *
545    * In a wellformed scanner (no or only correct usage of 
546    * yypushback(int) and a match-all fallback rule) this method 
547    * will only be called with things that "Can't Possibly Happen".
548    * If this method is called, something is seriously wrong
549    * (e.g. a JFlex bug producing a faulty scanner etc.).
550    *
551    * Usual syntax/scanner level error handling should be done
552    * in error fallback rules.
553    *
554    * @param   errorCode  the code of the errormessage to display
555    */
556   private void zzScanError(int errorCode) {
557     String message;
558     try {
559       message = ZZ_ERROR_MSG[errorCode];
560     }
561     catch (ArrayIndexOutOfBoundsException e) {
562       message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
563     }
564
565     throw new Error(message);
566   } 
567
568
569   /**
570    * Pushes the specified amount of characters back into the input stream.
571    *
572    * They will be read again by then next call of the scanning method
573    *
574    * @param number  the number of characters to be read again.
575    *                This number must not be greater than yylength()!
576    */
577   public void yypushback(int number)  {
578     if ( number > yylength() )
579       zzScanError(ZZ_PUSHBACK_2BIG);
580
581     zzMarkedPos -= number;
582   }
583
584
585   /**
586    * Contains user EOF-code, which will be executed exactly once,
587    * when the end of file is reached
588    */
589   private void zzDoEOF() throws java.io.IOException {
590     if (!zzEOFDone) {
591       zzEOFDone = true;
592       yyclose();
593     }
594   }
595
596
597   /**
598    * Resumes scanning until the next regular expression is matched,
599    * the end of input is encountered or an I/O-Error occurs.
600    *
601    * @return      the next token
602    * @exception   java.io.IOException  if any I/O-Error occurs
603    */
604   public java_cup.runtime.Symbol next_token() throws java.io.IOException {
605     int zzInput;
606     int zzAction;
607
608     // cached fields:
609     int zzCurrentPosL;
610     int zzMarkedPosL;
611     int zzEndReadL = zzEndRead;
612     char [] zzBufferL = zzBuffer;
613     char [] zzCMapL = ZZ_CMAP;
614
615     int [] zzTransL = ZZ_TRANS;
616     int [] zzRowMapL = ZZ_ROWMAP;
617     int [] zzAttrL = ZZ_ATTRIBUTE;
618
619     while (true) {
620       zzMarkedPosL = zzMarkedPos;
621
622       yychar+= zzMarkedPosL-zzStartRead;
623
624       boolean zzR = false;
625       int zzCh;
626       int zzCharCount;
627       for (zzCurrentPosL = zzStartRead  ;
628            zzCurrentPosL < zzMarkedPosL ;
629            zzCurrentPosL += zzCharCount ) {
630         zzCh = Character.codePointAt(zzBufferL, zzCurrentPosL, zzMarkedPosL);
631         zzCharCount = Character.charCount(zzCh);
632         switch (zzCh) {
633         case '\u000B':
634         case '\u000C':
635         case '\u0085':
636         case '\u2028':
637         case '\u2029':
638           yyline++;
639           yycolumn = 0;
640           zzR = false;
641           break;
642         case '\r':
643           yyline++;
644           yycolumn = 0;
645           zzR = true;
646           break;
647         case '\n':
648           if (zzR)
649             zzR = false;
650           else {
651             yyline++;
652             yycolumn = 0;
653           }
654           break;
655         default:
656           zzR = false;
657           yycolumn += zzCharCount;
658         }
659       }
660
661       if (zzR) {
662         // peek one character ahead if it is \n (if we have counted one line too much)
663         boolean zzPeek;
664         if (zzMarkedPosL < zzEndReadL)
665           zzPeek = zzBufferL[zzMarkedPosL] == '\n';
666         else if (zzAtEOF)
667           zzPeek = false;
668         else {
669           boolean eof = zzRefill();
670           zzEndReadL = zzEndRead;
671           zzMarkedPosL = zzMarkedPos;
672           zzBufferL = zzBuffer;
673           if (eof) 
674             zzPeek = false;
675           else 
676             zzPeek = zzBufferL[zzMarkedPosL] == '\n';
677         }
678         if (zzPeek) yyline--;
679       }
680       zzAction = -1;
681
682       zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
683   
684       zzState = ZZ_LEXSTATE[zzLexicalState];
685
686       // set up zzAction for empty match case:
687       int zzAttributes = zzAttrL[zzState];
688       if ( (zzAttributes & 1) == 1 ) {
689         zzAction = zzState;
690       }
691
692
693       zzForAction: {
694         while (true) {
695     
696           if (zzCurrentPosL < zzEndReadL) {
697             zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL);
698             zzCurrentPosL += Character.charCount(zzInput);
699           }
700           else if (zzAtEOF) {
701             zzInput = YYEOF;
702             break zzForAction;
703           }
704           else {
705             // store back cached positions
706             zzCurrentPos  = zzCurrentPosL;
707             zzMarkedPos   = zzMarkedPosL;
708             boolean eof = zzRefill();
709             // get translated positions and possibly new buffer
710             zzCurrentPosL  = zzCurrentPos;
711             zzMarkedPosL   = zzMarkedPos;
712             zzBufferL      = zzBuffer;
713             zzEndReadL     = zzEndRead;
714             if (eof) {
715               zzInput = YYEOF;
716               break zzForAction;
717             }
718             else {
719               zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL);
720               zzCurrentPosL += Character.charCount(zzInput);
721             }
722           }
723           int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
724           if (zzNext == -1) break zzForAction;
725           zzState = zzNext;
726
727           zzAttributes = zzAttrL[zzState];
728           if ( (zzAttributes & 1) == 1 ) {
729             zzAction = zzState;
730             zzMarkedPosL = zzCurrentPosL;
731             if ( (zzAttributes & 8) == 8 ) break zzForAction;
732           }
733
734         }
735       }
736
737       // store back cached position
738       zzMarkedPos = zzMarkedPosL;
739
740       if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
741         zzAtEOF = true;
742             zzDoEOF();
743           {      return symbolFactory.newSymbol("EOF", EOF, new Location(yyline+1,yycolumn+1,yychar), new Location(yyline+1,yycolumn+1,yychar+1));
744  }
745       }
746       else {
747         switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
748           case 1: 
749             { /* throw new Error("Illegal character <"+ yytext()+">");*/
750                     error("Illegal character <"+ yytext()+">");
751             }
752           case 39: break;
753           case 2: 
754             { return symbol("Identifier",IDENT, yytext());
755             }
756           case 40: break;
757           case 3: 
758             { /* ignore */
759             }
760           case 41: break;
761           case 4: 
762             { return symbol("semicolon",SEMICOLON);
763             }
764           case 42: break;
765           case 5: 
766             { string.setLength(0); yybegin(STRING);
767             }
768           case 43: break;
769           case 6: 
770             { return symbol("comma",COMMA);
771             }
772           case 44: break;
773           case 7: 
774             { return symbol("dot",DOT);
775             }
776           case 45: break;
777           case 8: 
778             { return symbol("(",LPAR);
779             }
780           case 46: break;
781           case 9: 
782             { return symbol(")",RPAR);
783             }
784           case 47: break;
785           case 10: 
786             { return symbol("{",BEGIN);
787             }
788           case 48: break;
789           case 11: 
790             { return symbol("}",END);
791             }
792           case 49: break;
793           case 12: 
794             { return symbol("=",ASSIGN);
795             }
796           case 50: break;
797           case 13: 
798             { string.append( yytext() );
799             }
800           case 51: break;
801           case 14: 
802             { yybegin(YYINITIAL); 
803       return symbol("StringConst",STRINGCONST,string.toString(),string.length());
804             }
805           case 52: break;
806           case 15: 
807             { string.append('\\');
808             }
809           case 53: break;
810           case 16: 
811             { return symbol("as",AS);
812             }
813           case 54: break;
814           case 17: 
815             { string.append('\n');
816             }
817           case 55: break;
818           case 18: 
819             { string.append('\t');
820             }
821           case 56: break;
822           case 19: 
823             { string.append('\r');
824             }
825           case 57: break;
826           case 20: 
827             { string.append('\"');
828             }
829           case 58: break;
830           case 21: 
831             { return symbol("int",TYPE, "int" );
832             }
833           case 59: break;
834           case 22: 
835             { return symbol("byte",TYPE, "byte" );
836             }
837           case 60: break;
838           case 23: 
839             { return symbol("long",TYPE, "long" );
840             }
841           case 61: break;
842           case 24: 
843             { return symbol("char",TYPE, "char" );
844             }
845           case 62: break;
846           case 25: 
847             { return symbol("void",TYPE, "void" );
848             }
849           case 63: break;
850           case 26: 
851             { return symbol("with",WITH);
852             }
853           case 64: break;
854           case 27: 
855             { return symbol("short",TYPE, "short" );
856             }
857           case 65: break;
858           case 28: 
859             { return symbol("float",TYPE, "float" );
860             }
861           case 66: break;
862           case 29: 
863             { return symbol("string",TYPE, "String" );
864             }
865           case 67: break;
866           case 30: 
867             { return symbol("double",TYPE, "double" );
868             }
869           case 68: break;
870           case 31: 
871             { return symbol("String",TYPE, "String" );
872             }
873           case 69: break;
874           case 32: 
875             { return symbol("public",PUBLIC);
876             }
877           case 70: break;
878           case 33: 
879             { return symbol("method",METHOD);
880             }
881           case 71: break;
882           case 34: 
883             { return symbol("boolean",TYPE, "boolean" );
884             }
885           case 72: break;
886           case 35: 
887             { return symbol("requires",REQUIRES);
888             }
889           case 73: break;
890           case 36: 
891             { return symbol("interface",INTERFACE);
892             }
893           case 74: break;
894           case 37: 
895             { return symbol("capability",CAPABILITY);
896             }
897           case 75: break;
898           case 38: 
899             { return symbol("description",DESCRIPTION);
900             }
901           case 76: break;
902           default:
903             zzScanError(ZZ_NO_MATCH);
904         }
905       }
906     }
907   }
908
909
910 }