Пример #1
0
 protected override List<XArray> OverrideProcess(string code, List<XArray> arrs, XSParser parser, string[] cons, int codeLevel)
 {
     if (cons.Length != 2)
         throw new XLogicException(Messages.InvalidNumCons);
     int from = (int)parser.ParseMathExpr(cons[0], arrs);
     int to = (int)parser.ParseMathExpr(cons[1], arrs);
     List<XArray> t = new List<XArray>();
     t.Add(new XArray("loop." + codeLevel + ".from", 1));
     t.Add(new XArray("loop." + codeLevel + ".to", 1));
     t[0].vars[0] = from;
     t[1].vars[0] = to;
     t.Add(new XArray("loop." + codeLevel + ".current", 1));
     t.Add(new XArray("loop.this.from", 1));
     t.Add(new XArray("loop.this.to", 1));
     t[3].vars[0] = from;
     t[4].vars[0] = to;
     t.Add(new XArray("loop.this.current", 1));
     for (int i = from; i <= to; i++)
     {
         if (i > 1000000)
             throw new EndlessException(Messages.LoopStuck);
         t[2].vars[0] = i;
         t[5].vars[0] = i;
         arrs = Helper.OnlyBeneathLevel(parser.ParseReturn(code, codeLevel + 1, XArray.ConnectLists(arrs, t)), codeLevel);
     }
     return arrs;
 }
 protected override List<XArray> OverrideProcess(string code, List<XArray> arrs, XSParser parser, string[] cons, int codeLevel)
 {
     string funcName = cons[0];
     string[] arrsNames = new string[cons.Length - 1];
     bool p = false;
     if (cons[1].Replace(" ", "").StartsWith(XSyntax.ParamsWord))
     {
         if (cons.Length != 2)
             throw new ParseException(Messages.ParamArray);
         for (int j = XSyntax.ParamsWord.Length + 1; j < cons[1].Length; j++)
         {
             if (cons[1][j] == ' ')
                 continue;
             else
             {
                 arrsNames[0] = cons[1].Substring(j);
                 p = true;
                 break;
             }
         }
     }
     else
     {
         for (int i = 1; i < cons.Length; i++)
             arrsNames[i - 1] = cons[i];
     }
     parser.xmParser.mathFunctions.Add(new MathFunction(funcName, code, p, arrsNames, parser));
     return arrs;
 }
Пример #3
0
 protected override List<XArray> OverrideCommand(string[] parameters, XSParser parser, List<XArray> arrs)
 {
     int varIndex = Helper.ArrayIndex(arrs, parameters[1].Replace(" ", ""));
     int arrIndex = Helper.ArrayIndex(arrs, parameters[0].Replace(" ", ""));
     arrs[varIndex].vars[0] =
     for(int i = 0; i<arrs[arrIndex].vars.Length;i++)
 }
Пример #4
0
 protected override List<XArray> OverrideProcess(string code, List<XArray> arrs, XSParser parser, string[] cons, int codeLevel)
 {
     if (cons.Length != 1)
         throw new XLogicException(Messages.InvalidNumCons);
     if (Helper.BooleanExpression(cons[0], arrs, parser))
         arrs = Helper.OnlyBeneathLevel(parser.ParseReturn(code, codeLevel + 1, arrs), codeLevel);
     return arrs;
 }
Пример #5
0
 protected override List<XArray> OverrideCommand(string[] parameters, XSParser parser, List<XArray> arrs)
 {
     int varIndex = Helper.ArrayIndex(arrs, parameters[1].Replace(" ", ""));
     int arrIndex = Helper.ArrayIndex(arrs, parameters[0].Replace(" ", ""));
     if (arrs[varIndex].vars.Length > 1)
         throw new ParseException(Messages.FaieldToSumArr);
     arrs[varIndex].vars[0] = 0;
     for (int i = 0; i < arrs[arrIndex].vars.Length; i++)
         arrs[varIndex].vars[0] += arrs[arrIndex].vars[i];
     return arrs;
 }
