// $ANTLR 2.7.5 (20050128): "JAMParser.g" -> "JAMLexer.java"$

package at.oefai.aaa.agent.jam;

// StefanRank: rewrite of JAMParser.jj (the JavaCC grammar for JAM) for ANTLR
// (because ANTLR also allows the generation of a Parser using Python/C++)

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;

// JAMLexer prefix

/**
 * The JAMLexer defines the translation from a character stream (file)
 * to a stream of tokens that can be read by the JAMParser.
 * @author StefanRank
 */
public class JAMLexer extends antlr.CharScanner implements JAMParserTokenTypes, TokenStream
 {

// optional action for instance vars/methods
public JAMLexer(InputStream in) {
    this(new ByteBuffer(in));
}
public JAMLexer(Reader in) {
    this(new CharBuffer(in));
}
public JAMLexer(InputBuffer ib) {
    this(new LexerSharedInputState(ib));
}
public JAMLexer(LexerSharedInputState state) {
    super(state);
    caseSensitiveLiterals = true;
    setCaseSensitive(true);
    literals = new Hashtable();
    literals.put(new ANTLRHashString("DOCUMENTATION", this), new Integer(14));
    literals.put(new ANTLRHashString("ASSERT", this), new Integer(19));
    literals.put(new ANTLRHashString("EFFECTS", this), new Integer(24));
    literals.put(new ANTLRHashString("FACTS", this), new Integer(6));
    literals.put(new ANTLRHashString("FAIL", this), new Integer(50));
    literals.put(new ANTLRHashString("WHILE", this), new Integer(33));
    literals.put(new ANTLRHashString("UPDATE", this), new Integer(45));
    literals.put(new ANTLRHashString("QUERY", this), new Integer(59));
    literals.put(new ANTLRHashString("ATOMIC", this), new Integer(35));
    literals.put(new ANTLRHashString("BODY", this), new Integer(26));
    literals.put(new ANTLRHashString("CONCLUDE", this), new Integer(17));
    literals.put(new ANTLRHashString("MAINTAIN", this), new Integer(58));
    literals.put(new ANTLRHashString("PARALLEL", this), new Integer(29));
    literals.put(new ANTLRHashString("UTILITY", this), new Integer(23));
    literals.put(new ANTLRHashString("PARSE", this), new Integer(67));
    literals.put(new ANTLRHashString("FAILURE", this), new Integer(25));
    literals.put(new ANTLRHashString("PERCEIVE", this), new Integer(18));
    literals.put(new ANTLRHashString("RETRACT", this), new Integer(20));
    literals.put(new ANTLRHashString("PLAN", this), new Integer(10));
    literals.put(new ANTLRHashString("RETRIEVE", this), new Integer(37));
    literals.put(new ANTLRHashString("PERFORM", this), new Integer(57));
    literals.put(new ANTLRHashString("ASSIGN", this), new Integer(48));
    literals.put(new ANTLRHashString("GOAL", this), new Integer(16));
    literals.put(new ANTLRHashString("UNPOST", this), new Integer(52));
    literals.put(new ANTLRHashString("WAIT", this), new Integer(36));
    literals.put(new ANTLRHashString("NAME", this), new Integer(13));
    literals.put(new ANTLRHashString("ATTRIBUTES", this), new Integer(15));
    literals.put(new ANTLRHashString("ACHIEVE", this), new Integer(56));
    literals.put(new ANTLRHashString("AND", this), new Integer(27));
    literals.put(new ANTLRHashString("CONTEXT", this), new Integer(21));
    literals.put(new ANTLRHashString("GOALS", this), new Integer(4));
    literals.put(new ANTLRHashString("DO", this), new Integer(34));
    literals.put(new ANTLRHashString("PRECONDITION", this), new Integer(22));
    literals.put(new ANTLRHashString("NEXTFACT", this), new Integer(43));
    literals.put(new ANTLRHashString("RETRIEVEALL", this), new Integer(42));
    literals.put(new ANTLRHashString("SUCCEED", this), new Integer(49));
    literals.put(new ANTLRHashString("EXECUTE", this), new Integer(38));
    literals.put(new ANTLRHashString("WHEN", this), new Integer(32));
    literals.put(new ANTLRHashString("LOAD", this), new Integer(41));
    literals.put(new ANTLRHashString("DO_ANY", this), new Integer(31));
    literals.put(new ANTLRHashString("OBSERVER", this), new Integer(7));
    literals.put(new ANTLRHashString("TEST", this), new Integer(44));
    literals.put(new ANTLRHashString("POST", this), new Integer(51));
    literals.put(new ANTLRHashString("OR", this), new Integer(28));
    literals.put(new ANTLRHashString("FACT", this), new Integer(12));
    literals.put(new ANTLRHashString("DO_ALL", this), new Integer(30));
}

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 '\n':  case '\u000c':  case '\r':
                case ' ':
                {
                    mWHITESPACE(true);
                    theRetToken=_returnToken;
                    break;
                }
                case '"':
                {
                    mSTRING(true);
                    theRetToken=_returnToken;
                    break;
                }
                case ';':
                {
                    mSEMICOLON(true);
                    theRetToken=_returnToken;
                    break;
                }
                case '{':
                {
                    mLEFT_BRACE(true);
                    theRetToken=_returnToken;
                    break;
                }
                case '}':
                {
                    mRIGHT_BRACE(true);
                    theRetToken=_returnToken;
                    break;
                }
                case '(':
                {
                    mLEFT_PAREN(true);
                    theRetToken=_returnToken;
                    break;
                }
                case ')':
                {
                    mRIGHT_PAREN(true);
                    theRetToken=_returnToken;
                    break;
                }
                case '[':
                {
                    mLEFT_BRACKET(true);
                    theRetToken=_returnToken;
                    break;
                }
                case ']':
                {
                    mRIGHT_BRACKET(true);
                    theRetToken=_returnToken;
                    break;
                }
                case '+':  case '-':  case '.':  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 'A':  case 'B':  case 'C':  case 'D':
                case 'E':  case 'F':  case 'G':  case 'H':
                case 'I':  case 'J':  case 'K':  case 'L':
                case 'M':  case 'N':  case 'O':  case 'P':
                case 'Q':  case 'R':  case 'S':  case 'T':
                case 'U':  case 'V':  case 'W':  case 'X':
                case 'Y':  case 'Z':  case '_':  case 'a':
                case 'b':  case 'c':  case 'd':  case 'e':
                case 'f':  case 'g':  case 'h':  case 'i':
                case 'j':  case 'k':  case 'l':  case 'm':
                case 'n':  case 'o':  case 'p':  case 'q':
                case 'r':  case 's':  case 't':  case 'u':
                case 'v':  case 'w':  case 'x':  case 'y':
                case 'z':
                {
                    mIDENTIFIER(true);
                    theRetToken=_returnToken;
                    break;
                }
                case '$':
                {
                    mVARIABLE(true);
                    theRetToken=_returnToken;
                    break;
                }
                default:
                    if ((LA(1)=='/') && (LA(2)=='/')) {
                        mSINGLE_LINE_COMMENT(true);
                        theRetToken=_returnToken;
                    }
                    else if ((LA(1)=='/') && (LA(2)=='*')) {
                        mMULTI_LINE_COMMENT(true);
                        theRetToken=_returnToken;
                    }
                    else if ((LA(1)==':') && (LA(2)=='T')) {
                        mKEYWORD_TEST(true);
                        theRetToken=_returnToken;
                    }
                    else if ((LA(1)==':') && (LA(2)=='U')) {
                        mKEYWORD_UTILITY(true);
                        theRetToken=_returnToken;
                    }
                    else if ((LA(1)==':') && (LA(2)=='B')) {
                        mKEYWORD_BY(true);
                        theRetToken=_returnToken;
                    }
                    else if ((LA(1)==':') && (LA(2)=='N')) {
                        mKEYWORD_NOT_BY(true);
                        theRetToken=_returnToken;
                    }
                    else if ((LA(1)==':') && (true)) {
                        mCOLON(true);
                        theRetToken=_returnToken;
                    }
                    else if ((_tokenSet_0.member(LA(1))) && (true)) {
                        mSPECIAL_FUNCTION_NAME(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();
                _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 mWHITESPACE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = WHITESPACE;
        int _saveIndex;

        {
        int _cnt115=0;
        _loop115:
        do {
            if ((_tokenSet_1.member(LA(1)))) {
                mDELIMIT_CHAR(false);
            }
            else {
                if ( _cnt115>=1 ) { break _loop115; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
            }

            _cnt115++;
        } while (true);
        }
        if ( inputState.guessing==0 ) {
            _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;
    }

    protected final void mDELIMIT_CHAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = DELIMIT_CHAR;
        int _saveIndex;

        {
        switch ( LA(1)) {
        case ' ':
        {
            match(' ');
            break;
        }
        case '\t':
        {
            match('\t');
            break;
        }
        case '\n':
        {
            match('\n');
            if ( inputState.guessing==0 ) {
                newline();
            }
            break;
        }
        case '\r':
        {
            match('\r');
            break;
        }
        case '\u000c':
        {
            match('\f');
            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;
    }

    public final void mSINGLE_LINE_COMMENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = SINGLE_LINE_COMMENT;
        int _saveIndex;

        match("//");
        {
        _loop120:
        do {
            if ((_tokenSet_2.member(LA(1)))) {
                matchNot('\n');
            }
            else {
                break _loop120;
            }

        } while (true);
        }
        match('\n');
        if ( inputState.guessing==0 ) {

            _ttype = Token.SKIP;
            newline();

        }
        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 mMULTI_LINE_COMMENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = MULTI_LINE_COMMENT;
        int _saveIndex;

        match("/*");
        {
        _loop124:
        do {
            if (((LA(1)=='*') && ((LA(2) >= '\u0000' && LA(2) <= '\ufffe')) && ((LA(3) >= '\u0000' && LA(3) <= '\ufffe')))&&( LA(2)!='/' )) {
                match('*');
            }
            else if ((LA(1)=='\n')) {
                match('\n');
                if ( inputState.guessing==0 ) {
                    newline();
                }
            }
            else if ((_tokenSet_3.member(LA(1)))) {
                {
                match(_tokenSet_3);
                }
            }
            else {
                break _loop124;
            }

        } while (true);
        }
        match("*/");
        if ( inputState.guessing==0 ) {
            _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 mSTRING(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = STRING;
        int _saveIndex;

        _saveIndex=text.length();
        match('"');
        text.setLength(_saveIndex);
        {
        _loop128:
        do {
            if ((LA(1)=='\\')) {
                mESCAPE(false);
            }
            else if ((_tokenSet_4.member(LA(1)))) {
                {
                match(_tokenSet_4);
                }
            }
            else {
                break _loop128;
            }

        } while (true);
        }
        _saveIndex=text.length();
        match('"');
        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 mESCAPE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = ESCAPE;
        int _saveIndex;

        match('\\');
        {
        switch ( LA(1)) {
        case 'n':
        {
            match('n');
            if ( inputState.guessing==0 ) {
                text.setLength(_begin); text.append("\n");
            }
            break;
        }
        case 'r':
        {
            match('r');
            if ( inputState.guessing==0 ) {
                text.setLength(_begin); text.append("\r");
            }
            break;
        }
        case 't':
        {
            match('t');
            if ( inputState.guessing==0 ) {
                text.setLength(_begin); text.append("\t");
            }
            break;
        }
        case 'f':
        {
            match('f');
            if ( inputState.guessing==0 ) {
                text.setLength(_begin); text.append("\f");
            }
            break;
        }
        case '"':
        {
            match('"');
            if ( inputState.guessing==0 ) {
                text.setLength(_begin); text.append("\"");
            }
            break;
        }
        case '\\':
        {
            match('\\');
            if ( inputState.guessing==0 ) {
                text.setLength(_begin); text.append("\\");
            }
            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;
    }

    protected final void mID_START_LETTER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = ID_START_LETTER;
        int _saveIndex;

        {
        switch ( LA(1)) {
        case '_':
        {
            match('_');
            break;
        }
        case 'A':  case 'B':  case 'C':  case 'D':
        case 'E':  case 'F':  case 'G':  case 'H':
        case 'I':  case 'J':  case 'K':  case 'L':
        case 'M':  case 'N':  case 'O':  case 'P':
        case 'Q':  case 'R':  case 'S':  case 'T':
        case 'U':  case 'V':  case 'W':  case 'X':
        case 'Y':  case 'Z':
        {
            matchRange('A','Z');
            break;
        }
        case 'a':  case 'b':  case 'c':  case 'd':
        case 'e':  case 'f':  case 'g':  case 'h':
        case 'i':  case 'j':  case 'k':  case 'l':
        case 'm':  case 'n':  case 'o':  case 'p':
        case 'q':  case 'r':  case 's':  case 't':
        case 'u':  case 'v':  case 'w':  case 'x':
        case 'y':  case 'z':
        {
            matchRange('a','z');
            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;
    }

    protected final void mLETTER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = LETTER;
        int _saveIndex;

        {
        switch ( LA(1)) {
        case '-':
        {
            match('-');
            break;
        }
        case 'A':  case 'B':  case 'C':  case 'D':
        case 'E':  case 'F':  case 'G':  case 'H':
        case 'I':  case 'J':  case 'K':  case 'L':
        case 'M':  case 'N':  case 'O':  case 'P':
        case 'Q':  case 'R':  case 'S':  case 'T':
        case 'U':  case 'V':  case 'W':  case 'X':
        case 'Y':  case 'Z':  case '_':  case 'a':
        case 'b':  case 'c':  case 'd':  case 'e':
        case 'f':  case 'g':  case 'h':  case 'i':
        case 'j':  case 'k':  case 'l':  case 'm':
        case 'n':  case 'o':  case 'p':  case 'q':
        case 'r':  case 's':  case 't':  case 'u':
        case 'v':  case 'w':  case 'x':  case 'y':
        case 'z':
        {
            mID_START_LETTER(false);
            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;
    }

    public final void mKEYWORD_TEST(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = KEYWORD_TEST;
        int _saveIndex;

        match(":TEST");
        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 mKEYWORD_UTILITY(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = KEYWORD_UTILITY;
        int _saveIndex;

        match(":UTILITY");
        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 mKEYWORD_BY(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = KEYWORD_BY;
        int _saveIndex;

        match(":BY");
        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 mKEYWORD_NOT_BY(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = KEYWORD_NOT_BY;
        int _saveIndex;

        match(":NOT-BY");
        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 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;
    }

    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;
    }

    public final void mLEFT_BRACE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = LEFT_BRACE;
        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 mRIGHT_BRACE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = RIGHT_BRACE;
        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 mLEFT_PAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = LEFT_PAREN;
        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 mRIGHT_PAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = RIGHT_PAREN;
        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 mLEFT_BRACKET(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = LEFT_BRACKET;
        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 mRIGHT_BRACKET(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = RIGHT_BRACKET;
        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;
    }

    protected final void mDIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = DIGIT;
        int _saveIndex;

        {
        matchRange('0','9');
        }
        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 mEXPONENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = EXPONENT;
        int _saveIndex;

        {
        switch ( LA(1)) {
        case 'e':
        {
            match('e');
            break;
        }
        case 'E':
        {
            match('E');
            break;
        }
        default:
        {
            throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
        }
        }
        }
        {
        switch ( LA(1)) {
        case '+':
        {
            match('+');
            break;
        }
        case '-':
        {
            match('-');
            break;
        }
        case '0':  case '1':  case '2':  case '3':
        case '4':  case '5':  case '6':  case '7':
        case '8':  case '9':
        {
            break;
        }
        default:
        {
            throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
        }
        }
        }
        {
        int _cnt153=0;
        _loop153:
        do {
            if (((LA(1) >= '0' && LA(1) <= '9'))) {
                mDIGIT(false);
            }
            else {
                if ( _cnt153>=1 ) { break _loop153; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
            }

            _cnt153++;
        } while (true);
        }
        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 mINTEGER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = INTEGER;
        int _saveIndex;

        boolean isDecimal = false;


        {
        boolean synPredMatched158 = false;
        if (((LA(1)=='+'||LA(1)=='-') && (true) && (true))) {
            int _m158 = mark();
            synPredMatched158 = true;
            inputState.guessing++;
            try {
                {
                {
                switch ( LA(1)) {
                case '+':
                {
                    match('+');
                    break;
                }
                case '-':
                {
                    match('-');
                    break;
                }
                default:
                {
                    throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
                }
                }
                }
                mDELIMIT_CHAR(false);
                }
            }
            catch (RecognitionException pe) {
                synPredMatched158 = false;
            }
            rewind(_m158);
            inputState.guessing--;
        }
        if ( synPredMatched158 ) {
            {
            switch ( LA(1)) {
            case '+':
            {
                match('+');
                break;
            }
            case '-':
            {
                match('-');
                break;
            }
            default:
            {
                throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
            }
            }
            }
            if ( inputState.guessing==0 ) {
                _ttype = SPECIAL_FUNCTION_NAME;
            }
        }
        else if ((_tokenSet_5.member(LA(1))) && (true) && (true)) {
            {
            switch ( LA(1)) {
            case '+':
            {
                match('+');
                break;
            }
            case '-':
            {
                match('-');
                break;
            }
            case '.':  case '0':  case '1':  case '2':
            case '3':  case '4':  case '5':  case '6':
            case '7':  case '8':  case '9':
            {
                break;
            }
            default:
            {
                throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
            }
            }
            }
            {
            switch ( LA(1)) {
            case '.':
            {
                match('.');
                {
                int _cnt163=0;
                _loop163:
                do {
                    if (((LA(1) >= '0' && LA(1) <= '9'))) {
                        mDIGIT(false);
                    }
                    else {
                        if ( _cnt163>=1 ) { break _loop163; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
                    }

                    _cnt163++;
                } while (true);
                }
                {
                if ((LA(1)=='E'||LA(1)=='e')) {
                    mEXPONENT(false);
                }
                else {
                }

                }
                if ( inputState.guessing==0 ) {
                    _ttype = FLOAT;
                }
                break;
            }
            case '0':  case '1':  case '2':  case '3':
            case '4':  case '5':  case '6':  case '7':
            case '8':  case '9':
            {
                {
                switch ( LA(1)) {
                case '0':
                {
                    match('0');
                    if ( inputState.guessing==0 ) {
                        isDecimal = true;
                    }
                    break;
                }
                case '1':  case '2':  case '3':  case '4':
                case '5':  case '6':  case '7':  case '8':
                case '9':
                {
                    {
                    matchRange('1','9');
                    }
                    {
                    _loop168:
                    do {
                        if (((LA(1) >= '0' && LA(1) <= '9'))) {
                            mDIGIT(false);
                        }
                        else {
                            break _loop168;
                        }

                    } while (true);
                    }
                    if ( inputState.guessing==0 ) {
                        isDecimal = true;
                    }
                    break;
                }
                default:
                {
                    throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
                }
                }
                }
                {
                if (((LA(1)=='.'||LA(1)=='E'||LA(1)=='e'))&&( isDecimal )) {
                    {
                    switch ( LA(1)) {
                    case '.':
                    {
                        match('.');
                        {
                        _loop172:
                        do {
                            if (((LA(1) >= '0' && LA(1) <= '9'))) {
                                mDIGIT(false);
                            }
                            else {
                                break _loop172;
                            }

                        } while (true);
                        }
                        {
                        if ((LA(1)=='E'||LA(1)=='e')) {
                            mEXPONENT(false);
                        }
                        else {
                        }

                        }
                        break;
                    }
                    case 'E':  case 'e':
                    {
                        mEXPONENT(false);
                        break;
                    }
                    default:
                    {
                        throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
                    }
                    }
                    }
                    if ( inputState.guessing==0 ) {
                        _ttype = FLOAT;
                    }
                }
                else {
                }

                }
                break;
            }
            default:
            {
                throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
            }
            }
            }
        }
        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;
    }

    public final void mIDENTIFIER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = IDENTIFIER;
        int _saveIndex;

        {
        boolean synPredMatched179 = false;
        if (((_tokenSet_6.member(LA(1))) && (_tokenSet_7.member(LA(2))) && (_tokenSet_7.member(LA(3))))) {
            int _m179 = mark();
            synPredMatched179 = true;
            inputState.guessing++;
            try {
                {
                mID_START_LETTER(false);
                {
                _loop178:
                do {
                    switch ( LA(1)) {
                    case '-':  case 'A':  case 'B':  case 'C':
                    case 'D':  case 'E':  case 'F':  case 'G':
                    case 'H':  case 'I':  case 'J':  case 'K':
                    case 'L':  case 'M':  case 'N':  case 'O':
                    case 'P':  case 'Q':  case 'R':  case 'S':
                    case 'T':  case 'U':  case 'V':  case 'W':
                    case 'X':  case 'Y':  case 'Z':  case '_':
                    case 'a':  case 'b':  case 'c':  case 'd':
                    case 'e':  case 'f':  case 'g':  case 'h':
                    case 'i':  case 'j':  case 'k':  case 'l':
                    case 'm':  case 'n':  case 'o':  case 'p':
                    case 'q':  case 'r':  case 's':  case 't':
                    case 'u':  case 'v':  case 'w':  case 'x':
                    case 'y':  case 'z':
                    {
                        mLETTER(false);
                        break;
                    }
                    case '0':  case '1':  case '2':  case '3':
                    case '4':  case '5':  case '6':  case '7':
                    case '8':  case '9':
                    {
                        mDIGIT(false);
                        break;
                    }
                    default:
                    {
                        break _loop178;
                    }
                    }
                } while (true);
                }
                match('.');
                }
            }
            catch (RecognitionException pe) {
                synPredMatched179 = false;
            }
            rewind(_m179);
            inputState.guessing--;
        }
        if ( synPredMatched179 ) {
            mID_START_LETTER(false);
            {
            _loop181:
            do {
                switch ( LA(1)) {
                case '-':  case 'A':  case 'B':  case 'C':
                case 'D':  case 'E':  case 'F':  case 'G':
                case 'H':  case 'I':  case 'J':  case 'K':
                case 'L':  case 'M':  case 'N':  case 'O':
                case 'P':  case 'Q':  case 'R':  case 'S':
                case 'T':  case 'U':  case 'V':  case 'W':
                case 'X':  case 'Y':  case 'Z':  case '_':
                case 'a':  case 'b':  case 'c':  case 'd':
                case 'e':  case 'f':  case 'g':  case 'h':
                case 'i':  case 'j':  case 'k':  case 'l':
                case 'm':  case 'n':  case 'o':  case 'p':
                case 'q':  case 'r':  case 's':  case 't':
                case 'u':  case 'v':  case 'w':  case 'x':
                case 'y':  case 'z':
                {
                    mLETTER(false);
                    break;
                }
                case '0':  case '1':  case '2':  case '3':
                case '4':  case '5':  case '6':  case '7':
                case '8':  case '9':
                {
                    mDIGIT(false);
                    break;
                }
                default:
                {
                    break _loop181;
                }
                }
            } while (true);
            }
            {
            int _cnt185=0;
            _loop185:
            do {
                if ((LA(1)=='.')) {
                    match('.');
                    mID_START_LETTER(false);
                    {
                    _loop184:
                    do {
                        switch ( LA(1)) {
                        case '-':  case 'A':  case 'B':  case 'C':
                        case 'D':  case 'E':  case 'F':  case 'G':
                        case 'H':  case 'I':  case 'J':  case 'K':
                        case 'L':  case 'M':  case 'N':  case 'O':
                        case 'P':  case 'Q':  case 'R':  case 'S':
                        case 'T':  case 'U':  case 'V':  case 'W':
                        case 'X':  case 'Y':  case 'Z':  case '_':
                        case 'a':  case 'b':  case 'c':  case 'd':
                        case 'e':  case 'f':  case 'g':  case 'h':
                        case 'i':  case 'j':  case 'k':  case 'l':
                        case 'm':  case 'n':  case 'o':  case 'p':
                        case 'q':  case 'r':  case 's':  case 't':
                        case 'u':  case 'v':  case 'w':  case 'x':
                        case 'y':  case 'z':
                        {
                            mLETTER(false);
                            break;
                        }
                        case '0':  case '1':  case '2':  case '3':
                        case '4':  case '5':  case '6':  case '7':
                        case '8':  case '9':
                        {
                            mDIGIT(false);
                            break;
                        }
                        default:
                        {
                            break _loop184;
                        }
                        }
                    } while (true);
                    }
                }
                else {
                    if ( _cnt185>=1 ) { break _loop185; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
                }

                _cnt185++;
            } while (true);
            }
            if ( inputState.guessing==0 ) {
                _ttype = CLASS_IDENTIFIER;
            }
        }
        else if ((_tokenSet_6.member(LA(1))) && (true) && (true)) {
            mID_START_LETTER(false);
            {
            _loop187:
            do {
                switch ( LA(1)) {
                case '-':  case 'A':  case 'B':  case 'C':
                case 'D':  case 'E':  case 'F':  case 'G':
                case 'H':  case 'I':  case 'J':  case 'K':
                case 'L':  case 'M':  case 'N':  case 'O':
                case 'P':  case 'Q':  case 'R':  case 'S':
                case 'T':  case 'U':  case 'V':  case 'W':
                case 'X':  case 'Y':  case 'Z':  case '_':
                case 'a':  case 'b':  case 'c':  case 'd':
                case 'e':  case 'f':  case 'g':  case 'h':
                case 'i':  case 'j':  case 'k':  case 'l':
                case 'm':  case 'n':  case 'o':  case 'p':
                case 'q':  case 'r':  case 's':  case 't':
                case 'u':  case 'v':  case 'w':  case 'x':
                case 'y':  case 'z':
                {
                    mLETTER(false);
                    break;
                }
                case '0':  case '1':  case '2':  case '3':
                case '4':  case '5':  case '6':  case '7':
                case '8':  case '9':
                {
                    mDIGIT(false);
                    break;
                }
                default:
                {
                    break _loop187;
                }
                }
            } while (true);
            }
        }
        else {
            throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
        }

        }
        _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;
    }

    public final void mVARIABLE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = VARIABLE;
        int _saveIndex;

        match('$');
        {
        int _cnt190=0;
        _loop190:
        do {
            switch ( LA(1)) {
            case '-':  case 'A':  case 'B':  case 'C':
            case 'D':  case 'E':  case 'F':  case 'G':
            case 'H':  case 'I':  case 'J':  case 'K':
            case 'L':  case 'M':  case 'N':  case 'O':
            case 'P':  case 'Q':  case 'R':  case 'S':
            case 'T':  case 'U':  case 'V':  case 'W':
            case 'X':  case 'Y':  case 'Z':  case '_':
            case 'a':  case 'b':  case 'c':  case 'd':
            case 'e':  case 'f':  case 'g':  case 'h':
            case 'i':  case 'j':  case 'k':  case 'l':
            case 'm':  case 'n':  case 'o':  case 'p':
            case 'q':  case 'r':  case 's':  case 't':
            case 'u':  case 'v':  case 'w':  case 'x':
            case 'y':  case 'z':
            {
                mLETTER(false);
                break;
            }
            case '0':  case '1':  case '2':  case '3':
            case '4':  case '5':  case '6':  case '7':
            case '8':  case '9':
            {
                mDIGIT(false);
                break;
            }
            case '.':
            {
                match('.');
                break;
            }
            default:
            {
                if ( _cnt190>=1 ) { break _loop190; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
            }
            }
            _cnt190++;
        } while (true);
        }
        if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
            _token = makeToken(_ttype);
            _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
        }
        _returnToken = _token;
    }

/** Plus and Minus get a special case to allow recognising them directly in
 * front of numbers as part of the numbers, as a function they need whitespace. */
    public final void mSPECIAL_FUNCTION_NAME(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
        int _ttype; Token _token=null; int _begin=text.length();
        _ttype = SPECIAL_FUNCTION_NAME;
        int _saveIndex;

        {
        switch ( LA(1)) {
        case '*':
        {
            match('*');
            break;
        }
        case '/':
        {
            match('/');
            break;
        }
        case '%':
        {
            match('%');
            break;
        }
        case '=':
        {
            match("==");
            break;
        }
        case '&':
        {
            match("&&");
            break;
        }
        case '|':
        {
            match("||");
            break;
        }
        default:
            if ((LA(1)=='!') && (LA(2)=='=')) {
                match("!=");
            }
            else if ((LA(1)=='<') && (LA(2)=='=')) {
                match("<=");
            }
            else if ((LA(1)=='>') && (LA(2)=='=')) {
                match(">=");
            }
            else if ((LA(1)=='<') && (true)) {
                match('<');
            }
            else if ((LA(1)=='>') && (true)) {
                match('>');
            }
            else if ((LA(1)=='!') && (true)) {
                match('!');
            }
        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;
    }


    private static final long[] mk_tokenSet_0() {
        long[] data = new long[1025];
        data[0]=8070596088689590272L;
        data[1]=1152921504606846976L;
        return data;
    }
    public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
    private static final long[] mk_tokenSet_1() {
        long[] data = new long[1025];
        data[0]=4294981120L;
        return data;
    }
    public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
    private static final long[] mk_tokenSet_2() {
        long[] data = new long[2048];
        data[0]=-1025L;
        for (int i = 1; i<=1022; i++) { data[i]=-1L; }
        data[1023]=9223372036854775807L;
        return data;
    }
    public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
    private static final long[] mk_tokenSet_3() {
        long[] data = new long[2048];
        data[0]=-4398046512129L;
        for (int i = 1; i<=1022; i++) { data[i]=-1L; }
        data[1023]=9223372036854775807L;
        return data;
    }
    public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
    private static final long[] mk_tokenSet_4() {
        long[] data = new long[2048];
        data[0]=-17179869185L;
        data[1]=-268435457L;
        for (int i = 2; i<=1022; i++) { data[i]=-1L; }
        data[1023]=9223372036854775807L;
        return data;
    }
    public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4());
    private static final long[] mk_tokenSet_5() {
        long[] data = new long[1025];
        data[0]=288063250384289792L;
        return data;
    }
    public static final BitSet _tokenSet_5 = new BitSet(mk_tokenSet_5());
    private static final long[] mk_tokenSet_6() {
        long[] data = new long[1025];
        data[1]=576460745995190270L;
        return data;
    }
    public static final BitSet _tokenSet_6 = new BitSet(mk_tokenSet_6());
    private static final long[] mk_tokenSet_7() {
        long[] data = new long[1025];
        data[0]=288054454291267584L;
        data[1]=576460745995190270L;
        return data;
    }
    public static final BitSet _tokenSet_7 = new BitSet(mk_tokenSet_7());

    }
