Esempio n. 1
0
        // 顶层公式使用
        public XTFormula RootParse()
        {
            HashSet <string> argNames = new HashSet <string>();
            XTFormula        formula  = new XTFormula(this.m_formula, argNames);

            return(this.Parse(argNames, formula));
        }
Esempio n. 2
0
        // 解释嵌套表达式
        private XTFormula Parse(HashSet <string> argNames, XTFormula formula)
        {
            XTFormulaToken token = null;

            while (this.CurrChar() > 0)
            {
                token = null;
                foreach (XTFormulaTokenParser parser in m_tokenParsers)
                {
                    token = parser.Parse(this, argNames);
                    if (token == null)
                    {
                        continue;
                    }
                    formula.AddToken(this, token);
                    break;
                }
                if (token == null)
                {
                    break;
                }
            }
            if (!formula.IsVaild)
            {
                this.RaiseFormulaException();
            }
            return(formula);
        }
Esempio n. 3
0
        public override XTFormulaToken Parse(XTFormulaParser parser, HashSet <string> argNames)
        {
            if (parser.CurrChar() != '(')
            {
                return(null);
            }
            parser.NextChar();
            XTFormula formula = parser.InnerParse(argNames);
            int       end     = parser.NextChar();

            if (end != ')')
            {
                parser.RaiseFormulaException();
            }
            return(new XTScopeToken(formula));
        }
Esempio n. 4
0
        private XTFormulaToken CreateToken(XTFormulaParser parser, HashSet <string> argNames, BaseFuncInfo funcInfo)
        {
            // 函数开始
            if (parser.NextRegx(funcInfo.ReStart) == null)
            {
                return(null);
            }

            // 函数参数
            XTFormula formula;

            XTFormula[] formulas = new XTFormula[funcInfo.ArgCount];
            for (int i = 0; i < funcInfo.ArgCount; ++i)
            {
                if (i > 0)
                {
                    if (parser.NextRegx(sm_reSplit) == null)
                    {
                        parser.RaiseFormulaException();
                    }
                }
                formula = parser.InnerParse(argNames);
                if (formula == null)
                {
                    parser.RaiseFormulaException();
                }
                formulas[i] = formula;
            }

            // 函数结束
            if (parser.NextRegx(sm_reEnd) == null)
            {
                parser.RaiseFormulaException();
            }
            return(funcInfo.CreateToken(formulas));
        }
Esempio n. 5
0
 public XTScopeToken(XTFormula formula)
 {
     this.m_formula = formula;
 }