~brian-thomason/+junk/jasperreports3.7

« back to all changes in this revision

Viewing changes to src/net/sf/jasperreports/olap/mapping/MappingLexer.java

  • Committer: Brian Thomason
  • Date: 2011-12-20 17:51:16 UTC
  • Revision ID: brian.thomason@canonical.com-20111220175116-apwo6unuaedvgzo3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// $ANTLR 2.7.5 (20050128): "mapping.g" -> "MappingLexer.java"$
 
2
 
 
3
/*
 
4
 * JasperReports - Free Java Reporting Library.
 
5
 * Copyright (C) 2001 - 2009 Jaspersoft Corporation. All rights reserved.
 
6
 * http://www.jaspersoft.com
 
7
 *
 
8
 * Unless you have purchased a commercial license agreement from Jaspersoft,
 
9
 * the following license terms apply:
 
10
 *
 
11
 * This program is part of JasperReports.
 
12
 *
 
13
 * JasperReports is free software: you can redistribute it and/or modify
 
14
 * it under the terms of the GNU Lesser General Public License as published by
 
15
 * the Free Software Foundation, either version 3 of the License, or
 
16
 * (at your option) any later version.
 
17
 *
 
18
 * JasperReports is distributed in the hope that it will be useful,
 
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
21
 * GNU Lesser General Public License for more details.
 
22
 * 
 
23
 * You should have received a copy of the GNU Lesser General Public License
 
24
 * along with JasperReports. If not, see <http://www.gnu.org/licenses/>.
 
25
 */
 
26
package net.sf.jasperreports.olap.mapping;
 
27
 
 
28
import java.io.InputStream;
 
29
import java.io.Reader;
 
30
import java.util.Hashtable;
 
31
 
 
32
import antlr.ANTLRHashString;
 
33
import antlr.ByteBuffer;
 
34
import antlr.CharBuffer;
 
35
import antlr.CharStreamException;
 
36
import antlr.CharStreamIOException;
 
37
import antlr.InputBuffer;
 
38
import antlr.LexerSharedInputState;
 
39
import antlr.NoViableAltForCharException;
 
40
import antlr.RecognitionException;
 
41
import antlr.Token;
 
42
import antlr.TokenStream;
 
43
import antlr.TokenStreamException;
 
44
import antlr.TokenStreamIOException;
 
45
import antlr.TokenStreamRecognitionException;
 
46
import antlr.collections.impl.BitSet;
 
47
 
 
48
/**
 
49
 * @author Lucian Chirita (lucianc@users.sourceforge.net)
 
50
 * @version $Id: MappingLexer.java 3740 2010-04-16 15:03:17Z lucianc $
 
51
 */
 
52
public class MappingLexer extends antlr.CharScanner implements MappingParserTokenTypes, TokenStream
 
