001: // $ANTLR 2.7.5 (20050128): "mapping.g" -> "MappingLexer.java"$
002:
003: /*
004: * ============================================================================
005: * GNU Lesser General Public License
006: * ============================================================================
007: *
008: * JasperReports - Free Java report-generating library.
009: * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * You should have received a copy of the GNU Lesser General Public
022: * License along with this library; if not, write to the Free Software
023: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
024: *
025: * JasperSoft Corporation
026: * 303 Second Street, Suite 450 North
027: * San Francisco, CA 94107
028: * http://www.jaspersoft.com
029: */
030: package net.sf.jasperreports.olap.mapping;
031:
032: import java.util.List;
033: import java.util.ArrayList;
034:
035: import net.sf.jasperreports.olap.mapping.*;
036:
037: import java.io.InputStream;
038: import antlr.TokenStreamException;
039: import antlr.TokenStreamIOException;
040: import antlr.TokenStreamRecognitionException;
041: import antlr.CharStreamException;
042: import antlr.CharStreamIOException;
043: import antlr.ANTLRException;
044: import java.io.Reader;
045: import java.util.Hashtable;
046: import antlr.CharScanner;
047: import antlr.InputBuffer;
048: import antlr.ByteBuffer;
049: import antlr.CharBuffer;
050: import antlr.Token;
051: import antlr.CommonToken;
052: import antlr.RecognitionException;
053: import antlr.NoViableAltForCharException;
054: import antlr.MismatchedCharException;
055: import antlr.TokenStream;
056: import antlr.ANTLRHashString;
057: import antlr.LexerSharedInputState;
058: import antlr.collections.impl.BitSet;
059: import antlr.SemanticException;
060:
061: /**
062: * @author Lucian Chirita (lucianc@users.sourceforge.net)
063: * @version $Id: MappingLexer.java 1316 2006-06-29 13:45:55Z lucianc $
064: */
065: public class MappingLexer extends antlr.CharScanner implements
066: MappingParserTokenTypes, TokenStream {
067: public MappingLexer(InputStream in) {
068: this (new ByteBuffer(in));
069: }
070:
071: public MappingLexer(Reader in) {
072: this (new CharBuffer(in));
073: }
074:
075: public MappingLexer(InputBuffer ib) {
076: this (new LexerSharedInputState(ib));
077: }
078:
079: public MappingLexer(LexerSharedInputState state) {
080: super (state);
081: caseSensitiveLiterals = true;
082: setCaseSensitive(false);
083: literals = new Hashtable();
084: literals.put(new ANTLRHashString("Columns", this ), new Integer(
085: 7));
086: literals
087: .put(new ANTLRHashString("Data", this ), new Integer(12));
088: literals.put(new ANTLRHashString("Chapters", this ),
089: new Integer(10));
090: literals.put(new ANTLRHashString("Rows", this ), new Integer(8));
091: literals.put(new ANTLRHashString("Sections", this ),
092: new Integer(11));
093: literals.put(new ANTLRHashString("FormattedData", this ),
094: new Integer(13));
095: literals.put(new ANTLRHashString("Axis", this ), new Integer(4));
096: literals
097: .put(new ANTLRHashString("Pages", this ), new Integer(9));
098: }
099:
100: public Token nextToken() throws TokenStreamException {
101: Token theRetToken = null;
102: tryAgain: for (;;) {
103: Token _token = null;
104: int _ttype = Token.INVALID_TYPE;
105: resetText();
106: try { // for char stream error handling
107: try { // for lexical error handling
108: switch (LA(1)) {
109: case '.': {
110: mPOINT(true);
111: theRetToken = _returnToken;
112: break;
113: }
114: case '(': {
115: mLPAREN(true);
116: theRetToken = _returnToken;
117: break;
118: }
119: case ')': {
120: mRPAREN(true);
121: theRetToken = _returnToken;
122: break;
123: }
124: case '+': {
125: mPLUS(true);
126: theRetToken = _returnToken;
127: break;
128: }
129: case '-': {
130: mMINUS(true);
131: theRetToken = _returnToken;
132: break;
133: }
134: case '*': {
135: mSTAR(true);
136: theRetToken = _returnToken;
137: break;
138: }
139: case '?': {
140: mQMARK(true);
141: theRetToken = _returnToken;
142: break;
143: }
144: case ',': {
145: mCOMMA(true);
146: theRetToken = _returnToken;
147: break;
148: }
149: case '0':
150: case '1':
151: case '2':
152: case '3':
153: case '4':
154: case '5':
155: case '6':
156: case '7':
157: case '8':
158: case '9': {
159: mINT(true);
160: theRetToken = _returnToken;
161: break;
162: }
163: case 'a':
164: case 'b':
165: case 'c':
166: case 'd':
167: case 'e':
168: case 'f':
169: case 'g':
170: case 'h':
171: case 'i':
172: case 'j':
173: case 'k':
174: case 'l':
175: case 'm':
176: case 'n':
177: case 'o':
178: case 'p':
179: case 'q':
180: case 'r':
181: case 's':
182: case 't':
183: case 'u':
184: case 'v':
185: case 'w':
186: case 'x':
187: case 'y':
188: case 'z': {
189: mNAME(true);
190: theRetToken = _returnToken;
191: break;
192: }
193: case '\t':
194: case '\n':
195: case '\r':
196: case ' ': {
197: mWS(true);
198: theRetToken = _returnToken;
199: break;
200: }
201: default:
202: if ((LA(1) == '[')
203: && (_tokenSet_0.member(LA(2)))) {
204: mMONDRNAME(true);
205: theRetToken = _returnToken;
206: } else if ((LA(1) == '[') && (LA(2) == '#')) {
207: mMONDRIDX(true);
208: theRetToken = _returnToken;
209: } else {
210: if (LA(1) == EOF_CHAR) {
211: uponEOF();
212: _returnToken = makeToken(Token.EOF_TYPE);
213: } else {
214: throw new NoViableAltForCharException(
215: (char) LA(1), getFilename(),
216: getLine(), getColumn());
217: }
218: }
219: }
220: if (_returnToken == null)
221: continue tryAgain; // found SKIP token
222: _ttype = _returnToken.getType();
223: _ttype = testLiteralsTable(_ttype);
224: _returnToken.setType(_ttype);
225: return _returnToken;
226: } catch (RecognitionException e) {
227: throw new TokenStreamRecognitionException(e);
228: }
229: } catch (CharStreamException cse) {
230: if (cse instanceof CharStreamIOException) {
231: throw new TokenStreamIOException(
232: ((CharStreamIOException) cse).io);
233: } else {
234: throw new TokenStreamException(cse.getMessage());
235: }
236: }
237: }
238: }
239:
240: public final void mPOINT(boolean _createToken)
241: throws RecognitionException, CharStreamException,
242: TokenStreamException {
243: int _ttype;
244: Token _token = null;
245: int _begin = text.length();
246: _ttype = POINT;
247: int _saveIndex;
248:
249: match('.');
250: if (_createToken && _token == null && _ttype != Token.SKIP) {
251: _token = makeToken(_ttype);
252: _token.setText(new String(text.getBuffer(), _begin, text
253: .length()
254: - _begin));
255: }
256: _returnToken = _token;
257: }
258:
259: public final void mLPAREN(boolean _createToken)
260: throws RecognitionException, CharStreamException,
261: TokenStreamException {
262: int _ttype;
263: Token _token = null;
264: int _begin = text.length();
265: _ttype = LPAREN;
266: int _saveIndex;
267:
268: match('(');
269: if (_createToken && _token == null && _ttype != Token.SKIP) {
270: _token = makeToken(_ttype);
271: _token.setText(new String(text.getBuffer(), _begin, text
272: .length()
273: - _begin));
274: }
275: _returnToken = _token;
276: }
277:
278: public final void mRPAREN(boolean _createToken)
279: throws RecognitionException, CharStreamException,
280: TokenStreamException {
281: int _ttype;
282: Token _token = null;
283: int _begin = text.length();
284: _ttype = RPAREN;
285: int _saveIndex;
286:
287: match(')');
288: if (_createToken && _token == null && _ttype != Token.SKIP) {
289: _token = makeToken(_ttype);
290: _token.setText(new String(text.getBuffer(), _begin, text
291: .length()
292: - _begin));
293: }
294: _returnToken = _token;
295: }
296:
297: public final void mPLUS(boolean _createToken)
298: throws RecognitionException, CharStreamException,
299: TokenStreamException {
300: int _ttype;
301: Token _token = null;
302: int _begin = text.length();
303: _ttype = PLUS;
304: int _saveIndex;
305:
306: match('+');
307: if (_createToken && _token == null && _ttype != Token.SKIP) {
308: _token = makeToken(_ttype);
309: _token.setText(new String(text.getBuffer(), _begin, text
310: .length()
311: - _begin));
312: }
313: _returnToken = _token;
314: }
315:
316: public final void mMINUS(boolean _createToken)
317: throws RecognitionException, CharStreamException,
318: TokenStreamException {
319: int _ttype;
320: Token _token = null;
321: int _begin = text.length();
322: _ttype = MINUS;
323: int _saveIndex;
324:
325: match('-');
326: if (_createToken && _token == null && _ttype != Token.SKIP) {
327: _token = makeToken(_ttype);
328: _token.setText(new String(text.getBuffer(), _begin, text
329: .length()
330: - _begin));
331: }
332: _returnToken = _token;
333: }
334:
335: public final void mSTAR(boolean _createToken)
336: throws RecognitionException, CharStreamException,
337: TokenStreamException {
338: int _ttype;
339: Token _token = null;
340: int _begin = text.length();
341: _ttype = STAR;
342: int _saveIndex;
343:
344: match('*');
345: if (_createToken && _token == null && _ttype != Token.SKIP) {
346: _token = makeToken(_ttype);
347: _token.setText(new String(text.getBuffer(), _begin, text
348: .length()
349: - _begin));
350: }
351: _returnToken = _token;
352: }
353:
354: public final void mQMARK(boolean _createToken)
355: throws RecognitionException, CharStreamException,
356: TokenStreamException {
357: int _ttype;
358: Token _token = null;
359: int _begin = text.length();
360: _ttype = QMARK;
361: int _saveIndex;
362:
363: match('?');
364: if (_createToken && _token == null && _ttype != Token.SKIP) {
365: _token = makeToken(_ttype);
366: _token.setText(new String(text.getBuffer(), _begin, text
367: .length()
368: - _begin));
369: }
370: _returnToken = _token;
371: }
372:
373: public final void mCOMMA(boolean _createToken)
374: throws RecognitionException, CharStreamException,
375: TokenStreamException {
376: int _ttype;
377: Token _token = null;
378: int _begin = text.length();
379: _ttype = COMMA;
380: int _saveIndex;
381:
382: match(',');
383: if (_createToken && _token == null && _ttype != Token.SKIP) {
384: _token = makeToken(_ttype);
385: _token.setText(new String(text.getBuffer(), _begin, text
386: .length()
387: - _begin));
388: }
389: _returnToken = _token;
390: }
391:
392: public final void mINT(boolean _createToken)
393: throws RecognitionException, CharStreamException,
394: TokenStreamException {
395: int _ttype;
396: Token _token = null;
397: int _begin = text.length();
398: _ttype = INT;
399: int _saveIndex;
400:
401: {
402: int _cnt53 = 0;
403: _loop53: do {
404: if (((LA(1) >= '0' && LA(1) <= '9'))) {
405: mDIGIT(false);
406: } else {
407: if (_cnt53 >= 1) {
408: break _loop53;
409: } else {
410: throw new NoViableAltForCharException(
411: (char) LA(1), getFilename(), getLine(),
412: getColumn());
413: }
414: }
415:
416: _cnt53++;
417: } while (true);
418: }
419: if (_createToken && _token == null && _ttype != Token.SKIP) {
420: _token = makeToken(_ttype);
421: _token.setText(new String(text.getBuffer(), _begin, text
422: .length()
423: - _begin));
424: }
425: _returnToken = _token;
426: }
427:
428: protected final void mDIGIT(boolean _createToken)
429: throws RecognitionException, CharStreamException,
430: TokenStreamException {
431: int _ttype;
432: Token _token = null;
433: int _begin = text.length();
434: _ttype = DIGIT;
435: int _saveIndex;
436:
437: matchRange('0', '9');
438: if (_createToken && _token == null && _ttype != Token.SKIP) {
439: _token = makeToken(_ttype);
440: _token.setText(new String(text.getBuffer(), _begin, text
441: .length()
442: - _begin));
443: }
444: _returnToken = _token;
445: }
446:
447: public final void mMONDRNAME(boolean _createToken)
448: throws RecognitionException, CharStreamException,
449: TokenStreamException {
450: int _ttype;
451: Token _token = null;
452: int _begin = text.length();
453: _ttype = MONDRNAME;
454: int _saveIndex;
455:
456: match('[');
457: matchNot('#');
458: {
459: _loop57: do {
460: if ((_tokenSet_1.member(LA(1)))) {
461: {
462: match(_tokenSet_1);
463: }
464: } else {
465: break _loop57;
466: }
467:
468: } while (true);
469: }
470: match(']');
471: if (_createToken && _token == null && _ttype != Token.SKIP) {
472: _token = makeToken(_ttype);
473: _token.setText(new String(text.getBuffer(), _begin, text
474: .length()
475: - _begin));
476: }
477: _returnToken = _token;
478: }
479:
480: public final void mMONDRIDX(boolean _createToken)
481: throws RecognitionException, CharStreamException,
482: TokenStreamException {
483: int _ttype;
484: Token _token = null;
485: int _begin = text.length();
486: _ttype = MONDRIDX;
487: int _saveIndex;
488:
489: match("[#");
490: {
491: int _cnt60 = 0;
492: _loop60: do {
493: if (((LA(1) >= '0' && LA(1) <= '9'))) {
494: mDIGIT(false);
495: } else {
496: if (_cnt60 >= 1) {
497: break _loop60;
498: } else {
499: throw new NoViableAltForCharException(
500: (char) LA(1), getFilename(), getLine(),
501: getColumn());
502: }
503: }
504:
505: _cnt60++;
506: } while (true);
507: }
508: match(']');
509: if (_createToken && _token == null && _ttype != Token.SKIP) {
510: _token = makeToken(_ttype);
511: _token.setText(new String(text.getBuffer(), _begin, text
512: .length()
513: - _begin));
514: }
515: _returnToken = _token;
516: }
517:
518: public final void mNAME(boolean _createToken)
519: throws RecognitionException, CharStreamException,
520: TokenStreamException {
521: int _ttype;
522: Token _token = null;
523: int _begin = text.length();
524: _ttype = NAME;
525: int _saveIndex;
526:
527: mLETTER(false);
528: {
529: _loop63: do {
530: switch (LA(1)) {
531: case 'a':
532: case 'b':
533: case 'c':
534: case 'd':
535: case 'e':
536: case 'f':
537: case 'g':
538: case 'h':
539: case 'i':
540: case 'j':
541: case 'k':
542: case 'l':
543: case 'm':
544: case 'n':
545: case 'o':
546: case 'p':
547: case 'q':
548: case 'r':
549: case 's':
550: case 't':
551: case 'u':
552: case 'v':
553: case 'w':
554: case 'x':
555: case 'y':
556: case 'z': {
557: mLETTER(false);
558: break;
559: }
560: case '0':
561: case '1':
562: case '2':
563: case '3':
564: case '4':
565: case '5':
566: case '6':
567: case '7':
568: case '8':
569: case '9': {
570: mDIGIT(false);
571: break;
572: }
573: case ' ': {
574: match(' ');
575: break;
576: }
577: default: {
578: break _loop63;
579: }
580: }
581: } while (true);
582: }
583: if (_createToken && _token == null && _ttype != Token.SKIP) {
584: _token = makeToken(_ttype);
585: _token.setText(new String(text.getBuffer(), _begin, text
586: .length()
587: - _begin));
588: }
589: _returnToken = _token;
590: }
591:
592: protected final void mLETTER(boolean _createToken)
593: throws RecognitionException, CharStreamException,
594: TokenStreamException {
595: int _ttype;
596: Token _token = null;
597: int _begin = text.length();
598: _ttype = LETTER;
599: int _saveIndex;
600:
601: matchRange('a', 'z');
602: if (_createToken && _token == null && _ttype != Token.SKIP) {
603: _token = makeToken(_ttype);
604: _token.setText(new String(text.getBuffer(), _begin, text
605: .length()
606: - _begin));
607: }
608: _returnToken = _token;
609: }
610:
611: public final void mWS(boolean _createToken)
612: throws RecognitionException, CharStreamException,
613: TokenStreamException {
614: int _ttype;
615: Token _token = null;
616: int _begin = text.length();
617: _ttype = WS;
618: int _saveIndex;
619:
620: {
621: switch (LA(1)) {
622: case ' ': {
623: match(' ');
624: break;
625: }
626: case '\r': {
627: match('\r');
628: match('\n');
629: break;
630: }
631: case '\n': {
632: match('\n');
633: break;
634: }
635: case '\t': {
636: match('\t');
637: break;
638: }
639: default: {
640: throw new NoViableAltForCharException((char) LA(1),
641: getFilename(), getLine(), getColumn());
642: }
643: }
644: }
645: _ttype = Token.SKIP;
646: if (_createToken && _token == null && _ttype != Token.SKIP) {
647: _token = makeToken(_ttype);
648: _token.setText(new String(text.getBuffer(), _begin, text
649: .length()
650: - _begin));
651: }
652: _returnToken = _token;
653: }
654:
655: protected final void mMONDRCH(boolean _createToken)
656: throws RecognitionException, CharStreamException,
657: TokenStreamException {
658: int _ttype;
659: Token _token = null;
660: int _begin = text.length();
661: _ttype = MONDRCH;
662: int _saveIndex;
663:
664: switch (LA(1)) {
665: case 'a':
666: case 'b':
667: case 'c':
668: case 'd':
669: case 'e':
670: case 'f':
671: case 'g':
672: case 'h':
673: case 'i':
674: case 'j':
675: case 'k':
676: case 'l':
677: case 'm':
678: case 'n':
679: case 'o':
680: case 'p':
681: case 'q':
682: case 'r':
683: case 's':
684: case 't':
685: case 'u':
686: case 'v':
687: case 'w':
688: case 'x':
689: case 'y':
690: case 'z': {
691: mLETTER(false);
692: break;
693: }
694: case ' ': {
695: match(' ');
696: break;
697: }
698: default: {
699: throw new NoViableAltForCharException((char) LA(1),
700: getFilename(), getLine(), getColumn());
701: }
702: }
703: if (_createToken && _token == null && _ttype != Token.SKIP) {
704: _token = makeToken(_ttype);
705: _token.setText(new String(text.getBuffer(), _begin, text
706: .length()
707: - _begin));
708: }
709: _returnToken = _token;
710: }
711:
712: private static final long[] mk_tokenSet_0() {
713: long[] data = { -34359738369L, -1L, 0L, 0L };
714: return data;
715: }
716:
717: public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
718:
719: private static final long[] mk_tokenSet_1() {
720: long[] data = { -1L, -536870913L, 0L, 0L };
721: return data;
722: }
723:
724: public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
725:
726: }
|