示例#1
0
        private PathFilter ParseQuotedField(char indexerCloseChar, bool scan)
        {
            List <string> strs = null;

            while (this._currentIndex < this._expression.Length)
            {
                string str = this.ReadQuotedString();
                this.EatWhitespace();
                this.EnsureLength("Path ended with open indexer.");
                if (this._expression[this._currentIndex] == indexerCloseChar)
                {
                    if (strs == null)
                    {
                        return(JPath.CreatePathFilter(str, scan));
                    }
                    strs.Add(str);
                    if (!scan)
                    {
                        return(new FieldMultipleFilter()
                        {
                            Names = strs
                        });
                    }
                    return(new ScanMultipleFilter()
                    {
                        Names = strs
                    });
                }
                if (this._expression[this._currentIndex] != ',')
                {
                    char chr = this._expression[this._currentIndex];
                    throw new JsonException(string.Concat("Unexpected character while parsing path indexer: ", chr.ToString()));
                }
                this._currentIndex++;
                this.EatWhitespace();
                if (strs == null)
                {
                    strs = new List <string>();
                }
                strs.Add(str);
            }
            throw new JsonException("Path ended with open indexer.");
        }
示例#2
0
文件: JPath.cs 项目: zha0/Cerberus
        // Token: 0x06001460 RID: 5216 RVA: 0x0006C184 File Offset: 0x0006A384
        private PathFilter ParseQuotedField(char indexerCloseChar, bool scan)
        {
            List <string> list = null;

            while (this._currentIndex < this._expression.Length)
            {
                string text = this.ReadQuotedString();
                this.EatWhitespace();
                this.EnsureLength("Path ended with open indexer.");
                if (this._expression[this._currentIndex] == indexerCloseChar)
                {
                    if (list == null)
                    {
                        return(JPath.CreatePathFilter(text, scan));
                    }
                    list.Add(text);
                    if (!scan)
                    {
                        return(new FieldMultipleFilter(list));
                    }
                    return(new ScanMultipleFilter(list));
                }
                else
                {
                    if (this._expression[this._currentIndex] != ',')
                    {
                        throw new JsonException("Unexpected character while parsing path indexer: " + this._expression[this._currentIndex].ToString());
                    }
                    this._currentIndex++;
                    this.EatWhitespace();
                    if (list == null)
                    {
                        list = new List <string>();
                    }
                    list.Add(text);
                }
            }
            throw new JsonException("Path ended with open indexer.");
        }
示例#3
0
        private bool ParsePath(List <PathFilter> filters, int currentPartStartIndex, bool query)
        {
            char chr;
            bool flag  = false;
            bool flag1 = false;
            bool flag2 = false;
            bool flag3 = false;

Label3:
            while (this._currentIndex < this._expression.Length)
            {
                if (flag3)
                {
                    break;
                }
                chr = this._expression[this._currentIndex];
                if (chr <= ')')
                {
                    if (chr == ' ')
                    {
                        if (this._currentIndex >= this._expression.Length)
                        {
                            continue;
                        }
                        flag3 = true;
                        continue;
                    }
                    else
                    {
                        if (chr == '(')
                        {
                            goto Label2;
                        }
                        if (chr == ')')
                        {
                            goto Label0;
                        }
                        goto Label1;
                    }
                }
                else if (chr == '.')
                {
                    if (this._currentIndex > currentPartStartIndex)
                    {
                        string str = this._expression.Substring(currentPartStartIndex, this._currentIndex - currentPartStartIndex);
                        if (str == "*")
                        {
                            str = null;
                        }
                        filters.Add(JPath.CreatePathFilter(str, flag));
                        flag = false;
                    }
                    if (this._currentIndex + 1 < this._expression.Length && this._expression[this._currentIndex + 1] == '.')
                    {
                        flag = true;
                        this._currentIndex++;
                    }
                    this._currentIndex++;
                    currentPartStartIndex = this._currentIndex;
                    flag1 = false;
                    flag2 = true;
                    continue;
                }
                else
                {
                    if (chr == '[')
                    {
                        goto Label2;
                    }
                    if (chr == ']')
                    {
                        goto Label0;
                    }
                    else
                    {
                        goto Label1;
                    }
                }
Label2:
                if (this._currentIndex > currentPartStartIndex)
                {
                    string str1 = this._expression.Substring(currentPartStartIndex, this._currentIndex - currentPartStartIndex);
                    if (str1 == "*")
                    {
                        str1 = null;
                    }
                    filters.Add(JPath.CreatePathFilter(str1, flag));
                    flag = false;
                }
                filters.Add(this.ParseIndexer(chr, flag));
                this._currentIndex++;
                currentPartStartIndex = this._currentIndex;
                flag1 = true;
                flag2 = false;
            }
            bool length = this._currentIndex == this._expression.Length;

            if (this._currentIndex > currentPartStartIndex)
            {
                string str2 = this._expression.Substring(currentPartStartIndex, this._currentIndex - currentPartStartIndex).TrimEnd(new char[0]);
                if (str2 == "*")
                {
                    str2 = null;
                }
                filters.Add(JPath.CreatePathFilter(str2, flag));
            }
            else if (flag2 && length | query)
            {
                throw new JsonException("Unexpected end while parsing path.");
            }
            return(length);

Label0:
            flag3 = true;
            goto Label3;
Label1:
            if (!query || chr != '=' && chr != '<' && chr != '!' && chr != '>' && chr != '|' && chr != '&')
            {
                if (flag1)
                {
                    throw new JsonException(string.Concat("Unexpected character following indexer: ", chr.ToString()));
                }
                this._currentIndex++;
                goto Label3;
            }
            else
            {
                flag3 = true;
                goto Label3;
            }
        }