53
 {
 
54
public MappingLexer(InputStream in) {
 
55
        this(new ByteBuffer(in));
 
56
}
 
57
public MappingLexer(Reader in) {
 
58
        this(new CharBuffer(in));
 
59
}
 
60
public MappingLexer(InputBuffer ib) {
 
61
        this(new LexerSharedInputState(ib));
 
62
}
 
63
public MappingLexer(LexerSharedInputState state) {
 
64
        super(state);
 
65
        caseSensitiveLiterals = true;
 
66
        setCaseSensitive(false);
 
67
        literals = new Hashtable();
 
68
        literals.put(new ANTLRHashString("Columns", this), Integer.valueOf(7));
 
69
        literals.put(new ANTLRHashString("Data", this), Integer.valueOf(12));
 
70
        literals.put(new ANTLRHashString("Chapters", this), Integer.valueOf(10));
 
71
        literals.put(new ANTLRHashString("Rows", this), Integer.valueOf(8));
 
72
        literals.put(new ANTLRHashString("Sections", this), Integer.valueOf(11));
 
73
        literals.put(new ANTLRHashString("FormattedData", this), Integer.valueOf(13));
 
74
        literals.put(new ANTLRHashString("Axis", this), Integer.valueOf(4));
 
75
        literals.put(new ANTLRHashString("Pages", this), Integer.valueOf(9));
 
76
}
 
77
 
 
78
public Token nextToken() throws TokenStreamException {
 
79
        Token theRetToken=null;
 
80
tryAgain:
 
81
        for (;;) {
 
82
                Token _token = null;
 
83
                int _ttype = Token.INVALID_TYPE;
 
84
                resetText();
 
85
                try {   // for char stream error handling
 
86
                        try {   // for lexical error handling
 
87
                                switch ( LA(1)) {
 
88
                                case '.':
 
89
                                {
 
90
                                        mPOINT(true);
 
91
                                        theRetToken=_returnToken;
 
92
                                        break;
 
93
                                }
 
94
                                case '(':
 
95
                                {
 
96
                                        mLPAREN(true);
 
97
                                        theRetToken=_returnToken;
 
98
                                        break;
 
99
                                }
 
100
                                case ')':
 
101
                                {
 
102
                                        mRPAREN(true);
 
103
                                        theRetToken=_returnToken;
 
104
                                        break;
 
105
                                }
 
106
                                case '+':
 
107
                                {
 
108
                                        mPLUS(true);
 
109
                                        theRetToken=_returnToken;
 
110
                                        break;
 
111
                                }
 
112
                                case '-':
 
113
                                {
 
114
                                        mMINUS(true);
 
115
                                        theRetToken=_returnToken;
 
116
                                        break;
 
117
                                }
 
118
                                case '*':
 
119
                                {
 
120
                                        mSTAR(true);
 
121
                                        theRetToken=_returnToken;
 
122
                                        break;
 
123
                                }
 
124
                                case '?':
 
125
                                {
 
126
                                        mQMARK(true);
 
127
                                        theRetToken=_returnToken;
 
128
                                        break;
 
129
                                }
 
130
                                case ',':
 
131
                                {
 
132
                                        mCOMMA(true);
 
133
                                        theRetToken=_returnToken;
 
134
                                        break;
 
135
                                }
 
136
                                case '0':  case '1':  case '2':  case '3':
 
137
                                case '4':  case '5':  case '6':  case '7':
 
138
                                case '8':  case '9':
 
139
                                {
 
140
                                        mINT(true);
 
141
                                        theRetToken=_returnToken;
 
142
                                        break;
 
143
                                }
 
144
                                case '[':
 
145
                                {
 
146
                                        mMONDRNAME(true);
 
147
                                        theRetToken=_returnToken;
 
148
                                        break;
 
149
                                }
 
150
                                case '\t':  case '\n':  case '\r':  case ' ':
 
151
                                {
 
152
                                        mWS(true);
 
153
                                        theRetToken=_returnToken;
 
154
                                        break;
 
155
                                }
 
156
                                default:
 
157
                                        if ((_tokenSet_0.member(LA(1)))) {
 
158
                                                mNAME(true);
 
159
                                                theRetToken=_returnToken;
 
160
                                        }
 
161
                                else {
 
162
                                        if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
 
163
                                else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
 
164
                                }
 
165
                                }
 
166
                                if ( _returnToken==null )
 
167
                                {
 
168
                                        continue tryAgain; // found SKIP token
 
169
                                }
 
170
                                _ttype = _returnToken.getType();
 
171
                                _ttype = testLiteralsTable(_ttype);
 
172
                                _returnToken.setType(_ttype);
 
173
                                return _returnToken;
 
174
                        }
 
175
                        catch (RecognitionException e) {
 
176
                                throw new TokenStreamRecognitionException(e);
 
177
                        }
 
178
                }
 
179
                catch (CharStreamException cse) {
 
180
                        if ( cse instanceof CharStreamIOException ) {
 
181
                                throw new TokenStreamIOException(((CharStreamIOException)cse).io);
 
182
                        }
 
183
                        else {
 
184
                                throw new TokenStreamException(cse.getMessage());
 
185
                        }
 
186
                }
 
187
        }
 
188
}
 
189
 
 
190
        public final void mPOINT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
191
                int _ttype; Token _token=null; int _begin=text.length();
 
192
                _ttype = POINT;
 
193
                int _saveIndex;
 
194
                
 
195
                match('.');
 
196
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
197
                        _token = makeToken(_ttype);
 
198
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
199
                }
 
200
                _returnToken = _token;
 
201
        }
 
202
        
 
203
        public final void mLPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
