Beispiel #1
0
        public double ProccessFunction(string expr, ref int index, XMParser xmParser, List <XArray> arrs)
        {
            string[] parameters;
            index += name.Length + 1;
            int ti = index;

            for (int i = 1; i > 0; index++)
            {
                if (expr[index] == XSyntax.OpenRoundBracket)
                {
                    i++;
                }
                else if (expr[index] == XSyntax.CloseRoundBracket)
                {
                    i--;
                }
            }
            string s = expr.Substring(ti, index - ti - 1);

            if (s != "")
            {
                parameters = Helper.SplitOutOfBrackets(s, XSyntax.Comma, XSyntax.OpenRoundBracket, XSyntax.CloseRoundBracket);
            }
            else
            {
                parameters = new string[0];
            }
            return(OverrideFunction(parameters, xmParser, arrs));
        }
 public XSParser()
 {
     xmParser = new XMParser();
     processes = new List<Process>();
     processes.Add(new IfProcess());
     processes.Add(new WhileProcess());
     processes.Add(new FunctionProcess());
     processes.Add(new ForProcess());
 }
Beispiel #3
0
 /// <summary>
 /// Initializes the Math Parser, Commands, and Processes
 /// </summary>
 public XSParser()
 {
     xmParser  = new XMParser();
     processes = new List <Process>();
     commands  = new List <Command>();
     processes.Add(new IfProcess());
     processes.Add(new WhileProcess());
     processes.Add(new FunctionProcess());
     processes.Add(new ForProcess());
     commands.Add(new SumArray());
 }
 /// <summary>
 /// Initializes the Math Parser, Commands, and Processes
 /// </summary>
 public XSParser()
 {
     xmParser = new XMParser();
     processes = new List<Process>();
     commands = new List<Command>();
     processes.Add(new IfProcess());
     processes.Add(new WhileProcess());
     processes.Add(new FunctionProcess());
     processes.Add(new ForProcess());
     commands.Add(new SumArray());
 }
 public double ProccessFunction(string expr, ref int index, XMParser xmParser, List<XArray> arrs)
 {
     string[] parameters;
     index += name.Length + 1;
     int ti = index;
     for (int i = 1; i > 0; index++)
     {
         if (expr[index] == XSyntax.OpenRoundBracket)
             i++;
         else if (expr[index] == XSyntax.CloseRoundBracket)
             i--;
     }
     string s = expr.Substring(ti, index - ti - 1);
     if (s != "")
         parameters = Helper.SplitOutOfBrackets(s, XSyntax.Comma, XSyntax.OpenRoundBracket, XSyntax.CloseRoundBracket);
     else
         parameters = new string[0];
     return OverrideFunction(parameters, xmParser, arrs);
 }
Beispiel #6
0
 protected override double OverrideFunction(string[] parameters, XMParser xmParser, List <XArray> xarrs)
 {
     if (param)
     {
         double[] mparameters = new double[parameters.Length];
         for (int i = 0; i < parameters.Length; i++)
         {
             mparameters[i] = xmParser.GetDouble(parameters[i], 0, xarrs);
         }
         XArray array = new XArray(arrs[0], mparameters.Length);
         array.vars  = mparameters;
         array.level = 1;
         List <XArray> arrList = new List <XArray>();
         arrList.Add(array);
         return(xsParser.ParseReturnVariable(code, 1, arrList));
     }
     else
     {
         List <XArray> arrays = new List <XArray>();
         for (int i = 0; i < parameters.Length; i++)
         {
             int k = -1;
             for (int j = 0; j < xarrs.Count; j++)
             {
                 if (xarrs[j].name == parameters[i])
                 {
                     k = j;
                     break;
                 }
             }
             if (k != -1)
             {
                 arrays.Add(new XArray(arrs[i], xarrs[k].vars.Length));
                 arrays[arrays.Count - 1].vars  = xarrs[k].vars;
                 arrays[arrays.Count - 1].level = 1;
             }
         }
         return(xsParser.ParseReturnVariable(code, 1, arrays));
     }
 }
 protected override double OverrideFunction(string[] parameters, XMParser xmParser, List<XArray> xarrs)
 {
     if (param)
     {
         double[] mparameters = new double[parameters.Length];
         for (int i = 0; i < parameters.Length; i++)
             mparameters[i] = xmParser.GetDouble(parameters[i], 0, xarrs);
         XArray array = new XArray(arrs[0], mparameters.Length);
         array.vars = mparameters;
         array.level = 1;
         List<XArray> arrList = new List<XArray>();
         arrList.Add(array);
         return xsParser.ParseReturnVariable(code, 1, arrList);
     }
     else
     {
         List<XArray> arrays = new List<XArray>();
         for (int i = 0; i < parameters.Length; i++)
         {
             int k = -1;
             for (int j = 0; j < xarrs.Count; j++)
             {
                 if (xarrs[j].name == parameters[i])
                 {
                     k = j;
                     break;
                 }
             }
             if (k != -1)
             {
                 arrays.Add(new XArray(arrs[i], xarrs[k].vars.Length));
                 arrays[arrays.Count - 1].vars = xarrs[k].vars;
                 arrays[arrays.Count - 1].level = 1;
             }
         }
         return xsParser.ParseReturnVariable(code, 1, arrays);
     }
 }
Beispiel #8
0
 protected virtual double OverrideFunction(string[] parameters, XMParser xmParser, List <XArray> arrs)
 {
     return(0);
 }
 protected virtual double OverrideFunction(string[] parameters, XMParser xmParser, List<XArray> arrs)
 {
     return 0;
 }