コード例 #1
0
ファイル: JsonParser.cs プロジェクト: Hengle/swc-decompiled
        private JsonTokens NextTokenCore()
        {
            char c;

            for (c = this.json.get_Chars(this.index); c <= ' '; c = this.json.get_Chars(this.index))
            {
                int num = this.index + 1;
                this.index = num;
                if (num == this.jsonLength)
                {
                    return(JsonTokens.None);
                }
            }
            this.index++;
            if (c >= 'Ā')
            {
                return(JsonTokens.None);
            }
            JsonTokens jsonTokens = JsonParser.jsonTokenMap[(int)c];

            if (jsonTokens >= JsonTokens.WordFirst)
            {
                int num;
                do
                {
                    c = this.json.get_Chars(this.index);
                    if (c < 'a' || c > 'z')
                    {
                        break;
                    }
                    num        = this.index + 1;
                    this.index = num;
                }while (num < this.jsonLength);
            }
            return(jsonTokens);
        }
コード例 #2
0
        private string ParseString()
        {
            this.lookAheadToken = JsonTokens.None;
            int num = this.json.IndexOf('"', this.index);

            if (num < 0)
            {
                return(null);
            }
            if (this.nextBackslash < 0 || this.nextBackslash > num)
            {
                string s = this.json.Substring(this.index, num - this.index);
                this.index = num + 1;
                return(this.NewString(s));
            }
            this.sb.Length = 0;
            int num2 = -1;

            while (this.index < this.jsonLength)
            {
                char c = this.json[this.index++];
                if (c == '"')
                {
                    if (num2 != -1)
                    {
                        if (this.sb.Length == 0)
                        {
                            this.FindNextBackslash();
                            return(this.NewString(this.json.Substring(num2, this.index - num2 - 1)));
                        }
                        this.sb.Append(this.json.Substring(num2, this.index - num2 - 1));
                    }
                    this.FindNextBackslash();
                    return(this.NewString(this.sb.ToString()));
                }
                if (c != '\\')
                {
                    if (num2 == -1)
                    {
                        num2 = this.index - 1;
                    }
                }
                else
                {
                    if (this.index == this.jsonLength)
                    {
                        break;
                    }
                    if (num2 != -1)
                    {
                        this.sb.Append(this.json.Substring(num2, this.index - num2 - 1));
                        num2 = -1;
                    }
                    char c2 = this.json[this.index++];
                    switch (c2)
                    {
                    case 'r':
                        this.sb.Append('\r');
                        continue;

                    case 's':
IL_1AD:
                        if (c2 == '"')
                        {
                            this.sb.Append('"');
                            continue;
                        }
                        if (c2 == '/')
                        {
                            this.sb.Append('/');
                            continue;
                        }
                        if (c2 == '\\')
                        {
                            this.sb.Append('\\');
                            continue;
                        }
                        if (c2 == 'b')
                        {
                            this.sb.Append('\b');
                            continue;
                        }
                        if (c2 == 'f')
                        {
                            this.sb.Append('\f');
                            continue;
                        }
                        if (c2 != 'n')
                        {
                            continue;
                        }
                        this.sb.Append('\n');
                        continue;

                    case 't':
                        this.sb.Append('\t');
                        continue;

                    case 'u':
                    {
                        if (this.jsonLength - this.index < 4)
                        {
                            continue;
                        }
                        uint num3 = this.ParseUnicode(this.json[this.index], this.json[this.index + 1], this.json[this.index + 2], this.json[this.index + 3]);
                        this.sb.Append((char)num3);
                        this.index += 4;
                        continue;
                    }
                    }
                    goto IL_1AD;
                }
            }
            this.FindNextBackslash();
            return(null);
        }
コード例 #3
0
ファイル: JsonParser.cs プロジェクト: Hengle/swc-decompiled
        private string ParseString()
        {
            this.lookAheadToken = JsonTokens.None;
            int num = this.json.IndexOf('"', this.index);

            if (num < 0)
            {
                return(null);
            }
            if (this.nextBackslash < 0 || this.nextBackslash > num)
            {
                string s = this.json.Substring(this.index, num - this.index);
                this.index = num + 1;
                return(this.NewString(s));
            }
            this.sb.set_Length(0);
            int num2 = -1;

            while (this.index < this.jsonLength)
            {
                string arg_8B_0 = this.json;
                int    num3     = this.index;
                this.index = num3 + 1;
                char c = arg_8B_0.get_Chars(num3);
                if (c == '"')
                {
                    if (num2 != -1)
                    {
                        if (this.sb.get_Length() == 0)
                        {
                            this.FindNextBackslash();
                            return(this.NewString(this.json.Substring(num2, this.index - num2 - 1)));
                        }
                        this.sb.Append(this.json.Substring(num2, this.index - num2 - 1));
                    }
                    this.FindNextBackslash();
                    return(this.NewString(this.sb.ToString()));
                }
                if (c != '\\')
                {
                    if (num2 == -1)
                    {
                        num2 = this.index - 1;
                    }
                }
                else
                {
                    if (this.index == this.jsonLength)
                    {
                        break;
                    }
                    if (num2 != -1)
                    {
                        this.sb.Append(this.json.Substring(num2, this.index - num2 - 1));
                        num2 = -1;
                    }
                    string arg_171_0 = this.json;
                    num3       = this.index;
                    this.index = num3 + 1;
                    char c2 = arg_171_0.get_Chars(num3);
                    if (c2 <= '\\')
                    {
                        if (c2 != '"')
                        {
                            if (c2 != '/')
                            {
                                if (c2 == '\\')
                                {
                                    this.sb.Append('\\');
                                }
                            }
                            else
                            {
                                this.sb.Append('/');
                            }
                        }
                        else
                        {
                            this.sb.Append('"');
                        }
                    }
                    else if (c2 <= 'f')
                    {
                        if (c2 != 'b')
                        {
                            if (c2 == 'f')
                            {
                                this.sb.Append('\f');
                            }
                        }
                        else
                        {
                            this.sb.Append('\b');
                        }
                    }
                    else if (c2 != 'n')
                    {
                        switch (c2)
                        {
                        case 'r':
                            this.sb.Append('\r');
                            break;

                        case 't':
                            this.sb.Append('\t');
                            break;

                        case 'u':
                            if (this.jsonLength - this.index >= 4)
                            {
                                uint num4 = this.ParseUnicode(this.json.get_Chars(this.index), this.json.get_Chars(this.index + 1), this.json.get_Chars(this.index + 2), this.json.get_Chars(this.index + 3));
                                this.sb.Append((char)num4);
                                this.index += 4;
                            }
                            break;
                        }
                    }
                    else
                    {
                        this.sb.Append('\n');
                    }
                }
            }
            this.FindNextBackslash();
            return(null);
        }