001 // $ANTLR 2.7.4: "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 */
022 package org.apache.directory.shared.ldap.schema.syntax;
023
024 import java.util.ArrayList;
025 import java.util.List;
026
027 import org.apache.directory.shared.ldap.schema.parsers.ParserMonitor;
028
029
030 import java.io.InputStream;
031 import antlr.TokenStreamException;
032 import antlr.TokenStreamIOException;
033 import antlr.TokenStreamRecognitionException;
034 import antlr.CharStreamException;
035 import antlr.CharStreamIOException;
036 import antlr.ANTLRException;
037 import java.io.Reader;
038 import java.util.Hashtable;
039 import antlr.CharScanner;
040 import antlr.InputBuffer;
041 import antlr.ByteBuffer;
042 import antlr.CharBuffer;
043 import antlr.Token;
044 import antlr.CommonToken;
045 import antlr.RecognitionException;
046 import antlr.NoViableAltForCharException;
047 import antlr.MismatchedCharException;
048 import antlr.TokenStream;
049 import antlr.ANTLRHashString;
050 import antlr.LexerSharedInputState;
051 import antlr.collections.impl.BitSet;
052 import 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 * @version $Rev$
059 */
060 public class AntlrSchemaQdstringLexer extends antlr.CharScanner implements AntlrSchemaQdstringTokenTypes, TokenStream
061 {
062 public AntlrSchemaQdstringLexer(InputStream in) {
063 this(new ByteBuffer(in));
064 }
065 public AntlrSchemaQdstringLexer(Reader in) {
066 this(new CharBuffer(in));
067 }
068 public AntlrSchemaQdstringLexer(InputBuffer ib) {
069 this(new LexerSharedInputState(ib));
070 }
071 public AntlrSchemaQdstringLexer(LexerSharedInputState state) {
072 super(state);
073 caseSensitiveLiterals = true;
074 setCaseSensitive(false);
075 literals = new Hashtable();
076 }
077
078 public Token nextToken() throws TokenStreamException {
079 Token theRetToken=null;
080 tryAgain:
081 for (;;) {
082 Token _token = null;
083 int _ttype = Token.INVALID_TYPE;
084 resetText();
085 try { // for char stream error handling
086 try { // for lexical error handling
087 switch ( LA(1)) {
088 case '\t': case '\n': case '\r': case ' ':
089 {
090 mWHSP(true);
091 theRetToken=_returnToken;
092 break;
093 }
094 case '(':
095 {
096 mLPAR(true);
097 theRetToken=_returnToken;
098 break;
099 }
100 case ')':
101 {
102 mRPAR(true);
103 theRetToken=_returnToken;
104 break;
105 }
106 default:
107 if ((LA(1)=='\'') && ((LA(2) >= '\u0000' && LA(2) <= '\ufffe'))) {
108 mQDSTRING(true);
109 theRetToken=_returnToken;
110 }
111 else if ((LA(1)=='\'') && (true)) {
112 mQUOTE(true);
113 theRetToken=_returnToken;
114 }
115 else {
116 if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
117 else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
118 }
119 }
120 if ( _returnToken==null ) continue tryAgain; // found SKIP token
121 _ttype = _returnToken.getType();
122 _ttype = testLiteralsTable(_ttype);
123 _returnToken.setType(_ttype);
124 return _returnToken;
125 }
126 catch (RecognitionException e) {
127 throw new TokenStreamRecognitionException(e);
128 }
129 }
130 catch (CharStreamException cse) {
131 if ( cse instanceof CharStreamIOException ) {
132 throw new TokenStreamIOException(((CharStreamIOException)cse).io);
133 }
134 else {
135 throw new TokenStreamException(cse.getMessage());
136 }
137 }
138 }
139 }
140
141 public final void mWHSP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
142 int _ttype; Token _token=null; int _begin=text.length();
143 _ttype = WHSP;
144 int _saveIndex;
145
146 {
147 int _cnt950=0;
148 _loop950:
149 do {
150 switch ( LA(1)) {
151 case ' ':
152 {
153 match(' ');
154 break;
155 }
156 case '\t':
157 {
158 match('\t');
159 break;
160 }
161 case '\r':
162 {
163 match('\r');
164 {
165 if ((LA(1)=='\n') && (true)) {
166 match('\n');
167 }
168 else {
169 }
170
171 }
172 newline();
173 break;
174 }
175 case '\n':
176 {
177 match('\n');
178 newline();
179 break;
180 }
181 default:
182 {
183 if ( _cnt950>=1 ) { break _loop950; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
184 }
185 }
186 _cnt950++;
187 } while (true);
188 }
189 _ttype = Token.SKIP;
190 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
191 _token = makeToken(_ttype);
192 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
193 }
194 _returnToken = _token;
195 }
196
197 public final void mLPAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
198 int _ttype; Token _token=null; int _begin=text.length();
199 _ttype = LPAR;
200 int _saveIndex;
201
202 match('(');
203 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
204 _token = makeToken(_ttype);
205 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
206 }
207 _returnToken = _token;
208 }
209
210 public final void mRPAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
211 int _ttype; Token _token=null; int _begin=text.length();
212 _ttype = RPAR;
213 int _saveIndex;
214
215 match(')');
216 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
217 _token = makeToken(_ttype);
218 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
219 }
220 _returnToken = _token;
221 }
222
223 public final void mQUOTE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
224 int _ttype; Token _token=null; int _begin=text.length();
225 _ttype = QUOTE;
226 int _saveIndex;
227
228 match('\'');
229 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
230 _token = makeToken(_ttype);
231 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
232 }
233 _returnToken = _token;
234 }
235
236 public final void mQDSTRING(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
237 int _ttype; Token _token=null; int _begin=text.length();
238 _ttype = QDSTRING;
239 int _saveIndex;
240
241 {
242 mQUOTE(false);
243 {
244 _loop957:
245 do {
246 if ((_tokenSet_0.member(LA(1)))) {
247 matchNot('\'');
248 }
249 else {
250 break _loop957;
251 }
252
253 } while (true);
254 }
255 mQUOTE(false);
256 }
257 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
258 _token = makeToken(_ttype);
259 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
260 }
261 _returnToken = _token;
262 }
263
264
265 private static final long[] mk_tokenSet_0() {
266 long[] data = new long[2048];
267 data[0]=-549755813889L;
268 for (int i = 1; i<=1022; i++) { data[i]=-1L; }
269 data[1023]=9223372036854775807L;
270 return data;
271 }
272 public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
273
274 }