Exemplo n.º 1
0
        public Lexer(System.IO.TextReader reader)
        {
            _allowComments = true;
            _allowSingleQuotedStrings = true;

            _inputBuffer = 0;
            _stringBuffer = new System.Text.StringBuilder(128);
            _state = 1;
            EndOfInput = false;
            _reader = reader;

            _fsmContext = new FsmContext {L = this};
        }
            private static bool State4(FsmContext ctx)
            {
                ctx.L.GetChar();

                if (ctx.L.input_char == ' ' ||
                    ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r')
                {
                    ctx.Return    = true;
                    ctx.NextState = 1;
                    return(true);
                }

                switch (ctx.L.input_char)
                {
                case ',':
                case ']':
                case '}':
                    ctx.L.UngetChar();
                    ctx.Return    = true;
                    ctx.NextState = 1;
                    return(true);

                case '.':
                    ctx.L.string_buffer.Append((char)ctx.L.input_char);
                    ctx.NextState = 5;
                    return(true);

                case 'e':
                case 'E':
                    ctx.L.string_buffer.Append((char)ctx.L.input_char);
                    ctx.NextState = 7;
                    return(true);

                default:
                    return(false);
                }
            }
Exemplo n.º 3
0
    // Token: 0x0601578B RID: 87947 RVA: 0x00572970 File Offset: 0x00570B70
    private static bool State22(FsmContext ctx)
    {
        int num  = 0;
        int num2 = 4096;

        ctx.L.unichar = 0;
        while (ctx.L.GetChar())
        {
            if ((ctx.L.input_char < 48 || ctx.L.input_char > 57) && (ctx.L.input_char < 65 || ctx.L.input_char > 70) && (ctx.L.input_char < 97 || ctx.L.input_char > 102))
            {
                return(false);
            }
            ctx.L.unichar += Lexer.HexValue(ctx.L.input_char) * num2;
            num++;
            num2 /= 16;
            if (num == 4)
            {
                ctx.L.string_buffer.Append(Convert.ToChar(ctx.L.unichar));
                ctx.NextState = ctx.StateStack;
                return(true);
            }
        }
        return(true);
    }
Exemplo n.º 4
0
        private static bool State21 (FsmContext ctx)
        {
            ctx.L.GetChar ();

            switch (ctx.L.input_char) {
            case 'u':
                ctx.NextState = 22;
                return true;

            case '"':
            case '\'':
            case '/':
            case '\\':
            case 'b':
            case 'f':
            case 'n':
            case 'r':
            case 't':
                ctx.L.string_buffer.Append (
                    ProcessEscChar (ctx.L.input_char));
                ctx.NextState = ctx.StateStack;
                return true;

            default:
                return false;
            }
        }
Exemplo n.º 5
0
        private static bool State17 (FsmContext ctx)
        {
            ctx.L.GetChar ();

            switch (ctx.L.input_char) {
            case 'l':
                ctx.NextState = 18;
                return true;

            default:
                return false;
            }
        }
Exemplo n.º 6
0
        private static bool State8 (FsmContext ctx)
        {
            while (ctx.L.GetChar ()) {
                if (ctx.L.input_char >= '0' && ctx.L.input_char<= '9') {
                    ctx.L.string_buffer.Append ((char) ctx.L.input_char);
                    continue;
                }

                if (ctx.L.input_char == ' ' ||
                    ctx.L.input_char >= '\t' && ctx.L.input_char<= '\r') {
                    ctx.Return = true;
                    ctx.NextState = 1;
                    return true;
                }

                switch (ctx.L.input_char) {
                case ',':
                case ']':
                case '}':
                    ctx.L.UngetChar ();
                    ctx.Return = true;
                    ctx.NextState = 1;
                    return true;

                default:
                    return false;
                }
            }

            return true;
        }
Exemplo n.º 7
0
        private static bool State28 (FsmContext ctx)
        {
            while (ctx.L.GetChar ()) {
                if (ctx.L.input_char == '*')
                    continue;

                if (ctx.L.input_char == '/') {
                    ctx.NextState = 1;
                    return true;
                }

                ctx.NextState = 27;
                return true;
            }

            return true;
        }
Exemplo n.º 8
0
        public Lexer (TextReader reader)
        {
            allow_comments = true;
            allow_single_quoted_strings = true;

            input_buffer = 0;
            string_buffer = new StringBuilder (128);
            state = 1;
            end_of_input = false;
            this.reader = reader;

            fsm_context = new FsmContext ();
            fsm_context.L = this;
        }
Exemplo n.º 9
0
        private static bool State24 (FsmContext ctx)
        {
            ctx.L.GetChar ();

            switch (ctx.L.input_char) {
            case '\'':
                ctx.L.input_char = '"';
                ctx.Return = true;
                ctx.NextState = 1;
                return true;

            default:
                return false;
            }
        }
Exemplo n.º 10
0
    // Token: 0x06015776 RID: 87926 RVA: 0x00571D00 File Offset: 0x0056FF00
    private static bool State1(FsmContext ctx)
    {
        while (ctx.L.GetChar())
        {
            if (ctx.L.input_char != 32 && (ctx.L.input_char < 9 || ctx.L.input_char > 13))
            {
                if (ctx.L.input_char >= 49 && ctx.L.input_char <= 57)
                {
                    ctx.L.string_buffer.Append((char)ctx.L.input_char);
                    ctx.NextState = 3;
                    return(true);
                }
                int num = ctx.L.input_char;
                switch (num)
                {
                case 44:
                    break;

                case 45:
                    ctx.L.string_buffer.Append((char)ctx.L.input_char);
                    ctx.NextState = 2;
                    return(true);

                default:
                    switch (num)
                    {
                    case 91:
                    case 93:
                        break;

                    default:
                        switch (num)
                        {
                        case 123:
                        case 125:
                            break;

                        default:
                            if (num == 34)
                            {
                                ctx.NextState = 19;
                                ctx.Return    = true;
                                return(true);
                            }
                            if (num != 39)
                            {
                                if (num != 58)
                                {
                                    if (num == 102)
                                    {
                                        ctx.NextState = 12;
                                        return(true);
                                    }
                                    if (num == 110)
                                    {
                                        ctx.NextState = 16;
                                        return(true);
                                    }
                                    if (num != 116)
                                    {
                                        return(false);
                                    }
                                    ctx.NextState = 9;
                                    return(true);
                                }
                            }
                            else
                            {
                                if (!ctx.L.allow_single_quoted_strings)
                                {
                                    return(false);
                                }
                                ctx.L.input_char = 34;
                                ctx.NextState    = 23;
                                ctx.Return       = true;
                                return(true);
                            }
                            break;
                        }
                        break;
                    }
                    break;

                case 47:
                    if (!ctx.L.allow_comments)
                    {
                        return(false);
                    }
                    ctx.NextState = 25;
                    return(true);

                case 48:
                    ctx.L.string_buffer.Append((char)ctx.L.input_char);
                    ctx.NextState = 4;
                    return(true);
                }
                ctx.NextState = 1;
                ctx.Return    = true;
                return(true);
            }
        }
        return(true);
    }
Exemplo n.º 11
0
        private static bool State26(FsmContext ctx)
        {
            while (ctx.L.GetChar())
            {
                if (ctx.L._inputChar == '\n')
                {
                    ctx.NextState = 1;
                    return true;
                }
            }

            return true;
        }
Exemplo n.º 12
0
        private static bool State19(FsmContext ctx)
        {
            while (ctx.L.GetChar())
            {
                switch (ctx.L._inputChar)
                {
                    case '"':
                        ctx.L.UngetChar();
                        ctx.Return = true;
                        ctx.NextState = 20;
                        return true;

                    case '\\':
                        ctx.StateStack = 19;
                        ctx.NextState = 21;
                        return true;

                    default:
                        ctx.L._stringBuffer.Append((char) ctx.L._inputChar);
                        continue;
                }
            }

            return true;
        }
Exemplo n.º 13
0
        private static bool State18(FsmContext ctx)
        {
            ctx.L.GetChar();

            switch (ctx.L._inputChar)
            {
                case 'l':
                    ctx.Return = true;
                    ctx.NextState = 1;
                    return true;

                default:
                    return false;
            }
        }
Exemplo n.º 14
0
        private static bool State22 (FsmContext ctx)
        {
            int counter = 0;
            int mult    = 4096;

            ctx.L.unichar = 0;

            while (ctx.L.GetChar ()) {

                if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9' ||
                    ctx.L.input_char >= 'A' && ctx.L.input_char <= 'F' ||
                    ctx.L.input_char >= 'a' && ctx.L.input_char <= 'f') {

                    ctx.L.unichar += HexValue (ctx.L.input_char) * mult;

                    counter++;
                    mult /= 16;

                    if (counter == 4) {
                        ctx.L.string_buffer.Append (
                            Convert.ToChar (ctx.L.unichar));
                        ctx.NextState = ctx.StateStack;
                        return true;
                    }

                    continue;
                }

                return false;
            }

            return true;
        }
