// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) space 
// Source File Name:   ParserTokenManager.java

package lt.monarch.function.parser;

import java.io.IOException;

// Referenced classes of package lt.monarch.function.parser:
//            ParserConstants, ASCII_UCodeESC_CharStream, TokenMgrError, Token

public class ParserTokenManager
    implements ParserConstants
{

    private final int jjStopStringLiteralDfa_0(int i, long l)
    {
        switch (i)
        {
        default:
            return -1;
        }
    }

    private final int jjStartNfa_0(int i, long l)
    {
        return jjMoveNfa_0(jjStopStringLiteralDfa_0(i, l), i + 1);
    }

    private final int jjStopAtPos(int i, int j)
    {
        jjmatchedKind = j;
        jjmatchedPos = i;
        return i + 1;
    }

    private final int jjStartNfaWithStates_0(int i, int j, int k)
    {
        jjmatchedKind = j;
        jjmatchedPos = i;
        try
        {
            curChar = input_stream.readChar();
        }
        catch (IOException ioexception)
        {
            return i + 1;
        }
        return jjMoveNfa_0(k, i + 1);
    }

    private final int jjMoveStringLiteralDfa0_0()
    {
        switch (curChar)
        {
        case 40: // '('
            return jjStopAtPos(0, 16);

        case 41: // ')'
            return jjStopAtPos(0, 18);

        case 42: // '*'
            return jjStopAtPos(0, 6);

        case 43: // '+'
            return jjStopAtPos(0, 4);

        case 44: // ','
            return jjStopAtPos(0, 17);

        case 45: // '-'
            return jjStopAtPos(0, 5);

        case 47: // '/'
            return jjStopAtPos(0, 7);

        case 61: // '='
            return jjStopAtPos(0, 19);

        case 94: // '^'
            return jjStopAtPos(0, 8);
        }
        return jjMoveNfa_0(0, 0);
    }

    private final void jjCheckNAdd(int i)
    {
        if (jjrounds[i] != jjround)
        {
            jjstateSet[jjnewStateCnt++] = i;
            jjrounds[i] = jjround;
        }
    }

    private final void jjAddStates(int i, int j)
    {
        do
            jjstateSet[jjnewStateCnt++] = jjnextStates[i];
        while (i++ != j);
    }

    private final void jjCheckNAddTwoStates(int i, int j)
    {
        jjCheckNAdd(i);
        jjCheckNAdd(j);
    }

    private final void jjCheckNAddStates(int i, int j)
    {
        do
            jjCheckNAdd(jjnextStates[i]);
        while (i++ != j);
    }

    private final void jjCheckNAddStates(int i)
    {
        jjCheckNAdd(jjnextStates[i]);
        jjCheckNAdd(jjnextStates[i + 1]);
    }

    private final int jjMoveNfa_0(int i, int j)
    {
        int k = 0;
        jjnewStateCnt = 12;
        int l = 1;
        jjstateSet[0] = i;
        int i1 = 0x7fffffff;
        do
        {
            if (++jjround == 0x7fffffff)
                ReInitRounds();
            if (curChar < '@')
            {
                long l1 = 1L << curChar;
                do
                    switch (jjstateSet[--l])
                    {
                    case 0: // '\0'
                        if ((0x3ff000000000000L & l1) != 0L)
                        {
                            if (i1 > 10)
                                i1 = 10;
                            jjCheckNAddStates(0, 4);
                        }
                        break;

                    case 1: // '\001'
                        if ((0x3ff000000000000L & l1) != 0L)
                        {
                            if (i1 > 9)
                                i1 = 9;
                            jjstateSet[jjnewStateCnt++] = 1;
                        }
                        break;

                    case 3: // '\003'
                        if ((0x3ff000000000000L & l1) != 0L)
                        {
                            if (i1 > 10)
                                i1 = 10;
                            jjCheckNAddTwoStates(3, 4);
                        }
                        break;

                    case 4: // '\004'
                        if (curChar == '.')
                            jjCheckNAdd(5);
                        break;

                    case 5: // '\005'
                        if ((0x3ff000000000000L & l1) != 0L)
                        {
                            if (i1 > 10)
                                i1 = 10;
                            jjCheckNAdd(5);
                        }
                        break;

                    case 6: // '\006'
                        if ((0x3ff000000000000L & l1) != 0L)
                        {
                            if (i1 > 10)
                                i1 = 10;
                            jjCheckNAddStates(5, 7);
                        }
                        break;

                    case 7: // '\007'
                        if (curChar == '.')
                            jjCheckNAdd(8);
                        break;

                    case 8: // '\b'
                        if ((0x3ff000000000000L & l1) != 0L)
                        {
                            if (i1 > 10)
                                i1 = 10;
                            jjCheckNAddTwoStates(8, 9);
                        }
                        break;

                    case 10: // '\n'
                        if ((0x280000000000L & l1) != 0L)
                            jjCheckNAdd(11);
                        break;

                    case 11: // '\013'
                        if ((0x3ff000000000000L & l1) != 0L)
                        {
                            if (i1 > 10)
                                i1 = 10;
                            jjCheckNAdd(11);
                        }
                        break;
                    }
                while (l != k);
            } else
            if (curChar < '\200')
            {
                long l2 = 1L << (curChar & 0x3f);
                do
                    switch (jjstateSet[--l])
                    {
                    case 0: // '\0'
                        if ((0x7fffffe07fffffeL & l2) != 0L)
                        {
                            if (i1 > 9)
                                i1 = 9;
                            jjCheckNAdd(1);
                        }
                        break;

                    case 1: // '\001'
                        if ((0x7fffffe87fffffeL & l2) != 0L)
                        {
                            if (i1 > 9)
                                i1 = 9;
                            jjCheckNAdd(1);
                        }
                        break;

                    case 9: // '\t'
                        if ((0x2000000020L & l2) != 0L)
                            jjAddStates(8, 9);
                        break;
                    }
                while (l != k);
            } else
            {
                int j1 = curChar >> 8;
                int k1 = j1 >> 6;
                long l3 = 1L << (j1 & 0x3f);
                int i2 = (curChar & 0xff) >> 6;
                long l4 = 1L << (curChar & 0x3f);
                do
                    switch (jjstateSet[--l])
                    {
                    }
                while (l != k);
            }
            if (i1 != 0x7fffffff)
            {
                jjmatchedKind = i1;
                jjmatchedPos = j;
                i1 = 0x7fffffff;
            }
            j++;
            if ((l = jjnewStateCnt) == (k = 12 - (jjnewStateCnt = k)))
                return j;
            try
            {
                curChar = input_stream.readChar();
            }
            catch (IOException ioexception)
            {
                return j;
            }
        } while (true);
    }

    public void ReInit(ASCII_UCodeESC_CharStream ascii_ucodeesc_charstream)
    {
        jjmatchedPos = jjnewStateCnt = 0;
        curLexState = defaultLexState;
        input_stream = ascii_ucodeesc_charstream;
        ReInitRounds();
    }

    private final void ReInitRounds()
    {
        jjround = 0x80000001;
        for (int i = 12; i-- > 0;)
            jjrounds[i] = 0x80000000;

    }

    public void ReInit(ASCII_UCodeESC_CharStream ascii_ucodeesc_charstream, int i)
    {
        ReInit(ascii_ucodeesc_charstream);
        SwitchTo(i);
    }

    public void SwitchTo(int i)
    {
        if (i >= 1 || i < 0)
        {
            throw new TokenMgrError("Error: Ignoring invalid lexical state : " + i + ". State unchanged.", 2);
        } else
        {
            curLexState = i;
            return;
        }
    }

    private final Token jjFillToken()
    {
        Token token = Token.newToken(jjmatchedKind);
        token.kind = jjmatchedKind;
        String s = jjstrLiteralImages[jjmatchedKind];
        token.image = s != null ? s : input_stream.GetImage();
        token.beginLine = input_stream.getBeginLine();
        token.beginColumn = input_stream.getBeginColumn();
        token.endLine = input_stream.getEndLine();
        token.endColumn = input_stream.getEndColumn();
        return token;
    }

    public final Token getNextToken()
    {
        Object obj = null;
        boolean flag = false;
        do
        {
            do
            {
                try
                {
                    curChar = input_stream.BeginToken();
                }
                catch (IOException ioexception)
                {
                    jjmatchedKind = 0;
                    Token token = jjFillToken();
                    return token;
                }
                try
                {
                    input_stream.backup(0);
                    for (; curChar <= ' ' && (0x100002200L & 1L << curChar) != 0L; curChar = input_stream.BeginToken());
                    break;
                }
                catch (IOException ioexception1) { }
            } while (true);
            jjmatchedKind = 0x7fffffff;
            jjmatchedPos = 0;
            int i = jjMoveStringLiteralDfa0_0();
            if (jjmatchedKind != 0x7fffffff)
            {
                if (jjmatchedPos + 1 < i)
                    input_stream.backup(i - jjmatchedPos - 1);
                if ((jjtoToken[jjmatchedKind >> 6] & 1L << (jjmatchedKind & 0x3f)) != 0L)
                {
                    Token token1 = jjFillToken();
                    return token1;
                }
            } else
            {
                int j = input_stream.getEndLine();
                int k = input_stream.getEndColumn();
                String s = null;
                boolean flag1 = false;
                try
                {
                    input_stream.readChar();
                    input_stream.backup(1);
                }
                catch (IOException ioexception2)
                {
                    flag1 = true;
                    s = i > 1 ? input_stream.GetImage() : "";
                    if (curChar == '\n' || curChar == '\r')
                    {
                        j++;
                        k = 0;
                    } else
                    {
                        k++;
                    }
                }
                if (!flag1)
                {
                    input_stream.backup(1);
                    s = i > 1 ? input_stream.GetImage() : "";
                }
                throw new TokenMgrError(flag1, curLexState, j, k, s, curChar, 0);
            }
        } while (true);
    }

    public ParserTokenManager(ASCII_UCodeESC_CharStream ascii_ucodeesc_charstream)
    {
        jjrounds = new int[12];
        jjstateSet = new int[24];
        curLexState = 0;
        defaultLexState = 0;
        input_stream = ascii_ucodeesc_charstream;
    }

    public ParserTokenManager(ASCII_UCodeESC_CharStream ascii_ucodeesc_charstream, int i)
    {
        this(ascii_ucodeesc_charstream);
        SwitchTo(i);
    }

    static final int jjnextStates[] = {
        3, 4, 6, 7, 9, 6, 7, 9, 10, 11
    };
    public static final String jjstrLiteralImages[] = {
        "", null, null, null, "+", "-", "*", "/", "^", null, 
        null, null, null, null, null, null, "(", ",", ")", "="
    };
    public static final String lexStateNames[] = {
        "DEFAULT"
    };
    static final long jjtoToken[] = {
        0xf07f1L
    };
    static final long jjtoSkip[] = {
        14L
    };
    private ASCII_UCodeESC_CharStream input_stream;
    private final int jjrounds[];
    private final int jjstateSet[];
    protected char curChar;
    int curLexState;
    int defaultLexState;
    int jjnewStateCnt;
    int jjround;
    int jjmatchedPos;
    int jjmatchedKind;

}
