Esempio n. 1
0
        static string GetVarName(string equation, int index, EquationElement root)
        {
            string varname = Term.ExtractName(equation, index).ToLower();

            if (root != null && root.VarExist(varname))
            {
                return(varname);
            }
            char ch = equation[index];

            if (ch >= 'a' && ch <= 'z')
            {
                //return new string(new char[] { ch });
                return(varname);
            }
            if (ch >= 'A' && ch <= 'Z')
            {
                // return new string(new char[] { ch });
                return(varname);
            }
            if (ch == '_')
            {
                // return new string(new char[] { ch });
                return(varname);
            }
            return(string.Empty);
        }
Esempio n. 2
0
 static bool IsPI(string equation, int index)
 {
     if (equation.Length > index + 1)
     {
         string spi = Term.ExtractName(equation, index, false).ToLower();
         if (spi == "pi")
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 3
0
        static public bool IsValidDigit(string equation, int index)
        {
            string spi = Term.ExtractName(equation, index).ToLower();

            if (spi.Length < 2)
            {
                return(false);
            }
            if (Functions.ContainsKey(spi))
            {
                return(true);
            }
            if (Functions2.ContainsKey(spi))
            {
                return(true);
            }
            if (FunctionsIF.ContainsKey(spi))
            {
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        public Function(string src, int start, EquationElement root)
        {
            m_startIndex = start;
            m_func       = Term.ExtractName(src, start).ToLower();
            start       += m_func.Length;
            // space는 무시, 다음문자는 무조건 괄호가 와야함.
            while (src[start] == ' ')
            {
                start++;
            }
            if (src[start] != '(')
            {
                throw new ParseException(src, m_startIndex, "함수는 무조건 () 로 실행해야 합니다.'");
            }
            int termstart = start;
            int end       = Term.FindMatchingEnd('(', src, termstart);

            if (end < termstart)
            {
                throw new ParseException(src, m_startIndex, "함수 매칭 실패");
            }

            m_endindex = end;
            string allterms = src.Substring(termstart + 1, end - termstart - 1);

            //string[] terms = allterms.Split(',');
            string[] terms = GetTerms(allterms);
            m_terms = new List <Term>();
            foreach (string term in terms)
            {
                Term newterm = new Term();
                newterm.Parse(term, root);
                newterm.Parent = this;
                m_terms.Add(newterm);
            }
        }