Exemplo n.º 15
0
        private static bool State1 (FsmContext ctx)
        {
            while (ctx.L.GetChar ()) {
                if (ctx.L.input_char == ' ' ||
                    ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r')
                    continue;

                if (ctx.L.input_char >= '1' && ctx.L.input_char <= '9') {
                    ctx.L.string_buffer.Append ((char) ctx.L.input_char);
                    ctx.NextState = 3;
                    return true;
                }

                switch (ctx.L.input_char) {
                case '"':
                    ctx.NextState = 19;
                    ctx.Return = true;
                    return true;

                case ',':
                case ':':
                case '[':
                case ']':
                case '{':
                case '}':
                    ctx.NextState = 1;
                    ctx.Return = true;
                    return true;

                case '-':
                    ctx.L.string_buffer.Append ((char) ctx.L.input_char);
                    ctx.NextState = 2;
                    return true;

                case '0':
                    ctx.L.string_buffer.Append ((char) ctx.L.input_char);
                    ctx.NextState = 4;
                    return true;

                case 'f':
                    ctx.NextState = 12;
                    return true;

                case 'n':
                    ctx.NextState = 16;
                    return true;

                case 't':
                    ctx.NextState = 9;
                    return true;

                case '\'':
                    if (! ctx.L.allow_single_quoted_strings)
                        return false;

                    ctx.L.input_char = '"';
                    ctx.NextState = 23;
                    ctx.Return = true;
                    return true;

                case '/':
                    if (! ctx.L.allow_comments)
                        return false;

                    ctx.NextState = 25;
                    return true;

                default:
                    return false;
                }
            }

            return true;
        }
Exemplo n.º 16
0
        private static bool State23 (FsmContext ctx)
        {
            while (ctx.L.GetChar ()) {
                switch (ctx.L.input_char) {
                case '\'':
                    ctx.L.UngetChar ();
                    ctx.Return = true;
                    ctx.NextState = 24;
                    return true;

                case '\\':
                    ctx.StateStack = 23;
                    ctx.NextState = 21;
                    return true;

                default:
                    ctx.L.string_buffer.Append ((char) ctx.L.input_char);
                    continue;
                }
            }

            return true;
        }
Exemplo n.º 17
0
        private static bool State4 (FsmContext ctx)
        {
            ctx.L.GetChar ();

            if (ctx.L.input_char == ' ' ||
                ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') {
                ctx.Return = true;
                ctx.NextState = 1;
                return true;
            }

            switch (ctx.L.input_char) {
            case ',':
            case ']':
            case '}':
                ctx.L.UngetChar ();
                ctx.Return = true;
                ctx.NextState = 1;
                return true;

            case '.':
                ctx.L.string_buffer.Append ((char) ctx.L.input_char);
                ctx.NextState = 5;
                return true;

            case 'e':
            case 'E':
                ctx.L.string_buffer.Append ((char) ctx.L.input_char);
                ctx.NextState = 7;
                return true;

            default:
                return false;
            }
        }
Exemplo n.º 18
0
        private static bool State25 (FsmContext ctx)
        {
            ctx.L.GetChar ();

            switch (ctx.L.input_char) {
            case '*':
                ctx.NextState = 27;
                return true;

            case '/':
                ctx.NextState = 26;
                return true;

            default:
                return false;
            }
        }
Exemplo n.º 19
0
        private static bool State5 (FsmContext ctx)
        {
            ctx.L.GetChar ();

            if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') {
                ctx.L.string_buffer.Append ((char) ctx.L.input_char);
                ctx.NextState = 6;
                return true;
            }

            return false;
        }
