KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > olap > mapping > MappingLexer


1 // $ANTLR 2.7.5 (20050128): "mapping.g" -> "MappingLexer.java"$
2

3 /*
4  * ============================================================================
5  * GNU Lesser General Public License
6  * ============================================================================
7  *
8  * JasperReports - Free Java report-generating library.
9  * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
24  *
25  * JasperSoft Corporation
26  * 303 Second Street, Suite 450 North
27  * San Francisco, CA 94107
28  * http://www.jaspersoft.com
29  */

30 package net.sf.jasperreports.olap.mapping;
31
32 import java.util.List JavaDoc;
33 import java.util.ArrayList JavaDoc;
34
35 import net.sf.jasperreports.olap.mapping.*;
36
37 import java.io.InputStream JavaDoc;
38 import antlr.TokenStreamException;
39 import antlr.TokenStreamIOException;
40 import antlr.TokenStreamRecognitionException;
41 import antlr.CharStreamException;
42 import antlr.CharStreamIOException;
43 import antlr.ANTLRException;
44 import java.io.Reader JavaDoc;
45 import java.util.Hashtable JavaDoc;
46 import antlr.CharScanner;
47 import antlr.InputBuffer;
48 import antlr.ByteBuffer;
49 import antlr.CharBuffer;
50 import antlr.Token;
51 import antlr.CommonToken;
52 import antlr.RecognitionException;
53 import antlr.NoViableAltForCharException;
54 import antlr.MismatchedCharException;
55 import antlr.TokenStream;
56 import antlr.ANTLRHashString;
57 import antlr.LexerSharedInputState;
58 import antlr.collections.impl.BitSet;
59 import antlr.SemanticException;
60
61 /**
62  * @author Lucian Chirita (lucianc@users.sourceforge.net)
63  * @version $Id: MappingLexer.java 1316 2006-06-29 16:45:55 +0300 (Thu, 29 Jun 2006) lucianc $
64  */

