public Tree(string s)
        {
            s = Regex.Replace(s, "[s][i][n]", "[", RegexOptions.IgnoreCase);
            s = Regex.Replace(s, "[c][o][s]", "]", RegexOptions.IgnoreCase);
            s = Regex.Replace(s, "[t][a][n]", "!", RegexOptions.IgnoreCase);
            s = Regex.Replace(s, "[l][n]", "?", RegexOptions.IgnoreCase);
            s = Regex.Replace(s, "[e][x][p]", "#", RegexOptions.IgnoreCase);
            s = Regex.Replace(s, "[s][q][r][t]", "%", RegexOptions.IgnoreCase);

            Head = new ElementOfTree();
            Head.S(s);
        }
 public void S(string partOfstring)
 {
     if (String.IsNullOrWhiteSpace(partOfstring))
     {
         throw new EmptyMemberException();
     }
     try
     {
         int sk = 0;
         for (int i = partOfstring.Length - 1; i >= 0; i--)
         {
             if (partOfstring[i] == '(')
             {
                 sk++;
                 continue;
             }
             if (partOfstring[i] == ')')
             {
                 sk--;
                 continue;
             }
             if ((partOfstring[i] == '+' || partOfstring[i] == '-' && i != 0) && sk == 0)
             {
                 Value = partOfstring[i].ToString();
                 Type  = NodeType.PlusMinus;
                 Left  = new ElementOfTree();
                 Left.S(partOfstring.Substring(0, i));
                 Right = new ElementOfTree();
                 Right.T(partOfstring.Substring(i + 1));
                 return;
             }
         }
         if (partOfstring[0] == '-')
         {
             Value = partOfstring[0].ToString();
             Type  = NodeType.MinusU;
             Left  = new ElementOfTree();
             Left.T(partOfstring.Substring(1, partOfstring.Length - 1));
             return;
         }
         T(partOfstring);
     }
     catch (ExpressionException e)
     {
         e.Node = GetNormalNodeState(partOfstring);
         throw;
     }
 }
        private void F(string partOfString)
        {
            if (String.IsNullOrWhiteSpace(partOfString))
            {
                throw new EmptyMemberException();
            }

            try
            {
                switch (partOfString[0])
                {
                case '[': Value = "["; Type = NodeType.Sin; Left = new ElementOfTree(); Left.S(partOfString.Substring(2, partOfString.Length - 3)); return;

                case ']': Value = "]"; Type = NodeType.Cos; Left = new ElementOfTree(); Left.S(partOfString.Substring(2, partOfString.Length - 3)); return;

                case '!': Value = "!"; Type = NodeType.Tan; Left = new ElementOfTree(); Left.S(partOfString.Substring(2, partOfString.Length - 3)); return;

                case '?': Value = "?"; Type = NodeType.Ln; Left = new ElementOfTree(); Left.S(partOfString.Substring(2, partOfString.Length - 3)); return;

                case '#': Value = "#"; Type = NodeType.Exp; Left = new ElementOfTree(); Left.S(partOfString.Substring(2, partOfString.Length - 3)); return;

                case '%': Value = "%"; Type = NodeType.Sqrt; Left = new ElementOfTree(); Left.S(partOfString.Substring(2, partOfString.Length - 3)); return;

                default: throw new IncorrectFunctionDefinitionException();
                }
            }
            catch (ArgumentOutOfRangeException e)
            {
                throw new BracketsMissingException();
            }
        }