Пример #6
0
        protected override List <XArray> OverrideCommand(string[] parameters, XSParser parser, List <XArray> arrs)
        {
            int varIndex = Helper.ArrayIndex(arrs, parameters[1].Replace(" ", ""));
            int arrIndex = Helper.ArrayIndex(arrs, parameters[0].Replace(" ", ""));

            if (arrs[varIndex].vars.Length > 1)
            {
                throw new ParseException(Messages.FaieldToSumArr);
            }
            arrs[varIndex].vars[0] = 0;
            for (int i = 0; i < arrs[arrIndex].vars.Length; i++)
            {
                arrs[varIndex].vars[0] += arrs[arrIndex].vars[i];
            }
            return(arrs);
        }
Пример #7
0
 protected override List <XArray> OverrideProcess(string code, List <XArray> arrs, XSParser parser, string[] cons, int codeLevel)
 {
     if (cons.Length != 1)
     {
         throw new XLogicException(Messages.InvalidNumCons);
     }
     for (int i = 0; Helper.BooleanExpression(cons[0], arrs, parser); i++)
     {
         if (i > 1000000)
         {
             throw new EndlessException(Messages.LoopStuck);
         }
         arrs = Helper.OnlyBeneathLevel(parser.ParseReturn(code, codeLevel + 1, arrs), codeLevel);
     }
     return(arrs);
 }
Пример #8
0
        protected override List <XArray> OverrideProcess(string code, List <XArray> arrs, XSParser parser, string[] cons, int codeLevel)
        {
            string funcName = cons[0];

            string[] arrsNames = new string[cons.Length - 1];
            bool     p         = false;

            if (cons[1].Replace(" ", "").StartsWith(XSyntax.ParamsWord))
            {
                if (cons.Length != 2)
                {
                    throw new ParseException(Messages.ParamArray);
                }
                for (int j = XSyntax.ParamsWord.Length + 1; j < cons[1].Length; j++)
                {
                    if (cons[1][j] == ' ')
                    {
                        continue;
                    }
                    else
                    {
                        arrsNames[0] = cons[1].Substring(j);
                        p            = true;
                        break;
                    }
                }
            }
            else
            {
                for (int i = 1; i < cons.Length; i++)
                {
                    arrsNames[i - 1] = cons[i];
                }
            }
            parser.xmParser.mathFunctions.Add(new MathFunction(funcName, code, p, arrsNames, parser));
            return(arrs);
        }
Пример #9
0
        protected override List <XArray> OverrideProcess(string code, List <XArray> arrs, XSParser parser, string[] cons, int codeLevel)
        {
            if (cons.Length != 2)
            {
                throw new XLogicException(Messages.InvalidNumCons);
            }
            int           from = (int)parser.ParseMathExpr(cons[0], arrs);
            int           to   = (int)parser.ParseMathExpr(cons[1], arrs);
            List <XArray> t    = new List <XArray>();

            t.Add(new XArray("loop." + codeLevel + ".from", 1));
            t.Add(new XArray("loop." + codeLevel + ".to", 1));
            t[0].vars[0] = from;
            t[1].vars[0] = to;
            t.Add(new XArray("loop." + codeLevel + ".current", 1));
            t.Add(new XArray("loop.this.from", 1));
            t.Add(new XArray("loop.this.to", 1));
            t[3].vars[0] = from;
            t[4].vars[0] = to;
            t.Add(new XArray("loop.this.current", 1));
            for (int i = from; i <= to; i++)
            {
                if (i > 1000000)
                {
                    throw new EndlessException(Messages.LoopStuck);
                }
                t[2].vars[0] = i;
                t[5].vars[0] = i;
                arrs         = Helper.OnlyBeneathLevel(parser.ParseReturn(code, codeLevel + 1, XArray.ConnectLists(arrs, t)), codeLevel);
            }
            return(arrs);
        }