Exemplo n.º 20
0
        private static bool State27 (FsmContext ctx)
        {
            while (ctx.L.GetChar ()) {
                if (ctx.L.input_char == '*') {
                    ctx.NextState = 28;
                    return true;
                }
            }

            return true;
        }
Exemplo n.º 21
0
        private static bool State7 (FsmContext ctx)
        {
            ctx.L.GetChar ();

            if (ctx.L.input_char >= '0' && ctx.L.input_char<= '9') {
                ctx.L.string_buffer.Append ((char) ctx.L.input_char);
                ctx.NextState = 8;
                return true;
            }

            switch (ctx.L.input_char) {
            case '+':
            case '-':
                ctx.L.string_buffer.Append ((char) ctx.L.input_char);
                ctx.NextState = 8;
                return true;

            default:
                return false;
            }
        }
Exemplo n.º 22
0
            private static bool State1(FsmContext ctx)
            {
                while (ctx.L.GetChar())
                {
                    if (ctx.L.input_char == ' ' ||
                        ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r')
                    {
                        continue;
                    }

                    if (ctx.L.input_char >= '1' && ctx.L.input_char <= '9')
                    {
                        ctx.L.string_buffer.Append((char)ctx.L.input_char);
                        ctx.NextState = 3;
                        return(true);
                    }

                    switch (ctx.L.input_char)
                    {
                    case '"':
                        ctx.NextState = 19;
                        ctx.Return    = true;
                        return(true);

                    case ',':
                    case ':':
                    case '[':
                    case ']':
                    case '{':
                    case '}':
                        ctx.NextState = 1;
                        ctx.Return    = true;
                        return(true);

                    case '-':
                        ctx.L.string_buffer.Append((char)ctx.L.input_char);
                        ctx.NextState = 2;
                        return(true);

                    case '0':
                        ctx.L.string_buffer.Append((char)ctx.L.input_char);
                        ctx.NextState = 4;
                        return(true);

                    case 'f':
                        ctx.NextState = 12;
                        return(true);

                    case 'n':
                        ctx.NextState = 16;
                        return(true);

                    case 't':
                        ctx.NextState = 9;
                        return(true);

                    case '\'':
                        if (!ctx.L.allow_single_quoted_strings)
                        {
                            return(false);
                        }

                        ctx.L.input_char = '"';
                        ctx.NextState    = 23;
                        ctx.Return       = true;
                        return(true);

                    case '/':
                        if (!ctx.L.allow_comments)
                        {
                            return(false);
                        }

                        ctx.NextState = 25;
                        return(true);

                    default:
                        return(false);
                    }
                }

                return(true);
            }
Exemplo n.º 23
0
        private static bool State2(FsmContext ctx)
        {
            ctx.L.GetChar();

            if (ctx.L._inputChar >= '1' && ctx.L._inputChar <= '9')
            {
                ctx.L._stringBuffer.Append((char) ctx.L._inputChar);
                ctx.NextState = 3;
                return true;
            }

            switch (ctx.L._inputChar)
            {
                case '0':
                    ctx.L._stringBuffer.Append((char) ctx.L._inputChar);
                    ctx.NextState = 4;
                    return true;

                default:
                    return false;
            }
        }