204
                int _ttype; Token _token=null; int _begin=text.length();
 
205
                _ttype = LPAREN;
 
206
                int _saveIndex;
 
207
                
 
208
                match('(');
 
209
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
210
                        _token = makeToken(_ttype);
 
211
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
212
                }
 
213
                _returnToken = _token;
 
214
        }
 
215
        
 
216
        public final void mRPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
217
                int _ttype; Token _token=null; int _begin=text.length();
 
218
                _ttype = RPAREN;
 
219
                int _saveIndex;
 
220
                
 
221
                match(')');
 
222
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
223
                        _token = makeToken(_ttype);
 
224
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
225
                }
 
226
                _returnToken = _token;
 
227
        }
 
228
        
 
229
        public final void mPLUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
230
                int _ttype; Token _token=null; int _begin=text.length();
 
231
                _ttype = PLUS;
 
232
                int _saveIndex;
 
233
                
 
234
                match('+');
 
235
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
236
                        _token = makeToken(_ttype);
 
237
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
238
                }
 
239
                _returnToken = _token;
 
240
        }
 
241
        
 
242
        public final void mMINUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
243
                int _ttype; Token _token=null; int _begin=text.length();
 
244
                _ttype = MINUS;
 
245
                int _saveIndex;
 
246
                
 
247
                match('-');
 
248
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
249
                        _token = makeToken(_ttype);
 
250
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
251
                }
 
252
                _returnToken = _token;
 
253
        }
 
254
        
 
255
        public final void mSTAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
256
                int _ttype; Token _token=null; int _begin=text.length();
 
257
                _ttype = STAR;
 
258
                int _saveIndex;
 
259
                
 
260
                match('*');
 
261
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
262
                        _token = makeToken(_ttype);
 
263
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
264
                }
 
265
                _returnToken = _token;
 
266
        }
 
267
        
 
268
        public final void mQMARK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
269
                int _ttype; Token _token=null; int _begin=text.length();
 
270
                _ttype = QMARK;
 
271
                int _saveIndex;
 
272
                
 
273
                match('?');
 
274
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
275
                        _token = makeToken(_ttype);
 
276
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
277
                }
 
278
                _returnToken = _token;
 
279
        }
 
280
        
 
281
        public final void mCOMMA(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
282
                int _ttype; Token _token=null; int _begin=text.length();
 
283
                _ttype = COMMA;
 
284
                int _saveIndex;
 
285
                
 
286
                match(',');
 
287
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
288
                        _token = makeToken(_ttype);
 
289
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
290
                }
 
291
                _returnToken = _token;
 
292
        }
 
293
        
 
294
        public final void mINT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
295
                int _ttype; Token _token=null; int _begin=text.length();
 
296
                _ttype = INT;
 
297
                int _saveIndex;
 
298
                
 
299
                {
 
300
                int _cnt50=0;
 
301
                _loop50:
 
302
                do {
 
303
                        if (((LA(1) >= '0' && LA(1) <= '9'))) {
 
304
                                mDIGIT(false);
 
305
                        }
 
306
                        else {
 
307
                                if ( _cnt50>=1 ) { break _loop50; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
 
308
                        }
 
309
                        
 
310
                        _cnt50++;
 
311
                } while (true);
 
312
                }
 
313
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
314
                        _token = makeToken(_ttype);
 
315
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
316
                }
 
317
                _returnToken = _token;
 
318
        }
 
319
        
 
320
        protected final void mDIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
321
                int _ttype; Token _token=null; int _begin=text.length();
 
322
                _ttype = DIGIT;
 
323
                int _saveIndex;
 
324
                
 
325
                matchRange('0','9');
 
326
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
327
                        _token = makeToken(_ttype);
 
328
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
329
                }
 
330
                _returnToken = _token;
 
331
        }
 
332
        
 
333
        public final void mMONDRNAME(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
334
                int _ttype; Token _token=null; int _begin=text.length();
 
335
                _ttype = MONDRNAME;
 
336
                int _saveIndex;
 
337
                
 
338
                match('[');
 
339
                {
 
340
                int _cnt54=0;
 
341
                _loop54:
 
342
                do {
 
343
                        if ((_tokenSet_1.member(LA(1)))) {
 
344
                                {
 
345
                                match(_tokenSet_1);
 
346
                                }
 
347
                        }
 
348
                        else {
 
349
                                if ( _cnt54>=1 ) { break _loop54; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
 
350
                        }
 
351
                        
 
352
                        _cnt54++;
 
353
                } while (true);
 
354
                }
 
355
                match(']');
 
356
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
357
                        _token = makeToken(_ttype);
 
358
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
359
                }
 
360
                _returnToken = _token;
 
361
        }
 
