001// $ANTLR 2.7.7 (20060906): "distinguishedName.g" -> "AntlrDnLexer.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 *    https://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.name;
023
024import java.io.StringReader;
025import java.util.ArrayList;
026import java.util.HashMap;
027import java.util.List;
028import java.util.Map;
029
030import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
031import javax.naming.NameParser;
032import org.apache.directory.api.ldap.model.entry.Value;
033import org.apache.directory.api.ldap.model.schema.SchemaManager;
034import org.apache.directory.api.ldap.model.schema.AttributeType;
035import org.apache.directory.api.util.ExpansibleByteBuffer;
036import org.apache.directory.api.util.Strings;
037import org.apache.directory.api.util.Unicode;
038
039import java.io.InputStream;
040import antlr.TokenStreamException;
041import antlr.TokenStreamIOException;
042import antlr.TokenStreamRecognitionException;
043import antlr.CharStreamException;
044import antlr.CharStreamIOException;
045import antlr.ANTLRException;
046import java.io.Reader;
047import java.util.Hashtable;
048import antlr.CharScanner;
049import antlr.InputBuffer;
050import antlr.ByteBuffer;
051import antlr.CharBuffer;
052import antlr.Token;
053import antlr.CommonToken;
054import antlr.RecognitionException;
055import antlr.NoViableAltForCharException;
056import antlr.MismatchedCharException;
057import antlr.TokenStream;
058import antlr.ANTLRHashString;
059import antlr.LexerSharedInputState;
060import antlr.collections.impl.BitSet;
061import antlr.SemanticException;
062
063/**
064 * An antlr generated Dn lexer.
065 *
066 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
067 */
068public class AntlrDnLexer extends antlr.CharScanner implements AntlrDnTokenTypes, TokenStream
069 {
070public AntlrDnLexer(InputStream in) {
071        this(new ByteBuffer(in));
072}
073public AntlrDnLexer(Reader in) {
074        this(new CharBuffer(in));
075}
076public AntlrDnLexer(InputBuffer ib) {
077        this(new LexerSharedInputState(ib));
078}
079public AntlrDnLexer(LexerSharedInputState state) {
080        super(state);
081        caseSensitiveLiterals = true;
082        setCaseSensitive(false);
083        literals = new Hashtable();
084}
085
086public Token nextToken() throws TokenStreamException {
087        Token theRetToken=null;
088tryAgain:
089        for (;;) {
090                Token _token = null;
091                int _ttype = Token.INVALID_TYPE;
092                resetText();
093                try {   // for char stream error handling
094                        try {   // for lexical error handling
095                                switch ( LA(1)) {
096                                case ',':
097                                {
098                                        mCOMMA(true);
099                                        theRetToken=_returnToken;
100                                        break;
101                                }
102                                case '=':
103                                {
104                                        mEQUALS(true);
105                                        theRetToken=_returnToken;
106                                        break;
107                                }
108                                case '+':
109                                {
110                                        mPLUS(true);
111                                        theRetToken=_returnToken;
112                                        break;
113                                }
114                                case '-':
115                                {
116                                        mHYPHEN(true);
117                                        theRetToken=_returnToken;
118                                        break;
119                                }
120                                case '_':
121                                {
122                                        mUNDERSCORE(true);
123                                        theRetToken=_returnToken;
124                                        break;
125                                }
126                                case '"':
127                                {
128                                        mDQUOTE(true);
129                                        theRetToken=_returnToken;
130                                        break;
131                                }
132                                case ';':
133                                {
134                                        mSEMI(true);
135                                        theRetToken=_returnToken;
136                                        break;
137                                }
138                                case '<':
139                                {
140                                        mLANGLE(true);
141                                        theRetToken=_returnToken;
142                                        break;
143                                }
144                                case '>':
145                                {
146                                        mRANGLE(true);
147                                        theRetToken=_returnToken;
148                                        break;
149                                }
150                                case ' ':
151                                {
152                                        mSPACE(true);
153                                        theRetToken=_returnToken;
154                                        break;
155                                }
156                                case '0':  case '1':  case '2':  case '3':
157                                case '4':  case '5':  case '6':  case '7':
158                                case '8':  case '9':  case 'a':  case 'b':
159                                case 'c':  case 'd':  case 'e':  case 'f':
160                                case 'g':  case 'h':  case 'i':  case 'j':
161                                case 'k':  case 'l':  case 'm':  case 'n':
162                                case 'o':  case 'p':  case 'q':  case 'r':
163                                case 's':  case 't':  case 'u':  case 'v':
164                                case 'w':  case 'x':  case 'y':  case 'z':
165                                {
166                                        mNUMERICOID_OR_ALPHA_OR_DIGIT(true);
167                                        theRetToken=_returnToken;
168                                        break;
169                                }
170                                case '\\':
171                                {
172                                        mHEXPAIR_OR_ESCESC_ESCSHARP_OR_ESC(true);
173                                        theRetToken=_returnToken;
174                                        break;
175                                }
176                                case '#':
177                                {
178                                        mHEXVALUE_OR_SHARP(true);
179                                        theRetToken=_returnToken;
180                                        break;
181                                }
182                                case '\u0001':  case '\u0002':  case '\u0003':  case '\u0004':
183                                case '\u0005':  case '\u0006':  case '\u0007':  case '\u0008':
184                                case '\t':  case '\n':  case '\u000b':  case '\u000c':
185                                case '\r':  case '\u000e':  case '\u000f':  case '\u0010':
186                                case '\u0011':  case '\u0012':  case '\u0013':  case '\u0014':
187                                case '\u0015':  case '\u0016':  case '\u0017':  case '\u0018':
188                                case '\u0019':  case '\u001a':  case '\u001b':  case '\u001c':
189                                case '\u001d':  case '\u001e':  case '\u001f':  case '!':
190                                case '$':  case '%':  case '&':  case '\'':
191                                case '(':  case ')':  case '*':  case '.':
192                                case '/':  case ':':  case '?':  case '@':
193                                case '[':  case ']':  case '^':  case '`':
194                                case '{':  case '|':  case '}':  case '~':
195                                case '\u007f':
196                                {
197                                        mCHAR_REST(true);
198                                        theRetToken=_returnToken;
199                                        break;
200                                }
201                                default:
202                                        if (((LA(1) >= '\u0080' && LA(1) <= '\ufffe'))) {
203                                                mUTFMB(true);
204                                                theRetToken=_returnToken;
205                                        }
206                                else {
207                                        if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
208                                else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
209                                }
210                                }
211                                if ( _returnToken==null ) continue tryAgain; // found SKIP token
212                                _ttype = _returnToken.getType();
213                                _ttype = testLiteralsTable(_ttype);
214                                _returnToken.setType(_ttype);
215                                return _returnToken;
216                        }
217                        catch (RecognitionException e) {
218                                throw new TokenStreamRecognitionException(e);
219                        }
220                }
221                catch (CharStreamException cse) {
222                        if ( cse instanceof CharStreamIOException ) {
223                                throw new TokenStreamIOException(((CharStreamIOException)cse).io);
224                        }
225                        else {
226                                throw new TokenStreamException(cse.getMessage());
227                        }
228                }
229        }
230}
231
232        public final void mCOMMA(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
233                int _ttype; Token _token=null; int _begin=text.length();
234                _ttype = COMMA;
235                int _saveIndex;
236                
237                match(',');
238                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
239                        _token = makeToken(_ttype);
240                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
241                }
242                _returnToken = _token;
243        }
244        
245        public final void mEQUALS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
246                int _ttype; Token _token=null; int _begin=text.length();
247                _ttype = EQUALS;
248                int _saveIndex;
249                
250                match('=');
251                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
252                        _token = makeToken(_ttype);
253                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
254                }
255                _returnToken = _token;
256        }
257        
258        public final void mPLUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
259                int _ttype; Token _token=null; int _begin=text.length();
260                _ttype = PLUS;
261                int _saveIndex;
262                
263                match('+');
264                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
265                        _token = makeToken(_ttype);
266                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
267                }
268                _returnToken = _token;
269        }
270        
271        public final void mHYPHEN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
272                int _ttype; Token _token=null; int _begin=text.length();
273                _ttype = HYPHEN;
274                int _saveIndex;
275                
276                match('-');
277                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
278                        _token = makeToken(_ttype);
279                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
280                }
281                _returnToken = _token;
282        }
283        
284        public final void mUNDERSCORE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
285                int _ttype; Token _token=null; int _begin=text.length();
286                _ttype = UNDERSCORE;
287                int _saveIndex;
288                
289                match('_');
290                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
291                        _token = makeToken(_ttype);
292                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
293                }
294                _returnToken = _token;
295        }
296        
297        public final void mDQUOTE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
298                int _ttype; Token _token=null; int _begin=text.length();
299                _ttype = DQUOTE;
300                int _saveIndex;
301                
302                match('"');
303                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
304                        _token = makeToken(_ttype);
305                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
306                }
307                _returnToken = _token;
308        }
309        
310        public final void mSEMI(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
311                int _ttype; Token _token=null; int _begin=text.length();
312                _ttype = SEMI;
313                int _saveIndex;
314                
315                match(';');
316                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
317                        _token = makeToken(_ttype);
318                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
319                }
320                _returnToken = _token;
321        }
322        
323        public final void mLANGLE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
324                int _ttype; Token _token=null; int _begin=text.length();
325                _ttype = LANGLE;
326                int _saveIndex;
327                
328                match('<');
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        public final void mRANGLE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
337                int _ttype; Token _token=null; int _begin=text.length();
338                _ttype = RANGLE;
339                int _saveIndex;
340                
341                match('>');
342                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
343                        _token = makeToken(_ttype);
344                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
345                }
346                _returnToken = _token;
347        }
348        
349        public final void mSPACE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
350                int _ttype; Token _token=null; int _begin=text.length();
351                _ttype = SPACE;
352                int _saveIndex;
353                
354                match(' ');
355                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
356                        _token = makeToken(_ttype);
357                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
358                }
359                _returnToken = _token;
360        }
361        
362        public final void mNUMERICOID_OR_ALPHA_OR_DIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
363                int _ttype; Token _token=null; int _begin=text.length();
364                _ttype = NUMERICOID_OR_ALPHA_OR_DIGIT;
365                int _saveIndex;
366                
367                boolean synPredMatched13 = false;
368                if (((_tokenSet_0.member(LA(1))) && (_tokenSet_1.member(LA(2))))) {
369                        int _m13 = mark();
370                        synPredMatched13 = true;
371                        inputState.guessing++;
372                        try {
373                                {
374                                mNUMERICOID(false);
375                                }
376                        }
377                        catch (RecognitionException pe) {
378                                synPredMatched13 = false;
379                        }
380                        rewind(_m13);
381inputState.guessing--;
382                }
383                if ( synPredMatched13 ) {
384                        mNUMERICOID(false);
385                        if ( inputState.guessing==0 ) {
386                                _ttype = NUMERICOID;
387                        }
388                }
389                else {
390                        boolean synPredMatched15 = false;
391                        if ((((LA(1) >= '0' && LA(1) <= '9')) && (true))) {
392                                int _m15 = mark();
393                                synPredMatched15 = true;
394                                inputState.guessing++;
395                                try {
396                                        {
397                                        mDIGIT(false);
398                                        }
399                                }
400                                catch (RecognitionException pe) {
401                                        synPredMatched15 = false;
402                                }
403                                rewind(_m15);
404inputState.guessing--;
405                        }
406                        if ( synPredMatched15 ) {
407                                mDIGIT(false);
408                                if ( inputState.guessing==0 ) {
409                                        _ttype = DIGIT;
410                                }
411                        }
412                        else {
413                                boolean synPredMatched17 = false;
414                                if ((((LA(1) >= 'a' && LA(1) <= 'z')) && (true))) {
415                                        int _m17 = mark();
416                                        synPredMatched17 = true;
417                                        inputState.guessing++;
418                                        try {
419                                                {
420                                                mALPHA(false);
421                                                }
422                                        }
423                                        catch (RecognitionException pe) {
424                                                synPredMatched17 = false;
425                                        }
426                                        rewind(_m17);
427inputState.guessing--;
428                                }
429                                if ( synPredMatched17 ) {
430                                        mALPHA(false);
431                                        if ( inputState.guessing==0 ) {
432                                                _ttype = ALPHA;
433                                        }
434                                }
435                                else {
436                                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
437                                }
438                                }}
439                                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
440                                        _token = makeToken(_ttype);
441                                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
442                                }
443                                _returnToken = _token;
444                        }
445                        
446        protected final void mNUMERICOID(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
447                int _ttype; Token _token=null; int _begin=text.length();
448                _ttype = NUMERICOID;
449                int _saveIndex;
450                
451                {
452                switch ( LA(1)) {
453                case 'o':
454                {
455                        match("oid.");
456                        break;
457                }
458                case '0':  case '1':  case '2':  case '3':
459                case '4':  case '5':  case '6':  case '7':
460                case '8':  case '9':
461                {
462                        break;
463                }
464                default:
465                {
466                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
467                }
468                }
469                }
470                mNUMBER(false);
471                {
472                int _cnt21=0;
473                _loop21:
474                do {
475                        if ((LA(1)=='.')) {
476                                mDOT(false);
477                                mNUMBER(false);
478                        }
479                        else {
480                                if ( _cnt21>=1 ) { break _loop21; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
481                        }
482                        
483                        _cnt21++;
484                } while (true);
485                }
486                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
487                        _token = makeToken(_ttype);
488                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
489                }
490                _returnToken = _token;
491        }
492        
493        protected final void mDIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
494                int _ttype; Token _token=null; int _begin=text.length();
495                _ttype = DIGIT;
496                int _saveIndex;
497                
498                matchRange('0','9');
499                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
500                        _token = makeToken(_ttype);
501                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
502                }
503                _returnToken = _token;
504        }
505        
506        protected final void mALPHA(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
507                int _ttype; Token _token=null; int _begin=text.length();
508                _ttype = ALPHA;
509                int _saveIndex;
510                
511                matchRange('a','z');
512                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
513                        _token = makeToken(_ttype);
514                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
515                }
516                _returnToken = _token;
517        }
518        
519        protected final void mNUMBER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
520                int _ttype; Token _token=null; int _begin=text.length();
521                _ttype = NUMBER;
522                int _saveIndex;
523                
524                if (((LA(1) >= '1' && LA(1) <= '9')) && ((LA(2) >= '0' && LA(2) <= '9'))) {
525                        {
526                        mLDIGIT(false);
527                        {
528                        int _cnt26=0;
529                        _loop26:
530                        do {
531                                if (((LA(1) >= '0' && LA(1) <= '9'))) {
532                                        mDIGIT(false);
533                                }
534                                else {
535                                        if ( _cnt26>=1 ) { break _loop26; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
536                                }
537                                
538                                _cnt26++;
539                        } while (true);
540                        }
541                        }
542                }
543                else if (((LA(1) >= '0' && LA(1) <= '9')) && (true)) {
544                        mDIGIT(false);
545                }
546                else {
547                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
548                }
549                
550                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
551                        _token = makeToken(_ttype);
552                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
553                }
554                _returnToken = _token;
555        }
556        
557        protected final void mDOT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
558                int _ttype; Token _token=null; int _begin=text.length();
559                _ttype = DOT;
560                int _saveIndex;
561                
562                match('.');
563                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
564                        _token = makeToken(_ttype);
565                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
566                }
567                _returnToken = _token;
568        }
569        
570        protected final void mLDIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
571                int _ttype; Token _token=null; int _begin=text.length();
572                _ttype = LDIGIT;
573                int _saveIndex;
574                
575                matchRange('1','9');
576                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
577                        _token = makeToken(_ttype);
578                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
579                }
580                _returnToken = _token;
581        }
582        
583        public final void mHEXPAIR_OR_ESCESC_ESCSHARP_OR_ESC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
584                int _ttype; Token _token=null; int _begin=text.length();
585                _ttype = HEXPAIR_OR_ESCESC_ESCSHARP_OR_ESC;
586                int _saveIndex;
587                
588                boolean synPredMatched32 = false;
589                if (((LA(1)=='\\') && (_tokenSet_2.member(LA(2))))) {
590                        int _m32 = mark();
591                        synPredMatched32 = true;
592                        inputState.guessing++;
593                        try {
594                                {
595                                mESC(false);
596                                mHEX(false);
597                                mHEX(false);
598                                }
599                        }
600                        catch (RecognitionException pe) {
601                                synPredMatched32 = false;
602                        }
603                        rewind(_m32);
604inputState.guessing--;
605                }
606                if ( synPredMatched32 ) {
607                        mHEXPAIR(false);
608                        if ( inputState.guessing==0 ) {
609                                _ttype = HEXPAIR;
610                        }
611                }
612                else if ((LA(1)=='\\') && (LA(2)=='\\')) {
613                        mESCESC(false);
614                        if ( inputState.guessing==0 ) {
615                                _ttype = ESCESC;
616                        }
617                }
618                else if ((LA(1)=='\\') && (LA(2)=='#')) {
619                        mESCSHARP(false);
620                        if ( inputState.guessing==0 ) {
621                                _ttype = ESCSHARP;
622                        }
623                }
624                else if ((LA(1)=='\\') && (true)) {
625                        mESC(false);
626                        if ( inputState.guessing==0 ) {
627                                _ttype = ESC;
628                        }
629                }
630                else {
631                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
632                }
633                
634                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
635                        _token = makeToken(_ttype);
636                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
637                }
638                _returnToken = _token;
639        }
640        
641        protected final void mESC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
642                int _ttype; Token _token=null; int _begin=text.length();
643                _ttype = ESC;
644                int _saveIndex;
645                
646                match('\\');
647                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
648                        _token = makeToken(_ttype);
649                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
650                }
651                _returnToken = _token;
652        }
653        
654        protected final void mHEX(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
655                int _ttype; Token _token=null; int _begin=text.length();
656                _ttype = HEX;
657                int _saveIndex;
658                
659                switch ( LA(1)) {
660                case '0':  case '1':  case '2':  case '3':
661                case '4':  case '5':  case '6':  case '7':
662                case '8':  case '9':
663                {
664                        mDIGIT(false);
665                        break;
666                }
667                case 'a':  case 'b':  case 'c':  case 'd':
668                case 'e':  case 'f':
669                {
670                        matchRange('a','f');
671                        break;
672                }
673                default:
674                {
675                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
676                }
677                }
678                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
679                        _token = makeToken(_ttype);
680                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
681                }
682                _returnToken = _token;
683        }
684        
685        protected final void mHEXPAIR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
686                int _ttype; Token _token=null; int _begin=text.length();
687                _ttype = HEXPAIR;
688                int _saveIndex;
689                
690                _saveIndex=text.length();
691                mESC(false);
692                text.setLength(_saveIndex);
693                mHEX(false);
694                mHEX(false);
695                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
696                        _token = makeToken(_ttype);
697                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
698                }
699                _returnToken = _token;
700        }
701        
702        protected final void mESCESC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
703                int _ttype; Token _token=null; int _begin=text.length();
704                _ttype = ESCESC;
705                int _saveIndex;
706                
707                mESC(false);
708                mESC(false);
709                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
710                        _token = makeToken(_ttype);
711                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
712                }
713                _returnToken = _token;
714        }
715        
716        protected final void mESCSHARP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
717                int _ttype; Token _token=null; int _begin=text.length();
718                _ttype = ESCSHARP;
719                int _saveIndex;
720                
721                mESC(false);
722                mSHARP(false);
723                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
724                        _token = makeToken(_ttype);
725                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
726                }
727                _returnToken = _token;
728        }
729        
730        protected final void mSHARP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
731                int _ttype; Token _token=null; int _begin=text.length();
732                _ttype = SHARP;
733                int _saveIndex;
734                
735                match('#');
736                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
737                        _token = makeToken(_ttype);
738                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
739                }
740                _returnToken = _token;
741        }
742        
743        public final void mHEXVALUE_OR_SHARP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
744                int _ttype; Token _token=null; int _begin=text.length();
745                _ttype = HEXVALUE_OR_SHARP;
746                int _saveIndex;
747                
748                boolean synPredMatched42 = false;
749                if (((LA(1)=='#') && (_tokenSet_2.member(LA(2))))) {
750                        int _m42 = mark();
751                        synPredMatched42 = true;
752                        inputState.guessing++;
753                        try {
754                                {
755                                mSHARP(false);
756                                {
757                                int _cnt41=0;
758                                _loop41:
759                                do {
760                                        if ((_tokenSet_2.member(LA(1)))) {
761                                                mHEX(false);
762                                                mHEX(false);
763                                        }
764                                        else {
765                                                if ( _cnt41>=1 ) { break _loop41; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
766                                        }
767                                        
768                                        _cnt41++;
769                                } while (true);
770                                }
771                                }
772                        }
773                        catch (RecognitionException pe) {
774                                synPredMatched42 = false;
775                        }
776                        rewind(_m42);
777inputState.guessing--;
778                }
779                if ( synPredMatched42 ) {
780                        mHEXVALUE(false);
781                        if ( inputState.guessing==0 ) {
782                                _ttype = HEXVALUE;
783                        }
784                }
785                else if ((LA(1)=='#') && (true)) {
786                        mSHARP(false);
787                        if ( inputState.guessing==0 ) {
788                                _ttype = SHARP;
789                        }
790                }
791                else {
792                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
793                }
794                
795                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
796                        _token = makeToken(_ttype);
797                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
798                }
799                _returnToken = _token;
800        }
801        
802        protected final void mHEXVALUE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
803                int _ttype; Token _token=null; int _begin=text.length();
804                _ttype = HEXVALUE;
805                int _saveIndex;
806                
807                _saveIndex=text.length();
808                mSHARP(false);
809                text.setLength(_saveIndex);
810                {
811                int _cnt45=0;
812                _loop45:
813                do {
814                        if ((_tokenSet_2.member(LA(1)))) {
815                                mHEX(false);
816                                mHEX(false);
817                        }
818                        else {
819                                if ( _cnt45>=1 ) { break _loop45; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
820                        }
821                        
822                        _cnt45++;
823                } while (true);
824                }
825                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
826                        _token = makeToken(_ttype);
827                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
828                }
829                _returnToken = _token;
830        }
831        
832        public final void mUTFMB(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
833                int _ttype; Token _token=null; int _begin=text.length();
834                _ttype = UTFMB;
835                int _saveIndex;
836                
837                matchRange('\u0080','\uFFFE');
838                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
839                        _token = makeToken(_ttype);
840                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
841                }
842                _returnToken = _token;
843        }
844        
845/**
846 * RFC 4514, Section 3:
847 * <pre>
848 * LUTF1 = %x01-1F / %x21 / %x24-2A / %x2D-3A /
849 *    %x3D / %x3F-5B / %x5D-7F
850 *
851 * To avoid nondeterminism the following 
852 * rules are excluded. These rules are 
853 * explicitly added in the productions.
854 *   EQUALS (0x3D)
855 *   HYPHEN (0x2D)
856 *   UNDERSCORE (0x5F)
857 *   DIGIT (0x30-0x39)
858 *   ALPHA (0x41-0x5A and 0x61-0x7A)
859 * </pre>
860 *
861 * @param _createToken If a Token is to be to created
862 * @throws RecognitionException If the token is invalid
863 * @throws TokenStreamException When we weren't able to fetch a token
864 * @throws CharStreamException If we can't process the stream
865 */
866        public final void mCHAR_REST(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
867                int _ttype; Token _token=null; int _begin=text.length();
868                _ttype = CHAR_REST;
869                int _saveIndex;
870                
871                switch ( LA(1)) {
872                case '\u0001':  case '\u0002':  case '\u0003':  case '\u0004':
873                case '\u0005':  case '\u0006':  case '\u0007':  case '\u0008':
874                case '\t':  case '\n':  case '\u000b':  case '\u000c':
875                case '\r':  case '\u000e':  case '\u000f':  case '\u0010':
876                case '\u0011':  case '\u0012':  case '\u0013':  case '\u0014':
877                case '\u0015':  case '\u0016':  case '\u0017':  case '\u0018':
878                case '\u0019':  case '\u001a':  case '\u001b':  case '\u001c':
879                case '\u001d':  case '\u001e':  case '\u001f':
880                {
881                        matchRange('\u0001','\u001F');
882                        break;
883                }
884                case '!':
885                {
886                        match('\u0021');
887                        break;
888                }
889                case '$':  case '%':  case '&':  case '\'':
890                case '(':  case ')':  case '*':
891                {
892                        matchRange('\u0024','\u002A');
893                        break;
894                }
895                case '.':  case '/':
896                {
897                        matchRange('\u002E','\u002F');
898                        break;
899                }
900                case ':':
901                {
902                        match('\u003A');
903                        break;
904                }
905                case '?':  case '@':
906                {
907                        matchRange('\u003F','\u0040');
908                        break;
909                }
910                case '[':
911                {
912                        match('\u005B');
913                        break;
914                }
915                case ']':  case '^':
916                {
917                        matchRange('\u005D','\u005E');
918                        break;
919                }
920                case '`':
921                {
922                        match('\u0060');
923                        break;
924                }
925                case '{':  case '|':  case '}':  case '~':
926                case '\u007f':
927                {
928                        matchRange('\u007B','\u007F');
929                        break;
930                }
931                default:
932                {
933                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
934                }
935                }
936                if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
937                        _token = makeToken(_ttype);
938                        _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
939                }
940                _returnToken = _token;
941        }
942        
943        
944        private static final long[] mk_tokenSet_0() {
945                long[] data = new long[1025];
946                data[0]=287948901175001088L;
947                data[1]=140737488355328L;
948                return data;
949        }
950        public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
951        private static final long[] mk_tokenSet_1() {
952                long[] data = new long[1025];
953                data[0]=288019269919178752L;
954                data[1]=2199023255552L;
955                return data;
956        }
957        public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
958        private static final long[] mk_tokenSet_2() {
959                long[] data = new long[1025];
960                data[0]=287948901175001088L;
961                data[1]=541165879296L;
962                return data;
963        }
964        public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
965        
966        }