Package net.sf.jabref.search

Source Code of net.sf.jabref.search.SearchExpressionLexer

// $ANTLR : "Lexer.g" -> "SearchExpressionLexer.java"$

package net.sf.jabref.search;

import java.io.InputStream;
import java.io.Reader;
import java.util.Hashtable;

import antlr.ANTLRHashString;
import antlr.ByteBuffer;
import antlr.CharBuffer;
import antlr.CharStreamException;
import antlr.CharStreamIOException;
import antlr.InputBuffer;
import antlr.LexerSharedInputState;
import antlr.NoViableAltForCharException;
import antlr.RecognitionException;
import antlr.Token;
import antlr.TokenStream;
import antlr.TokenStreamException;
import antlr.TokenStreamIOException;
import antlr.TokenStreamRecognitionException;
import antlr.collections.impl.BitSet;

@SuppressWarnings({"unchecked", "unused"})
public class SearchExpressionLexer extends antlr.CharScanner implements SearchExpressionLexerTokenTypes, TokenStream
{
public SearchExpressionLexer(InputStream in) {
  this(new ByteBuffer(in));
}
public SearchExpressionLexer(Reader in) {
  this(new CharBuffer(in));
}
public SearchExpressionLexer(InputBuffer ib) {
  this(new LexerSharedInputState(ib));
}

public SearchExpressionLexer(LexerSharedInputState state) {
  super(state);
  caseSensitiveLiterals = false;
  setCaseSensitive(false);
  literals = new Hashtable<ANTLRHashString, Integer>();
  literals.put(new ANTLRHashString("matches", this), new Integer(8));
  literals.put(new ANTLRHashString("or", this), new Integer(5));
  literals.put(new ANTLRHashString("and", this), new Integer(4));
  literals.put(new ANTLRHashString("not", this), new Integer(6));
  literals.put(new ANTLRHashString("contains", this), new Integer(7));
}

public Token nextToken() throws TokenStreamException {
  Token theRetToken=null;
tryAgain:
  for (;;) {
    Token _token = null;
    int _ttype = Token.INVALID_TYPE;
    resetText();
    try {   // for char stream error handling
      try {   // for lexical error handling
        switch ( LA(1)) {
        case '\t'case ' ':
        {
          mWS(true);
          theRetToken=_returnToken;
          break;
        }
        case '(':
        {
          mLPAREN(true);
          theRetToken=_returnToken;
          break;
        }
        case ')':
        {
          mRPAREN(true);
          theRetToken=_returnToken;
          break;
        }
        case '!':
        {
          mNEQUAL(true);
          theRetToken=_returnToken;
          break;
        }
        default:
          if ((LA(1)=='=') && (LA(2)=='=')) {
            mEEQUAL(true);
            theRetToken=_returnToken;
          }
          else if ((LA(1)=='"') && ((LA(2) >= '\u0003' && LA(2) <= '\u00ff'))) {
            mSTRING(true);
            theRetToken=_returnToken;
          }
          else if ((LA(1)=='=') && (true)) {
            mEQUAL(true);
            theRetToken=_returnToken;
          }
          else if ((LA(1)=='"') && (true)) {
            mQUOTE(true);
            theRetToken=_returnToken;
          }
          else if ((_tokenSet_0.member(LA(1)))) {
            mFIELDTYPE(true);
            theRetToken=_returnToken;
          }
        else {
          if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
        else {throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
        }
        }
        if ( _returnToken==null ) continue tryAgain; // found SKIP token
        _ttype = _returnToken.getType();
        _returnToken.setType(_ttype);
        return _returnToken;
      }
      catch (RecognitionException e) {
        throw new TokenStreamRecognitionException(e);
      }
    }
    catch (CharStreamException cse) {
      if ( cse instanceof CharStreamIOException ) {
        throw new TokenStreamIOException(((CharStreamIOException)cse).io);
      }
      else {
        throw new TokenStreamException(cse.getMessage());
      }
    }
  }
}

  public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype; Token _token=null; int _begin=text.length();
    _ttype = WS;
   
    int _saveIndex;
   
    {
    switch ( LA(1)) {
    case ' ':
    {
      match(' ');
      break;
    }
    case '\t':
    {
      match('\t');
      break;
    }
    default:
    {
      throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
    }
    }
    }
    _ttype = Token.SKIP;
    if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
      _token = makeToken(_ttype);
      _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
    }
    _returnToken = _token;
  }
 
  public final void mLPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype; Token _token=null; int _begin=text.length();
    _ttype = LPAREN;
    int _saveIndex;
   
    match('(');
    if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
      _token = makeToken(_ttype);
      _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
    }
    _returnToken = _token;
  }
 
  public final void mRPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype; Token _token=null; int _begin=text.length();
    _ttype = RPAREN;
    int _saveIndex;
   
    match(')');
    if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
      _token = makeToken(_ttype);
      _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
    }
    _returnToken = _token;
  }
 
  public final void mEQUAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype; Token _token=null; int _begin=text.length();
    _ttype = EQUAL;
    int _saveIndex;
   
    match("=");
    if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
      _token = makeToken(_ttype);
      _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
    }
    _returnToken = _token;
  }
 
  public final void mEEQUAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype; Token _token=null; int _begin=text.length();
    _ttype = EEQUAL;
    int _saveIndex;
   
    match("==");
    if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
      _token = makeToken(_ttype);
      _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
    }
    _returnToken = _token;
  }
 
  public final void mNEQUAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype; Token _token=null; int _begin=text.length();
    _ttype = NEQUAL;
    int _saveIndex;
   
    match("!=");
    if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
      _token = makeToken(_ttype);
      _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
    }
    _returnToken = _token;
  }
 
  public final void mQUOTE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype; Token _token=null; int _begin=text.length();
    _ttype = QUOTE;
    int _saveIndex;
   
    match('"');
    if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
      _token = makeToken(_ttype);
      _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
    }
    _returnToken = _token;
  }
 
  public final void mSTRING(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype; Token _token=null; int _begin=text.length();
    _ttype = STRING;
    int _saveIndex;
   
    _saveIndex=text.length();
    mQUOTE(false);
    text.setLength(_saveIndex);
    {
    _loop28:
    do {
      if ((_tokenSet_1.member(LA(1)))) {
        matchNot('"');
      }
      else {
        break _loop28;
      }
     
    } while (true);
    }
    _saveIndex=text.length();
    mQUOTE(false);
    text.setLength(_saveIndex);
    if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
      _token = makeToken(_ttype);
      _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
    }
    _returnToken = _token;
  }
 
  protected final void mLETTER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype; Token _token=null; int _begin=text.length();
    _ttype = LETTER;
    int _saveIndex;
   
    {
    match(_tokenSet_0);
    }
    _ttype = testLiteralsTable(new String(text.getBuffer(),_begin,text.length()-_begin),_ttype);
    if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
      _token = makeToken(_ttype);
      _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
    }
    _returnToken = _token;
  }
 
  public final void mFIELDTYPE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
    int _ttype; Token _token=null; int _begin=text.length();
    _ttype = FIELDTYPE;
    int _saveIndex;
   
    {
    int _cnt33=0;
    _loop33:
    do {
      if ((_tokenSet_0.member(LA(1)))) {
        mLETTER(false);
      }
      else {
        if ( _cnt33>=1 ) { break _loop33; } else {throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
      }
     
      _cnt33++;
    } while (true);
    }
    _ttype = testLiteralsTable(_ttype);
    if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
      _token = makeToken(_ttype);
      _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
    }
    _returnToken = _token;
  }
 
 
  private static final long[] mk_tokenSet_0() {
    long[] data = new long[8];
    data[0]=-2305846337813348872L;
    for (int i = 1; i<=3; i++) { data[i]=-1L; }
    return data;
  }
  public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
  private static final long[] mk_tokenSet_1() {
    long[] data = new long[8];
    data[0]=-17179869192L;
    for (int i = 1; i<=3; i++) { data[i]=-1L; }
    return data;
  }
  public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
 
  }
TOP

Related Classes of net.sf.jabref.search.SearchExpressionLexer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.