// $ANTLR 2.7.6 (2005-12-22): "glycoct_grammar.g" -> "GlycoctLexer.java"$
package org.eurocarbdb.sugar.seq.grammar;
import org.eurocarbdb.sugar.Anomer;
import org.eurocarbdb.sugar.SugarRepeatAnnotation;
import java.io.InputStream;
import antlr.TokenStreamException;
import antlr.TokenStreamIOException;
import antlr.TokenStreamRecognitionException;
import antlr.CharStreamException;
import antlr.CharStreamIOException;
import antlr.ANTLRException;
import java.io.Reader;
import java.util.Hashtable;
import antlr.CharScanner;
import antlr.InputBuffer;
import antlr.ByteBuffer;
import antlr.CharBuffer;
import antlr.Token;
import antlr.CommonToken;
import antlr.RecognitionException;
import antlr.NoViableAltForCharException;
import antlr.MismatchedCharException;
import antlr.TokenStream;
import antlr.ANTLRHashString;
import antlr.LexerSharedInputState;
import antlr.collections.impl.BitSet;
import antlr.SemanticException;
/**
*
* This class implements a lexer/scanner for carbohydrate
* sequences in Glycoct syntax. This class was auto-generated from
* the ANTLR lexer grammar in glycoct_grammar.g.
*
* @see GlycoctParser
* @see glycoct_grammar.g
*
* @author mjh [glycoslave@gmail.com]
*/
public class GlycoctLexer extends antlr.CharScanner implements GlycoctParserTokenTypes, TokenStream
{
public GlycoctLexer(InputStream in) {
this(new ByteBuffer(in));
}
public GlycoctLexer(Reader in) {
this(new CharBuffer(in));
}
public GlycoctLexer(InputBuffer ib) {
this(new LexerSharedInputState(ib));
}
public GlycoctLexer(LexerSharedInputState state) {
super(state);
caseSensitiveLiterals = true;
setCaseSensitive(true);
literals = new Hashtable();
literals.put(new ANTLRHashString("R", this), new Integer(20));
}
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 ':':
{
mCOLON(true);
theRetToken=_returnToken;
break;
}
case ',':
{
mCOMMA(true);
theRetToken=_returnToken;
break;
}
case '-':
{
mHYPHEN(true);
theRetToken=_returnToken;
break;
}
case '+':
{
mPLUS(true);
theRetToken=_returnToken;
break;
}
case '=':
{
mEQUALS(true);
theRetToken=_returnToken;
break;
}
case '|':
{
mPIPE(true);
theRetToken=_returnToken;
break;
}
case ';':
{
mSEMICOLON(true);
theRetToken=_returnToken;
break;
}
case '(':
{
mLPARENTHESIS(true);
theRetToken=_returnToken;
break;
}
case ')':
{
mRPARENTHESIS(true);
theRetToken=_returnToken;
break;
}
case '?':
{
mUNKNOWN_TERMINUS(true);
theRetToken=_returnToken;
break;
}
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
{
mINTEGER(true);
theRetToken=_returnToken;
break;
}
case 'L':
{
mLIN(true);
theRetToken=_returnToken;
break;
}
case 'S':
{
mSTA(true);
theRetToken=_returnToken;
break;
}
case 'I':
{
mISO(true);
theRetToken=_returnToken;
break;
}
case 'A':
{
mAGL(true);
theRetToken=_returnToken;
break;
}
case '\t': case '\n': case '\r': case ' ':
{
mWS(true);
theRetToken=_returnToken;
break;
}
default:
if ((LA(1)=='R') && (LA(2)=='E') && (LA(3)=='S')) {
mRES(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='P') && (LA(2)=='R') && (LA(3)=='O')) {
mPRO(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='R') && (LA(2)=='E') && (LA(3)=='P')) {
mREP(true);
theRetToken=_returnToken;
}
else if ((_tokenSet_0.member(LA(1))) && (_tokenSet_1.member(LA(2))) && (_tokenSet_2.member(LA(3)))) {
mMONOSAC_SUPERCLASS(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='b') && (LA(2)==':')) {
mMONOSAC_DECLARATION(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='s') && (LA(2)==':')) {
mSUBSTIT_DECLARATION(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='i') && (LA(2)==':')) {
mINCHI_DECLARATION(true);
theRetToken=_returnToken;
}
else if ((LA(1)=='r') && (LA(2)==':')) {
mREPEAT_DECLARATION(true);
theRetToken=_returnToken;
}
else if (((LA(1) >= 'a' && LA(1) <= 'z')) && (true)) {
mIDENTIFIER(true);
theRetToken=_returnToken;
}
else {
if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
}
}
if ( _returnToken==null ) continue tryAgain; // found SKIP token
_ttype = _returnToken.getType();
_ttype = testLiteralsTable(_ttype);
_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());
}
}
}
}
/** A literal colon ':' */
public final void mCOLON(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = COLON;
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;
}
/** A literal comma ',' */
public final void mCOMMA(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = COMMA;
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;
}
/** A literal hyphen '-' */
public final void mHYPHEN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = HYPHEN;
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 mPLUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = PLUS;
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 mEQUALS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = EQUALS;
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;
}
/** A literal pipe symbol '|' */
public final void mPIPE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = PIPE;
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;
}
/** A literal semicolon ';' */
public final void mSEMICOLON(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = SEMICOLON;
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;
}
/** A literal left parenthesis '(' */
public final void mLPARENTHESIS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = LPARENTHESIS;
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;
}
/** A literal right parenthesis ')' */
public final void mRPARENTHESIS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = RPARENTHESIS;
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;
}
/** A literal '?', indicating an unknown terminal position. */
public final void mUNKNOWN_TERMINUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = UNKNOWN_TERMINUS;
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;
}
/** A literal string "b:", which declares a following monosaccharide section. */
public final void mMONOSAC_DECLARATION(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = MONOSAC_DECLARATION;
int _saveIndex;
match("b:");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/** A literal string "s:", which declares a following substituent section. */
public final void mSUBSTIT_DECLARATION(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = SUBSTIT_DECLARATION;
int _saveIndex;
match("s:");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/** A literal string "i:", which declares a section of INCHI code. */
public final void mINCHI_DECLARATION(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = INCHI_DECLARATION;
int _saveIndex;
match("i:");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/** A literal string "r:", which declares a repeat sub-structure section. */
public final void mREPEAT_DECLARATION(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = REPEAT_DECLARATION;
int _saveIndex;
match("r:");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/** Rule for a (positive) integer, or zero. */
public final void mINTEGER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = INTEGER;
int _saveIndex;
switch ( LA(1)) {
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8':
case '9':
{
{
matchRange('1','9');
}
{
_loop58:
do {
if (((LA(1) >= '0' && LA(1) <= '9'))) {
matchRange('0','9');
}
else {
break _loop58;
}
} while (true);
}
break;
}
case '0':
{
match('0');
break;
}
default:
{
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
}
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/** Rule for an identifier, which may be any alphabetic string. */
public final void mIDENTIFIER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = IDENTIFIER;
int _saveIndex;
{
int _cnt61=0;
_loop61:
do {
if (((LA(1) >= 'a' && LA(1) <= 'z'))) {
matchRange('a','z');
}
else {
if ( _cnt61>=1 ) { break _loop61; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
}
_cnt61++;
} while (true);
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/** Rule for a literal string "RES", identifying a RES section. */
public final void mRES(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = RES;
int _saveIndex;
match("RES");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/** Rule for a literal string "LIN", identifying a LIN section. */
public final void mLIN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = LIN;
int _saveIndex;
match("LIN");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/** Rule for a literal string "PRO", identifying a PRO section. */
public final void mPRO(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = PRO;
int _saveIndex;
match("PRO");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/** Rule for a literal string "REP", identifying a REP section. */
public final void mREP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = REP;
int _saveIndex;
match("REP");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/** Rule for a literal string "STA", identifying a STA section. */
public final void mSTA(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = STA;
int _saveIndex;
match("STA");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/** Rule for a literal string "ISO", identifying a ISO section. */
public final void mISO(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ISO;
int _saveIndex;
match("ISO");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/** Rule for a literal string "AGL", identifying a AGL section. */
public final void mAGL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = AGL;
int _saveIndex;
match("AGL");
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/** Rule for ring size/configuration, eg: hex (for hexose), hept (for heptose). */
public final void mMONOSAC_SUPERCLASS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = MONOSAC_SUPERCLASS;
int _saveIndex;
{
switch ( LA(1)) {
case 'P':
{
match("PEN");
break;
}
case 'N':
{
match("NON");
break;
}
case 'O':
{
match("OCT");
break;
}
default:
if ((LA(1)=='H') && (LA(2)=='E') && (LA(3)=='X')) {
match("HEX");
}
else if ((LA(1)=='H') && (LA(2)=='E') && (LA(3)=='P')) {
match("HEPT");
}
else if ((LA(1)=='T') && (LA(2)=='E')) {
match("TET");
}
else if ((LA(1)=='T') && (LA(2)=='R')) {
match("TRI");
}
else {
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
}
}
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
/**
* The "whitespace" rule, comprising space, tab, and return.
* These tokens are disregarded when parsing.
*/
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;
}
case '\n': case '\r':
{
{
switch ( LA(1)) {
case '\r':
{
{
match('\r');
match('\n');
}
break;
}
case '\n':
{
match('\n');
break;
}
default:
{
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
}
}
}
newline();
break;
}
default:
{
throw new NoViableAltForCharException((char)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;
}
private static final long[] mk_tokenSet_0() {
long[] data = { 0L, 1163520L, 0L, 0L};
return data;
}
public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
private static final long[] mk_tokenSet_1() {
long[] data = { 0L, 294952L, 0L, 0L};
return data;
}
public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
private static final long[] mk_tokenSet_2() {
long[] data = { 0L, 17908224L, 0L, 0L};
return data;
}
public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
}