001// $ANTLR 2.7.7 (20060906): "java14textblocks.g" -> "GeneratedTextBlockLexer.java"$
002
003package com.puppycrawl.tools.checkstyle.grammar;
004
005import com.puppycrawl.tools.checkstyle.DetailAstImpl;
006import java.text.MessageFormat;
007import antlr.CommonHiddenStreamToken;
008import antlr.TokenStreamSelector;
009
010import java.io.InputStream;
011import antlr.TokenStreamException;
012import antlr.TokenStreamIOException;
013import antlr.TokenStreamRecognitionException;
014import antlr.CharStreamException;
015import antlr.CharStreamIOException;
016import antlr.ANTLRException;
017import java.io.Reader;
018import java.util.Hashtable;
019import antlr.CharScanner;
020import antlr.InputBuffer;
021import antlr.ByteBuffer;
022import antlr.CharBuffer;
023import antlr.Token;
024import antlr.CommonToken;
025import antlr.RecognitionException;
026import antlr.NoViableAltForCharException;
027import antlr.MismatchedCharException;
028import antlr.TokenStream;
029import antlr.ANTLRHashString;
030import antlr.LexerSharedInputState;
031import antlr.collections.impl.BitSet;
032import antlr.SemanticException;
033
034public class GeneratedTextBlockLexer extends antlr.CharScanner implements GeneratedTextBlockLexerTokenTypes, TokenStream
035 {
036
037    public TokenStreamSelector selector;
038
039    // explicitly set tab width to 1 (default in ANTLR 2.7.1)
040    // in ANTLR 2.7.2a2 the default has changed from 1 to 8
041    public void tab()
042    {
043        setColumn( getColumn() + 1 );
044    }
045public GeneratedTextBlockLexer(InputStream in) {
046        this(new ByteBuffer(in));
047}
048public GeneratedTextBlockLexer(Reader in) {
049        this(new CharBuffer(in));
050}
051public GeneratedTextBlockLexer(InputBuffer ib) {
052        this(new LexerSharedInputState(ib));
053}
054public GeneratedTextBlockLexer(LexerSharedInputState state) {
055        super(state);
056        caseSensitiveLiterals = true;
057        setCaseSensitive(true);
058        literals = new Hashtable();
059        literals.put(new ANTLRHashString("byte", this), new Integer(51));
060        literals.put(new ANTLRHashString("public", this), new Integer(62));
061        literals.put(new ANTLRHashString("case", this), new Integer(93));
062        literals.put(new ANTLRHashString("short", this), new Integer(53));
063        literals.put(new ANTLRHashString("break", this), new Integer(86));
064        literals.put(new ANTLRHashString("while", this), new Integer(84));
065        literals.put(new ANTLRHashString("new", this), new Integer(136));
066        literals.put(new ANTLRHashString("instanceof", this), new Integer(121));
067        literals.put(new ANTLRHashString("implements", this), new Integer(75));
068        literals.put(new ANTLRHashString("synchronized", this), new Integer(67));
069        literals.put(new ANTLRHashString("float", this), new Integer(55));
070        literals.put(new ANTLRHashString("package", this), new Integer(44));
071        literals.put(new ANTLRHashString("return", this), new Integer(88));
072        literals.put(new ANTLRHashString("throw", this), new Integer(90));
073        literals.put(new ANTLRHashString("null", this), new Integer(135));
074        literals.put(new ANTLRHashString("protected", this), new Integer(63));
075        literals.put(new ANTLRHashString("class", this), new Integer(69));
076        literals.put(new ANTLRHashString("throws", this), new Integer(81));
077        literals.put(new ANTLRHashString("do", this), new Integer(85));
078        literals.put(new ANTLRHashString("strictfp", this), new Integer(41));
079        literals.put(new ANTLRHashString("super", this), new Integer(79));
080        literals.put(new ANTLRHashString("transient", this), new Integer(65));
081        literals.put(new ANTLRHashString("native", this), new Integer(66));
082        literals.put(new ANTLRHashString("interface", this), new Integer(71));
083        literals.put(new ANTLRHashString("final", this), new Integer(39));
084        literals.put(new ANTLRHashString("yield", this), new Integer(207));
085        literals.put(new ANTLRHashString("if", this), new Integer(83));
086        literals.put(new ANTLRHashString("record", this), new Integer(200));
087        literals.put(new ANTLRHashString("double", this), new Integer(57));
088        literals.put(new ANTLRHashString("volatile", this), new Integer(68));
089        literals.put(new ANTLRHashString("catch", this), new Integer(96));
090        literals.put(new ANTLRHashString("try", this), new Integer(95));
091        literals.put(new ANTLRHashString("int", this), new Integer(54));
092        literals.put(new ANTLRHashString("for", this), new Integer(91));
093        literals.put(new ANTLRHashString("extends", this), new Integer(70));
094        literals.put(new ANTLRHashString("boolean", this), new Integer(50));
095        literals.put(new ANTLRHashString("char", this), new Integer(52));
096        literals.put(new ANTLRHashString("private", this), new Integer(61));
097        literals.put(new ANTLRHashString("default", this), new Integer(94));
098        literals.put(new ANTLRHashString("false", this), new Integer(134));
099        literals.put(new ANTLRHashString("this", this), new Integer(78));
100        literals.put(new ANTLRHashString("static", this), new Integer(64));
101        literals.put(new ANTLRHashString("abstract", this), new Integer(40));
102        literals.put(new ANTLRHashString("continue", this), new Integer(87));
103        literals.put(new ANTLRHashString("finally", this), new Integer(97));
104        literals.put(new ANTLRHashString("else", this), new Integer(92));
105        literals.put(new ANTLRHashString("import", this), new Integer(46));
106        literals.put(new ANTLRHashString("void", this), new Integer(49));
107        literals.put(new ANTLRHashString("switch", this), new Integer(89));
108        literals.put(new ANTLRHashString("true", this), new Integer(133));
109        literals.put(new ANTLRHashString("long", this), new Integer(56));
110}
111
112public Token nextToken() throws TokenStreamException {
113        Token theRetToken=null;
114tryAgain:
115        for (;;) {
116                Token _token = null;
117                int _ttype = Token.INVALID_TYPE;
118                setCommitToPath(false);
119                resetText();
120                try {   // for char stream error handling
121                        try {   // for lexical error handling
122                                if ((LA(1)=='"') && (LA(2)=='"')) {
123                                        mTEXT_BLOCK_LITERAL_END(true);
124                                        theRetToken=_returnToken;
125                                }
126                                else if (((LA(1) >= '\u0000' && LA(1) <= '\ufffe')) && (true)) {
127                                        mTEXT_BLOCK_CONTENT(true);
128                                        theRetToken=_returnToken;
129                                }
130                                else {
131                                        if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
132                                else {consume(); continue tryAgain;}
133                                }
134                                
135                                if ( _returnToken==null ) continue tryAgain; // found SKIP token
136                                _ttype = _returnToken.getType();
137                                _ttype = testLiteralsTable(_ttype);
138                                _returnToken.setType(_ttype);
139                                return _returnToken;
140                        }
141                        catch (RecognitionException e) {
142                                if ( !getCommitToPath() ) {consume(); continue tryAgain;}
143                                throw new TokenStreamRecognitionException(e);
144                        }
145                }
146                catch (CharStreamException cse) {
147                        if ( cse instanceof CharStreamIOException ) {
148                                throw new TokenStreamIOException(((CharStreamIOException)cse).io);
149                        }
150                        else {
151                                throw new TokenStreamException(cse.getMessage());
152                        }
153                }
154        }
155}
156
157        protected final void mNEWLINE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
158                int _ttype; Token _token=null; int _begin=text.length();
159                _ttype = NEWLINE;
160                int _saveIndex;
161                
162                {
163                if ((LA(1)=='\r') && (LA(2)=='\n')) {
164                        match("\r\n");
165                }
166                else if ((LA(1)=='\r') && (true)) {
167                        match('\r');
168                }
169                else if ((LA(1)=='\n')) {
170                        match('\n');
171                }
172                else {
173                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
174                }
175                
176                }
177                if ( inputState.guessing==0 ) {
178                        this.newline();
179                }
180                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
181                        _token = makeToken(_ttype);
182                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
183                }
184                _returnToken = _token;
185        }
186        
187        public final void mTEXT_BLOCK_LITERAL_END(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
188                int _ttype; Token _token=null; int _begin=text.length();
189                _ttype = TEXT_BLOCK_LITERAL_END;
190                int _saveIndex;
191                
192                match("\"\"\"");
193                if ( inputState.guessing==0 ) {
194                        selector.pop();
195                }
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        protected final void mTWO_DOUBLE_QUOTES(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
204                int _ttype; Token _token=null; int _begin=text.length();
205                _ttype = TWO_DOUBLE_QUOTES;
206                int _saveIndex;
207                
208                match('"');
209                match('"');
210                {
211                if ((LA(1)=='\n'||LA(1)=='\r')) {
212                        mNEWLINE(false);
213                }
214                else if ((_tokenSet_0.member(LA(1)))) {
215                        matchNot('"');
216                }
217                else {
218                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
219                }
220                
221                }
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        protected final void mONE_DOUBLE_QUOTE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
230                int _ttype; Token _token=null; int _begin=text.length();
231                _ttype = ONE_DOUBLE_QUOTE;
232                int _saveIndex;
233                
234                match('"');
235                {
236                if ((LA(1)=='\n'||LA(1)=='\r')) {
237                        mNEWLINE(false);
238                }
239                else if ((_tokenSet_0.member(LA(1)))) {
240                        matchNot('"');
241                }
242                else {
243                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
244                }
245                
246                }
247                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
248                        _token = makeToken(_ttype);
249                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
250                }
251                _returnToken = _token;
252        }
253        
254        public final void mTEXT_BLOCK_CONTENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
255                int _ttype; Token _token=null; int _begin=text.length();
256                _ttype = TEXT_BLOCK_CONTENT;
257                int _saveIndex;
258                
259                {
260                int _cnt12=0;
261                _loop12:
262                do {
263                        boolean synPredMatched11 = false;
264                        if (((LA(1)=='"') && (LA(2)=='"'))) {
265                                int _m11 = mark();
266                                synPredMatched11 = true;
267                                inputState.guessing++;
268                                try {
269                                        {
270                                        mTWO_DOUBLE_QUOTES(false);
271                                        }
272                                }
273                                catch (RecognitionException pe) {
274                                        synPredMatched11 = false;
275                                }
276                                rewind(_m11);
277inputState.guessing--;
278                        }
279                        if ( synPredMatched11 ) {
280                                mTWO_DOUBLE_QUOTES(false);
281                        }
282                        else if ((LA(1)=='"') && (_tokenSet_1.member(LA(2)))) {
283                                mONE_DOUBLE_QUOTE(false);
284                        }
285                        else if ((LA(1)=='\\') && (_tokenSet_2.member(LA(2)))) {
286                                mSTD_ESC(false);
287                        }
288                        else if ((LA(1)=='\n'||LA(1)=='\r')) {
289                                mNEWLINE(false);
290                        }
291                        else if ((_tokenSet_0.member(LA(1))) && (true)) {
292                                matchNot('"');
293                        }
294                        else {
295                                if ( _cnt12>=1 ) { break _loop12; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
296                        }
297                        
298                        _cnt12++;
299                } while (true);
300                }
301                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
302                        _token = makeToken(_ttype);
303                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
304                }
305                _returnToken = _token;
306        }
307        
308        protected final void mSTD_ESC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
309                int _ttype; Token _token=null; int _begin=text.length();
310                _ttype = STD_ESC;
311                int _saveIndex;
312                
313                match('\\');
314                {
315                switch ( LA(1)) {
316                case 'n':
317                {
318                        match('n');
319                        break;
320                }
321                case 'r':
322                {
323                        match('r');
324                        break;
325                }
326                case 's':
327                {
328                        match('s');
329                        break;
330                }
331                case 't':
332                {
333                        match('t');
334                        break;
335                }
336                case 'b':
337                {
338                        match('b');
339                        break;
340                }
341                case 'f':
342                {
343                        match('f');
344                        break;
345                }
346                case '"':
347                {
348                        match('"');
349                        break;
350                }
351                case '\'':
352                {
353                        match('\'');
354                        break;
355                }
356                case '\\':
357                {
358                        match('\\');
359                        break;
360                }
361                default:
362                {
363                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
364                }
365                }
366                }
367                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
368                        _token = makeToken(_ttype);
369                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
370                }
371                _returnToken = _token;
372        }
373        
374        
375        private static final long[] mk_tokenSet_0() {
376                long[] data = new long[2048];
377                data[0]=-17179878401L;
378                for (int i = 1; i<=1022; i++) { data[i]=-1L; }
379                data[1023]=9223372036854775807L;
380                return data;
381        }
382        public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
383        private static final long[] mk_tokenSet_1() {
384                long[] data = new long[2048];
385                data[0]=-17179869185L;
386                for (int i = 1; i<=1022; i++) { data[i]=-1L; }
387                data[1023]=9223372036854775807L;
388                return data;
389        }
390        public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
391        private static final long[] mk_tokenSet_2() {
392                long[] data = new long[1025];
393                data[0]=566935683072L;
394                data[1]=7951960418287616L;
395                return data;
396        }
397        public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
398        
399        }