Example #1
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);
            }
        }
Example #2
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);
        }