CSLE.CLS_Expression_Compiler.GetLowestMathOp C# (CSharp) Метод

GetLowestMathOp() приватный Метод

private GetLowestMathOp ( IList tokens, IList list ) : int
tokens IList
list IList
Результат int
        int GetLowestMathOp(IList<Token> tokens, IList<int> list)
        {

            int nmax = int.MaxValue;//优先级
            int npos = -1;//字符
            foreach (int i in list)
            {
                int max = 0;
                switch (tokens[i].text)
                {
                    case "?":
                        max = -1;
                        break;
                    case ":":
                        max = 0;
                        break;
                    case "<":
                        max = 5;
                        break;
                    case ">":
                        max = 5;
                        break;
                    case "<=":
                        max = 5;
                        break;
                    case ">=":
                        max = 5;
                        break;
                    case "&&":
                        max = 3;
                        break;
                    case "||":
                        max = 3;
                        break;
                    case "==":
                        max = 4;
                        break;
                    case "!=":
                        max = 4;
                        break;
                    case "*":
                        max = 7;
                        break;
                    case "/":
                        max = 7;
                        break;
                    case "%":
                        max = 7;
                        break;
                    case "+":
                        max = 6;
                        break;
                    case "-":
                        max = 6;
                        break;
                    case ".":
                        max = 10;
                        break;
                    case "=>":
                        max = 8;
                        break;
                    case "[":
                        max = 10;
                        break;
                    case "(":
                        max = 9;//提高括弧的处理顺序到11,已回滚此修改
                        //表达式识别存在缺陷,并非单纯的改动可以解决,可能造成其他的不明显bug
                        break;
                    case "as":
                        max = 9;
                        break;
                    case "is":
                        max = 9;
                        break;
                }
                if (tokens[i].text == "(")//(int)(xxx) //这种表达式要优先处理前一个
                {
                    if (max < nmax)
                    {
                        nmax = max;
                        npos = i;
                    }
                }
                else
                {
                    if (max <= nmax)
                    {
                        nmax = max;
                        npos = i;
                    }
                }
            }

            return npos;
        }
    }