示例#4
0
文件: JPath.cs 项目: zha0/Cerberus
        // Token: 0x06001451 RID: 5201 RVA: 0x0006B0B0 File Offset: 0x000692B0
        private bool ParsePath(List <PathFilter> filters, int currentPartStartIndex, bool query)
        {
            bool scan  = false;
            bool flag  = false;
            bool flag2 = false;
            bool flag3 = false;

            while (this._currentIndex < this._expression.Length && !flag3)
            {
                char c = this._expression[this._currentIndex];
                if (c <= ')')
                {
                    if (c != ' ')
                    {
                        if (c != '(')
                        {
                            if (c != ')')
                            {
                                goto IL_1AA;
                            }
                            goto IL_DF;
                        }
                    }
                    else
                    {
                        if (this._currentIndex < this._expression.Length)
                        {
                            flag3 = true;
                            continue;
                        }
                        continue;
                    }
                }
                else
                {
                    if (c == '.')
                    {
                        if (this._currentIndex > currentPartStartIndex)
                        {
                            string text = this._expression.Substring(currentPartStartIndex, this._currentIndex - currentPartStartIndex);
                            if (text == "*")
                            {
                                text = null;
                            }
                            filters.Add(JPath.CreatePathFilter(text, scan));
                            scan = false;
                        }
                        if (this._currentIndex + 1 < this._expression.Length && this._expression[this._currentIndex + 1] == '.')
                        {
                            scan = true;
                            this._currentIndex++;
                        }
                        this._currentIndex++;
                        currentPartStartIndex = this._currentIndex;
                        flag  = false;
                        flag2 = true;
                        continue;
                    }
                    if (c != '[')
                    {
                        if (c != ']')
                        {
                            goto IL_1AA;
                        }
                        goto IL_DF;
                    }
                }
                if (this._currentIndex > currentPartStartIndex)
                {
                    string text2 = this._expression.Substring(currentPartStartIndex, this._currentIndex - currentPartStartIndex);
                    if (text2 == "*")
                    {
                        text2 = null;
                    }
                    filters.Add(JPath.CreatePathFilter(text2, scan));
                    scan = false;
                }
                filters.Add(this.ParseIndexer(c, scan));
                scan = false;
                this._currentIndex++;
                currentPartStartIndex = this._currentIndex;
                flag  = true;
                flag2 = false;
                continue;
IL_DF:
                flag3 = true;
                continue;
IL_1AA:
                if (query && (c == '=' || c == '<' || c == '!' || c == '>' || c == '|' || c == '&'))
                {
                    flag3 = true;
                }
                else
                {
                    if (flag)
                    {
                        throw new JsonException("Unexpected character following indexer: " + c.ToString());
                    }
                    this._currentIndex++;
                }
            }
            bool flag4 = this._currentIndex == this._expression.Length;

            if (this._currentIndex > currentPartStartIndex)
            {
                string text3 = this._expression.Substring(currentPartStartIndex, this._currentIndex - currentPartStartIndex).TrimEnd(new char[0]);
                if (text3 == "*")
                {
                    text3 = null;
                }
                filters.Add(JPath.CreatePathFilter(text3, scan));
            }
            else if (flag2 && (flag4 || query))
            {
                throw new JsonException("Unexpected end while parsing path.");
            }
            return(flag4);
        }