362
        
 
363
        public final void mNAME(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
364
                int _ttype; Token _token=null; int _begin=text.length();
 
365
                _ttype = NAME;
 
366
                int _saveIndex;
 
367
                
 
368
                mLETTER(false);
 
369
                {
 
370
                _loop57:
 
371
                do {
 
372
                        switch ( LA(1)) {
 
373
                        case '0':  case '1':  case '2':  case '3':
 
374
                        case '4':  case '5':  case '6':  case '7':
 
375
                        case '8':  case '9':
 
376
                        {
 
377
                                mDIGIT(false);
 
378
                                break;
 
379
                        }
 
380
                        case ' ':
 
381
                        {
 
382
                                match(' ');
 
383
                                break;
 
384
                        }
 
385
                        default:
 
386
                                if ((_tokenSet_0.member(LA(1)))) {
 
387
                                        mLETTER(false);
 
388
                                }
 
389
                        else {
 
390
                                break _loop57;
 
391
                        }
 
392
                        }
 
393
                } while (true);
 
394
                }
 
395
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
396
                        _token = makeToken(_ttype);
 
397
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
398
                }
 
399
                _returnToken = _token;
 
400
        }
 
401
        
 
402
        protected final void mLETTER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
403
                int _ttype; Token _token=null; int _begin=text.length();
 
404
                _ttype = LETTER;
 
405
                int _saveIndex;
 
406
                
 
407
                if (((LA(1) >= 'a' && LA(1) <= 'z'))) {
 
408
                        matchRange('a','z');
 
409
                }
 
410
                else if (((LA(1) >= '\u0080' && LA(1) <= '\ufffe'))) {
 
411
                        matchRange('\u0080','\ufffe');
 
412
                }
 
413
                else {
 
414
                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
 
415
                }
 
416
                
 
417
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
418
                        _token = makeToken(_ttype);
 
419
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
420
                }
 
421
                _returnToken = _token;
 
422
        }
 
423
        
 
424
        public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
 
425
                int _ttype; Token _token=null; int _begin=text.length();
 
426
                _ttype = WS;
 
427
                int _saveIndex;
 
428
                
 
429
                {
 
430
                switch ( LA(1)) {
 
431
                case ' ':
 
432
                {
 
433
                        match(' ');
 
434
                        break;
 
435
                }
 
436
                case '\r':
 
437
                {
 
438
                        match('\r');
 
439
                        match('\n');
 
440
                        break;
 
441
                }
 
442
                case '\n':
 
443
                {
 
444
                        match('\n');
 
445
                        break;
 
446
                }
 
447
                case '\t':
 
448
                {
 
449
                        match('\t');
 
450
                        break;
 
451
                }
 
452
                default:
 
453
                {
 
454
                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
 
455
                }
 
456
                }
 
457
                }
 
458
                _ttype = Token.SKIP;
 
459
                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
 
460
                        _token = makeToken(_ttype);
 
461
                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
 
462
                }
 
463
                _returnToken = _token;
 
464
        }
 
465
        
 
466
        
 
467
        private static final long[] mk_tokenSet_0() {
 
468
                long[] data = new long[3072];
 
469
                data[1]=576460743713488896L;
 
470
                for (int i = 2; i<=1022; i++) { data[i]=-1L; }
 
471
                data[1023]=9223372036854775807L;
 
472
                return data;
 
473
        }
 
474
        public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
 
475
        private static final long[] mk_tokenSet_1() {
 
476
                long[] data = new long[2048];
 
477
                data[0]=-1L;
 
478
                data[1]=-536870913L;
 
479
                for (int i = 2; i<=1022; i++) { data[i]=-1L; }
 
480
                data[1023]=9223372036854775807L;
 
481
                return data;
 
482
        }
 
483
        public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
 
484
        
 
485
        }