65 public class MappingLexer extends antlr.CharScanner implements MappingParserTokenTypes, TokenStream
66  {
67 public MappingLexer(InputStream JavaDoc in) {
68     this(new ByteBuffer(in));
69 }
70 public MappingLexer(Reader JavaDoc in) {
71     this(new CharBuffer(in));
72 }
73 public MappingLexer(InputBuffer ib) {
74     this(new LexerSharedInputState(ib));
75 }
76 public MappingLexer(LexerSharedInputState state) {
77     super(state);
78     caseSensitiveLiterals = true;
79     setCaseSensitive(false);
80     literals = new Hashtable JavaDoc();
81     literals.put(new ANTLRHashString("Columns", this), new Integer JavaDoc(7));
82     literals.put(new ANTLRHashString("Data", this), new Integer JavaDoc(12));
83     literals.put(new ANTLRHashString("Chapters", this), new Integer JavaDoc(10));
84     literals.put(new ANTLRHashString("Rows", this), new Integer JavaDoc(8));
85     literals.put(new ANTLRHashString("Sections", this), new Integer JavaDoc(11));
86     literals.put(new ANTLRHashString("FormattedData", this), new Integer JavaDoc(13));
87     literals.put(new ANTLRHashString("Axis", this), new Integer JavaDoc(4));
88     literals.put(new ANTLRHashString("Pages", this), new Integer JavaDoc(9));
89 }
90
91 public Token nextToken() throws TokenStreamException {
92     Token theRetToken=null;
93 tryAgain:
94     for (;;) {
95         Token _token = null;
96         int _ttype = Token.INVALID_TYPE;
97         resetText();
98         try { // for char stream error handling
99
try { // for lexical error handling
100
switch ( LA(1)) {
101                 case '.':
102                 {
103                     mPOINT(true);
104                     theRetToken=_returnToken;
105                     break;
106                 }
107                 case '(':
108                 {
109                     mLPAREN(true);
110                     theRetToken=_returnToken;
111                     break;
112                 }
113                 case ')':
114                 {
115                     mRPAREN(true);
116                     theRetToken=_returnToken;
117                     break;
118                 }
119                 case '+':
120                 {
121                     mPLUS(true);
122                     theRetToken=_returnToken;
123                     break;
124                 }
125                 case '-':
126                 {
127                     mMINUS(true);
128                     theRetToken=_returnToken;
129                     break;
130                 }
131                 case '*':
132                 {
133                     mSTAR(true);
134                     theRetToken=_returnToken;
135                     break;
136                 }
137                 case '?':
138                 {
139                     mQMARK(true);
140                     theRetToken=_returnToken;
141                     break;
142                 }
143                 case ',':
144                 {
145                     mCOMMA(true);
146                     theRetToken=_returnToken;
147                     break;
148                 }
149                 case '0': case '1': case '2': case '3':
150                 case '4': case '5': case '6': case '7':
151                 case '8': case '9':
152                 {
153                     mINT(true);
154                     theRetToken=_returnToken;
155                     break;
156                 }
157                 case 'a': case 'b': case 'c': case 'd':
158                 case 'e': case 'f': case 'g': case 'h':
159                 case 'i': case 'j': case 'k': case 'l':
160                 case 'm': case 'n': case 'o': case 'p':
161                 case 'q': case 'r': case 's': case 't':
162                 case 'u': case 'v': case 'w': case 'x':
163                 case 'y': case 'z':
164                 {
165                     mNAME(true);
166                     theRetToken=_returnToken;
167                     break;
168                 }
169                 case '\t': case '\n': case '\r': case ' ':
170                 {
171                     mWS(true);
172                     theRetToken=_returnToken;
173                     break;
174                 }
175                 default:
176                     if ((LA(1)=='[') && (_tokenSet_0.member(LA(2)))) {
177                         mMONDRNAME(true);
178                         theRetToken=_returnToken;
179                     }
180                     else if ((LA(1)=='[') && (LA(2)=='#')) {
181                         mMONDRIDX(true);
182                         theRetToken=_returnToken;
183                     }
184                 else {
185                     if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
186                 else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
187                 }
188                 }
189                 if ( _returnToken==null ) continue tryAgain; // found SKIP token
190
_ttype = _returnToken.getType();
191                 _ttype = testLiteralsTable(_ttype);
192                 _returnToken.setType(_ttype);
193                 return _returnToken;
194             }
195             catch (RecognitionException e) {
196                 throw new TokenStreamRecognitionException(e);
197             }
198         }
199         catch (CharStreamException cse) {
200             if ( cse instanceof CharStreamIOException ) {
201                 throw new TokenStreamIOException(((CharStreamIOException)cse).io);
202             }
203             else {
204                 throw new TokenStreamException(cse.getMessage());
205             }
206         }
207     }
208 }
209
210     public final void mPOINT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
211         int _ttype; Token _token=null; int _begin=text.length();
212         _ttype = POINT;
213         int _saveIndex;
214         
215         match('.');
216         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
217             _token = makeToken(_ttype);
218             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
219         }
220         _returnToken = _token;
221     }
222     
223     public final void mLPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
224         int _ttype; Token _token=null; int _begin=text.length();
225         _ttype = LPAREN;
226         int _saveIndex;
227         
228         match('(');
229         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
230             _token = makeToken(_ttype);
231             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
232         }
233         _returnToken = _token;
234     }
235     
236     public final void mRPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
237         int _ttype; Token _token=null; int _begin=text.length();
238         _ttype = RPAREN;
239         int _saveIndex;
240         
241         match(')');
242         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
243             _token = makeToken(_ttype);
244             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
245         }
246         _returnToken = _token;
247     }
248     
249     public final void mPLUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
250         int _ttype; Token _token=null; int _begin=text.length();
251         _ttype = PLUS;
252         int _saveIndex;
253         
254         match('+');
255         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
256             _token = makeToken(_ttype);
257             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
258         }
259         _returnToken = _token;
260     }
261     
262     public final void mMINUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
263         int _ttype; Token _token=null; int _begin=text.length();
264         _ttype = MINUS;
265         int _saveIndex;
266         
267         match('-');
268         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
269             _token = makeToken(_ttype);
270             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
271         }
272         _returnToken = _token;
273     }
274     
275     public final void mSTAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
276         int _ttype; Token _token=null; int _begin=text.length();
277         _ttype = STAR;
278         int _saveIndex;
279         
280         match('*');
281         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
282             _token = makeToken(_ttype);
283             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
284         }
285         _returnToken = _token;
286     }
287     
288     public final void mQMARK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
289         int _ttype; Token _token=null; int _begin=text.length();
290         _ttype = QMARK;
291         int _saveIndex;
292         
293         match('?');
294         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
295             _token = makeToken(_ttype);
296             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
297         }
298         _returnToken = _token;
299     }
300     
301     public final void mCOMMA(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
302         int _ttype; Token _token=null; int _begin=text.length();
303         _ttype = COMMA;
304         int _saveIndex;
305         
306         match(',');
307         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
308             _token = makeToken(_ttype);
309             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
310         }
311         _returnToken = _token;
312     }
313     
314     public final void mINT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
315         int _ttype; Token _token=null; int _begin=text.length();
316         _ttype = INT;
317         int _saveIndex;
318         
319         {
320         int _cnt53=0;
321         _loop53:
322         do {
323             if (((LA(1) >= '0' && LA(1) <= '9'))) {
324                 mDIGIT(false);
325             }
326             else {
327                 if ( _cnt53>=1 ) { break _loop53; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
328             }
329             
330             _cnt53++;
331         } while (true);
332         }
333         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
334             _token = makeToken(_ttype);
335             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
336         }
337         _returnToken = _token;
338     }
339     
340     protected final void mDIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
341         int _ttype; Token _token=null; int _begin=text.length();
342         _ttype = DIGIT;
343         int _saveIndex;
344         
345         matchRange('0','9');
346         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
347             _token = makeToken(_ttype);
348             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
349         }
350         _returnToken = _token;
351     }
352     
353     public final void mMONDRNAME(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
354         int _ttype; Token _token=null; int _begin=text.length();
355         _ttype = MONDRNAME;
356         int _saveIndex;
357         
358         match('[');
359         matchNot('#');
360         {
361         _loop57:
362         do {
363             if ((_tokenSet_1.member(LA(1)))) {
364                 {
365                 match(_tokenSet_1);
366                 }
367             }
368             else {
369                 break _loop57;
370             }
371             
372         } while (true);
373         }
374         match(']');
375         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
376             _token = makeToken(_ttype);
377             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
378         }
379         _returnToken = _token;
380     }
381     
382     public final void mMONDRIDX(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
383         int _ttype; Token _token=null; int _begin=text.length();
384         _ttype = MONDRIDX;
385         int _saveIndex;
386         
387         match("[#");
388         {
389         int _cnt60=0;
390         _loop60:
391         do {
392             if (((LA(1) >= '0' && LA(1) <= '9'))) {
393                 mDIGIT(false);
394             }
395             else {
396                 if ( _cnt60>=1 ) { break _loop60; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
397             }
398             
399             _cnt60++;
400         } while (true);
401         }
402         match(']');
403         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
404             _token = makeToken(_ttype);
405             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
406         }
407         _returnToken = _token;
408     }
409     
410     public final void mNAME(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
411         int _ttype; Token _token=null; int _begin=text.length();
412         _ttype = NAME;
413         int _saveIndex;
414         
415         mLETTER(false);
416         {
417         _loop63:
418         do {
419             switch ( LA(1)) {
420             case 'a': case 'b': case 'c': case 'd':
421             case 'e': case 'f': case 'g': case 'h':
422             case 'i': case 'j': case 'k': case 'l':
423             case 'm': case 'n': case 'o': case 'p':
424             case 'q': case 'r': case 's': case 't':
425             case 'u': case 'v': case 'w': case 'x':
426             case 'y': case 'z':
427             {
428                 mLETTER(false);
429                 break;
430             }
431             case '0': case '1': case '2': case '3':
432             case '4': case '5': case '6': case '7':
433             case '8': case '9':
434             {
435                 mDIGIT(false);
436                 break;
437             }
438             case ' ':
439             {
440                 match(' ');
441                 break;
442             }
443             default:
444             {
445                 break _loop63;
446             }
447             }
448         } while (true);
449         }
450         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
451             _token = makeToken(_ttype);
452             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
453         }
454         _returnToken = _token;
455     }
456     
457     protected final void mLETTER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
458         int _ttype; Token _token=null; int _begin=text.length();
459         _ttype = LETTER;
460         int _saveIndex;
461         
462         matchRange('a','z');
463         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
464             _token = makeToken(_ttype);
465             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
466         }
467         _returnToken = _token;
468     }
469     
470     public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
471         int _ttype; Token _token=null; int _begin=text.length();
472         _ttype = WS;
473         int _saveIndex;
474         
475         {
476         switch ( LA(1)) {
477         case ' ':
478         {
479             match(' ');
480             break;
481         }
482         case '\r':
483         {
484             match('\r');
485             match('\n');
486             break;
487         }
488         case '\n':
489         {
490             match('\n');
491             break;
492         }
493         case '\t':
494         {
495             match('\t');
496             break;
497         }
498         default:
499         {
500             throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
501         }
502         }
503         }
504         _ttype = Token.SKIP;
505         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
506             _token = makeToken(_ttype);
507             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
508         }
509         _returnToken = _token;
510     }
511     
512     protected final void mMONDRCH(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
513         int _ttype; Token _token=null; int _begin=text.length();
514         _ttype = MONDRCH;
515         int _saveIndex;
516         
517         switch ( LA(1)) {
518         case 'a': case 'b': case 'c': case 'd':
519         case 'e': case 'f': case 'g': case 'h':
520         case 'i': case 'j': case 'k': case 'l':
521         case 'm': case 'n': case 'o': case 'p':
522         case 'q': case 'r': case 's': case 't':
523         case 'u': case 'v': case 'w': case 'x':
524         case 'y': case 'z':
525         {
526             mLETTER(false);
527             break;
528         }
529         case ' ':
530         {
531             match(' ');
532             break;
533         }
534         default:
535         {
536             throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
537         }
538         }
539         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
540             _token = makeToken(_ttype);
541             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
542         }
543         _returnToken = _token;
544     }
545     
546     
547     private static final long[] mk_tokenSet_0() {
548         long[] data = { -34359738369L, -1L, 0L, 0L};
549         return data;
550     }
551     public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
552     private static final long[] mk_tokenSet_1() {
553         long[] data = { -1L, -536870913L, 0L, 0L};
554         return data;
555     }
556     public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
557     
558     }
559
Popular Tags