CSLE.CLS_Expression_Compiler.Compiler_Expression_Block C# (CSharp) Méthode

Compiler_Expression_Block() public méthode

public Compiler_Expression_Block ( IList tlist, ICLS_Environment content, int pos, int posend, ICLS_Expression &value ) : bool
tlist IList
content ICLS_Environment
pos int
posend int
value ICLS_Expression
Résultat bool
        public bool Compiler_Expression_Block(IList<Token> tlist, ICLS_Environment content, int pos, int posend, out ICLS_Expression value)
        {
            int begin = pos;
            value = null;
            List<ICLS_Expression> values = new List<ICLS_Expression>();
            int end = 0;
            do
            {
                if (tlist[begin].type == TokenType.COMMENT)
                {
                    begin++;
                    continue;
                }
                if (tlist[begin].type == TokenType.PUNCTUATION && tlist[begin].text == ";")
                {
                    begin++;
                    continue;
                }
                int bdep;
                //脱一次壳
                end = FindCodeInBlock(tlist, ref begin, out bdep);

                if (end > posend)
                {
                    end = posend;
                }
                int expend = end;
                int expbegin = begin;
                if (expbegin > expend)
                {
                    //LogError(tlist, "括号块识别失败", expbegin, expend);
                    return true;
                }
                if (bdep == 2) //编译块表达式
                {
                    expbegin++;
                    expend--;
                    ICLS_Expression subvalue;
                    bool bsucc = Compiler_Expression_Block(tlist,content, expbegin, expend, out subvalue);
                    if (bsucc)
                    {
                        if (subvalue != null)
                            values.Add(subvalue);
                    }
                    else
                    {
                        LogError(tlist, "表达式编译失败", expbegin, expend);
                        return false;
                    }
                }
                else
                {
                    ICLS_Expression subvalue;
                    bool bsucc = Compiler_Expression(tlist, content,expbegin, expend, out subvalue);
                    if (bsucc)
                    {
                        if (subvalue != null)
                            values.Add(subvalue);
                    }
                    else
                    {
                        LogError(tlist, "表达式编译失败", expbegin, expend);
                        return false;
                    }
                }




                begin = end + 1;
            }
            while (begin <= posend);
            if (values.Count == 1)
            {
                value = values[0];
            }
            else if (values.Count > 1)
            {
                CLS_Expression_Block block = new CLS_Expression_Block(pos, end, tlist[pos].line, tlist[end].line);
                foreach (var v in values)
                    block.listParam.Add(v);
                value = block;
            }
            return true;
        }