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