001// $ANTLR 2.7.7 (20060906): "schema-qdstring.g" -> "AntlrSchemaQdstringLexer.java"$ 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 * 021 */ 022package org.apache.directory.api.ldap.model.schema.syntaxes; 023 024import java.util.ArrayList; 025import java.util.List; 026 027import org.apache.directory.api.ldap.model.schema.parsers.ParserMonitor; 028 029 030import java.io.InputStream; 031import antlr.TokenStreamException; 032import antlr.TokenStreamIOException; 033import antlr.TokenStreamRecognitionException; 034import antlr.CharStreamException; 035import antlr.CharStreamIOException; 036import antlr.ANTLRException; 037import java.io.Reader; 038import java.util.Hashtable; 039import antlr.CharScanner; 040import antlr.InputBuffer; 041import antlr.ByteBuffer; 042import antlr.CharBuffer; 043import antlr.Token; 044import antlr.CommonToken; 045import antlr.RecognitionException; 046import antlr.NoViableAltForCharException; 047import antlr.MismatchedCharException; 048import antlr.TokenStream; 049import antlr.ANTLRHashString; 050import antlr.LexerSharedInputState; 051import antlr.collections.impl.BitSet; 052import antlr.SemanticException; 053 054/** 055 * An antlr generated schema lexer. This is a sub-lexer. 056 * 057 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 058 */ 059public class AntlrSchemaQdstringLexer extends antlr.CharScanner implements AntlrSchemaQdstringTokenTypes, TokenStream 060 { 061public AntlrSchemaQdstringLexer(InputStream in) { 062 this(new ByteBuffer(in)); 063} 064public AntlrSchemaQdstringLexer(Reader in) { 065 this(new CharBuffer(in)); 066} 067public AntlrSchemaQdstringLexer(InputBuffer ib) { 068 this(new LexerSharedInputState(ib)); 069} 070public AntlrSchemaQdstringLexer(LexerSharedInputState state) { 071 super(state); 072 caseSensitiveLiterals = true; 073 setCaseSensitive(false); 074 literals = new Hashtable(); 075} 076 077public Token nextToken() throws TokenStreamException { 078 Token theRetToken=null; 079tryAgain: 080 for (;;) { 081 Token _token = null; 082 int _ttype = Token.INVALID_TYPE; 083 resetText(); 084 try { // for char stream error handling 085 try { // for lexical error handling 086 switch ( LA(1)) { 087 case '\t': case '\n': case '\r': case ' ': 088 { 089 mWHSP(true); 090 theRetToken=_returnToken; 091 break; 092 } 093 case '(': 094 { 095 mLPAR(true); 096 theRetToken=_returnToken; 097 break; 098 } 099 case ')': 100 { 101 mRPAR(true); 102 theRetToken=_returnToken; 103 break; 104 } 105 default: 106 if ((LA(1)=='\'') && ((LA(2) >= '\u0000' && LA(2) <= '\ufffe'))) { 107 mQDSTRING(true); 108 theRetToken=_returnToken; 109 } 110 else if ((LA(1)=='\'') && (true)) { 111 mQUOTE(true); 112 theRetToken=_returnToken; 113 } 114 else { 115 if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);} 116 else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} 117 } 118 } 119 if ( _returnToken==null ) continue tryAgain; // found SKIP token 120 _ttype = _returnToken.getType(); 121 _ttype = testLiteralsTable(_ttype); 122 _returnToken.setType(_ttype); 123 return _returnToken; 124 } 125 catch (RecognitionException e) { 126 throw new TokenStreamRecognitionException(e); 127 } 128 } 129 catch (CharStreamException cse) { 130 if ( cse instanceof CharStreamIOException ) { 131 throw new TokenStreamIOException(((CharStreamIOException)cse).io); 132 } 133 else { 134 throw new TokenStreamException(cse.getMessage()); 135 } 136 } 137 } 138} 139 140 public final void mWHSP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 141 int _ttype; Token _token=null; int _begin=text.length(); 142 _ttype = WHSP; 143 int _saveIndex; 144 145 { 146 int _cnt4=0; 147 _loop4: 148 do { 149 switch ( LA(1)) { 150 case ' ': 151 { 152 match(' '); 153 break; 154 } 155 case '\t': 156 { 157 match('\t'); 158 break; 159 } 160 case '\r': 161 { 162 match('\r'); 163 { 164 if ((LA(1)=='\n') && (true)) { 165 match('\n'); 166 } 167 else { 168 } 169 170 } 171 newline(); 172 break; 173 } 174 case '\n': 175 { 176 match('\n'); 177 newline(); 178 break; 179 } 180 default: 181 { 182 if ( _cnt4>=1 ) { break _loop4; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} 183 } 184 } 185 _cnt4++; 186 } while (true); 187 } 188 _ttype = Token.SKIP; 189 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 190 _token = makeToken(_ttype); 191 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 192 } 193 _returnToken = _token; 194 } 195 196 public final void mLPAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 197 int _ttype; Token _token=null; int _begin=text.length(); 198 _ttype = LPAR; 199 int _saveIndex; 200 201 match('('); 202 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 203 _token = makeToken(_ttype); 204 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 205 } 206 _returnToken = _token; 207 } 208 209 public final void mRPAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 210 int _ttype; Token _token=null; int _begin=text.length(); 211 _ttype = RPAR; 212 int _saveIndex; 213 214 match(')'); 215 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 216 _token = makeToken(_ttype); 217 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 218 } 219 _returnToken = _token; 220 } 221 222 public final void mQUOTE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 223 int _ttype; Token _token=null; int _begin=text.length(); 224 _ttype = QUOTE; 225 int _saveIndex; 226 227 match('\''); 228 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 229 _token = makeToken(_ttype); 230 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 231 } 232 _returnToken = _token; 233 } 234 235 public final void mQDSTRING(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 236 int _ttype; Token _token=null; int _begin=text.length(); 237 _ttype = QDSTRING; 238 int _saveIndex; 239 240 { 241 mQUOTE(false); 242 { 243 _loop11: 244 do { 245 if ((_tokenSet_0.member(LA(1)))) { 246 matchNot('\''); 247 } 248 else { 249 break _loop11; 250 } 251 252 } while (true); 253 } 254 mQUOTE(false); 255 } 256 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 257 _token = makeToken(_ttype); 258 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 259 } 260 _returnToken = _token; 261 } 262 263 264 private static final long[] mk_tokenSet_0() { 265 long[] data = new long[2048]; 266 data[0]=-549755813889L; 267 for (int i = 1; i<=1022; i++) { data[i]=-1L; } 268 data[1023]=9223372036854775807L; 269 return data; 270 } 271 public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); 272 273 }