001// $ANTLR 2.7.7 (20060906): "schema-extension.g" -> "AntlrSchemaExtensionLexer.java"$
002
003/*
004 *  Licensed to the Apache Software Foundation (ASF) under one
005 *  or more contributor license agreements.  See the NOTICE file
006 *  distributed with this work for additional information
007 *  regarding copyright ownership.  The ASF licenses this file
008 *  to you under the Apache License, Version 2.0 (the
009 *  "License"); you may not use this file except in compliance
010 *  with the License.  You may obtain a copy of the License at
011 *  
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *  
014 *  Unless required by applicable law or agreed to in writing,
015 *  software distributed under the License is distributed on an
016 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 *  KIND, either express or implied.  See the License for the
018 *  specific language governing permissions and limitations
019 *  under the License. 
020 *  
021 */
022package org.apache.directory.api.ldap.model.schema.syntaxes;
023
024import java.io.StringReader;
025import java.util.List;
026
027
028import java.io.InputStream;
029import antlr.TokenStreamException;
030import antlr.TokenStreamIOException;
031import antlr.TokenStreamRecognitionException;
032import antlr.CharStreamException;
033import antlr.CharStreamIOException;
034import antlr.ANTLRException;
035import java.io.Reader;
036import java.util.Hashtable;
037import antlr.CharScanner;
038import antlr.InputBuffer;
039import antlr.ByteBuffer;
040import antlr.CharBuffer;
041import antlr.Token;
042import antlr.CommonToken;
043import antlr.RecognitionException;
044import antlr.NoViableAltForCharException;
045import antlr.MismatchedCharException;
046import antlr.TokenStream;
047import antlr.ANTLRHashString;
048import antlr.LexerSharedInputState;
049import antlr.collections.impl.BitSet;
050import antlr.SemanticException;
051
052/**
053 * An antlr generated schema lexer. This is a sub-lexer.
054 *
055 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
056 */
057public class AntlrSchemaExtensionLexer extends antlr.CharScanner implements AntlrSchemaExtensionTokenTypes, TokenStream
058 {
059public AntlrSchemaExtensionLexer(InputStream in) {
060        this(new ByteBuffer(in));
061}
062public AntlrSchemaExtensionLexer(Reader in) {
063        this(new CharBuffer(in));
064}
065public AntlrSchemaExtensionLexer(InputBuffer ib) {
066        this(new LexerSharedInputState(ib));
067}
068public AntlrSchemaExtensionLexer(LexerSharedInputState state) {
069        super(state);
070        caseSensitiveLiterals = true;
071        setCaseSensitive(false);
072        literals = new Hashtable();
073}
074
075public Token nextToken() throws TokenStreamException {
076        Token theRetToken=null;
077tryAgain:
078        for (;;) {
079                Token _token = null;
080                int _ttype = Token.INVALID_TYPE;
081                resetText();
082                try {   // for char stream error handling
083                        try {   // for lexical error handling
084                                switch ( LA(1)) {
085                                case 'x':
086                                {
087                                        mXKEY(true);
088                                        theRetToken=_returnToken;
089                                        break;
090                                }
091                                case '\t':  case '\n':  case '\r':  case ' ':
092                                case '\'':  case '(':
093                                {
094                                        mXVALUES(true);
095                                        theRetToken=_returnToken;
096                                        break;
097                                }
098                                default:
099                                {
100                                        if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
101                                else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
102                                }
103                                }
104                                if ( _returnToken==null ) continue tryAgain; // found SKIP token
105                                _ttype = _returnToken.getType();
106                                _ttype = testLiteralsTable(_ttype);
107                                _returnToken.setType(_ttype);
108                                return _returnToken;
109                        }
110                        catch (RecognitionException e) {
111                                throw new TokenStreamRecognitionException(e);
112                        }
113                }
114                catch (CharStreamException cse) {
115                        if ( cse instanceof CharStreamIOException ) {
116                                throw new TokenStreamIOException(((CharStreamIOException)cse).io);
117                        }
118                        else {
119                                throw new TokenStreamException(cse.getMessage());
120                        }
121                }
122        }
123}
124
125        protected final void mWHSP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
126                int _ttype; Token _token=null; int _begin=text.length();
127                _ttype = WHSP;
128                int _saveIndex;
129                
130                {
131                int _cnt4=0;
132                _loop4:
133                do {
134                        if ((LA(1)==' ') && (true)) {
135                                match(' ');
136                        }
137                        else if ((LA(1)=='\t') && (true)) {
138                                match('\t');
139                        }
140                        else if ((LA(1)=='\r') && (true)) {
141                                match('\r');
142                                {
143                                if ((LA(1)=='\n') && (true)) {
144                                        match('\n');
145                                }
146                                else {
147                                }
148                                
149                                }
150                                newline();
151                        }
152                        else if ((LA(1)=='\n') && (true)) {
153                                match('\n');
154                                newline();
155                        }
156                        else {
157                                if ( _cnt4>=1 ) { break _loop4; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
158                        }
159                        
160                        _cnt4++;
161                } while (true);
162                }
163                _ttype = Token.SKIP;
164                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
165                        _token = makeToken(_ttype);
166                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
167                }
168                _returnToken = _token;
169        }
170        
171        protected final void mQUOTE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
172                int _ttype; Token _token=null; int _begin=text.length();
173                _ttype = QUOTE;
174                int _saveIndex;
175                
176                match('\'');
177                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
178                        _token = makeToken(_ttype);
179                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
180                }
181                _returnToken = _token;
182        }
183        
184        public final void mXKEY(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
185                int _ttype; Token _token=null; int _begin=text.length();
186                _ttype = XKEY;
187                int _saveIndex;
188                Token xstring=null;
189                
190                mXSTRING(true);
191                xstring=_returnToken;
192                setText(xstring.getText().trim());
193                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
194                        _token = makeToken(_ttype);
195                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
196                }
197                _returnToken = _token;
198        }
199        
200        protected final void mXSTRING(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
201                int _ttype; Token _token=null; int _begin=text.length();
202                _ttype = XSTRING;
203                int _saveIndex;
204                
205                {
206                match("x-");
207                {
208                int _cnt11=0;
209                _loop11:
210                do {
211                        switch ( LA(1)) {
212                        case 'a':  case 'b':  case 'c':  case 'd':
213                        case 'e':  case 'f':  case 'g':  case 'h':
214                        case 'i':  case 'j':  case 'k':  case 'l':
215                        case 'm':  case 'n':  case 'o':  case 'p':
216                        case 'q':  case 'r':  case 's':  case 't':
217                        case 'u':  case 'v':  case 'w':  case 'x':
218                        case 'y':  case 'z':
219                        {
220                                matchRange('a','z');
221                                break;
222                        }
223                        case '-':
224                        {
225                                match('-');
226                                break;
227                        }
228                        case '_':
229                        {
230                                match('_');
231                                break;
232                        }
233                        default:
234                        {
235                                if ( _cnt11>=1 ) { break _loop11; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
236                        }
237                        }
238                        _cnt11++;
239                } while (true);
240                }
241                {
242                if ((_tokenSet_0.member(LA(1)))) {
243                        mWHSP(false);
244                }
245                else {
246                }
247                
248                }
249                }
250                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
251                        _token = makeToken(_ttype);
252                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
253                }
254                _returnToken = _token;
255        }
256        
257        public final void mXVALUES(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
258                int _ttype; Token _token=null; int _begin=text.length();
259                _ttype = XVALUES;
260                int _saveIndex;
261                Token values=null;
262                
263                mVALUES(true);
264                values=_returnToken;
265                setText(values.getText().trim());
266                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
267                        _token = makeToken(_ttype);
268                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
269                }
270                _returnToken = _token;
271        }
272        
273        protected final void mVALUES(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
274                int _ttype; Token _token=null; int _begin=text.length();
275                _ttype = VALUES;
276                int _saveIndex;
277                
278                {
279                switch ( LA(1)) {
280                case '\t':  case '\n':  case '\r':  case ' ':
281                case '\'':
282                {
283                        mVALUE(false);
284                        break;
285                }
286                case '(':
287                {
288                        match('(');
289                        mVALUE(false);
290                        {
291                        _loop17:
292                        do {
293                                if ((_tokenSet_1.member(LA(1)))) {
294                                        {
295                                        switch ( LA(1)) {
296                                        case '$':
297                                        {
298                                                match('$');
299                                                break;
300                                        }
301                                        case '\t':  case '\n':  case '\r':  case ' ':
302                                        case '\'':
303                                        {
304                                                break;
305                                        }
306                                        default:
307                                        {
308                                                throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
309                                        }
310                                        }
311                                        }
312                                        mVALUE(false);
313                                }
314                                else {
315                                        break _loop17;
316                                }
317                                
318                        } while (true);
319                        }
320                        match(')');
321                        break;
322                }
323                default:
324                {
325                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
326                }
327                }
328                }
329                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
330                        _token = makeToken(_ttype);
331                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
332                }
333                _returnToken = _token;
334        }
335        
336        protected final void mVALUE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
337                int _ttype; Token _token=null; int _begin=text.length();
338                _ttype = VALUE;
339                int _saveIndex;
340                
341                {
342                switch ( LA(1)) {
343                case '\t':  case '\n':  case '\r':  case ' ':
344                {
345                        mWHSP(false);
346                        break;
347                }
348                case '\'':
349                {
350                        break;
351                }
352                default:
353                {
354                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
355                }
356                }
357                }
358                {
359                mQUOTED_STRING(false);
360                }
361                {
362                if ((_tokenSet_0.member(LA(1))) && (true)) {
363                        mWHSP(false);
364                }
365                else {
366                }
367                
368                }
369                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
370                        _token = makeToken(_ttype);
371                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
372                }
373                _returnToken = _token;
374        }
375        
376        protected final void mQUOTED_STRING(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
377                int _ttype; Token _token=null; int _begin=text.length();
378                _ttype = QUOTED_STRING;
379                int _saveIndex;
380                
381                {
382                mQUOTE(false);
383                {
384                _loop25:
385                do {
386                        if ((_tokenSet_2.member(LA(1)))) {
387                                matchNot('\'');
388                        }
389                        else {
390                                break _loop25;
391                        }
392                        
393                } while (true);
394                }
395                mQUOTE(false);
396                }
397                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
398                        _token = makeToken(_ttype);
399                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
400                }
401                _returnToken = _token;
402        }
403        
404        
405        private static final long[] mk_tokenSet_0() {
406                long[] data = new long[1025];
407                data[0]=4294977024L;
408                return data;
409        }
410        public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
411        private static final long[] mk_tokenSet_1() {
412                long[] data = new long[1025];
413                data[0]=622770267648L;
414                return data;
415        }
416        public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
417        private static final long[] mk_tokenSet_2() {
418                long[] data = new long[2048];
419                data[0]=-549755813889L;
420                for (int i = 1; i<=1022; i++) { data[i]=-1L; }
421                data[1023]=9223372036854775807L;
422                return data;
423        }
424        public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
425        
426        }