Esempio n. 1
0
        public CBinOp(EBinOp op, CArg arg1, CArg arg2)
        {
            _op   = op;
            _arg1 = arg1;
            _arg2 = arg2;

            _arg1.SetOwner(this);
            _arg2.SetOwner(this);
        }
Esempio n. 2
0
        static KeyValuePair <bool, IMathFunc> BuildTriplet(int inPos, List <SBuildElem> inList, ILogger inLogger)
        {
            if (inPos <= 0 || inPos >= inList.Count - 1)
            {
                LogError(inLogger, EErrorCode.InvalidTripletPosition, $"{inList[inPos].StartLineIndex}");
                return(new KeyValuePair <bool, IMathFunc>(false, null));
            }

            EBinOp     op_type = EBinOp.Undefined;
            SBuildElem el      = inList[inPos];

            if (el.Token != null)
            {
                op_type = el.Token.GetBinOp();
            }

            if (op_type == EBinOp.Undefined)
            {
                if (el.Token != null)
                {
                    LogError(inLogger, EErrorCode.BinOperationUndefined, el.Token);
                }
                else
                {
                    LogError(inLogger, EErrorCode.BinOperationUndefined, string.Format("el.Op {0}", el.Op));
                }
                return(new KeyValuePair <bool, IMathFunc>(false, null));
            }

            //left
            el = inList[inPos - 1];
            CArg left_arg = BuildElemToArg(el, inLogger);

            //right
            el = inList[inPos + 1];
            CArg right_arg = BuildElemToArg(el, inLogger);

            if (left_arg == null || right_arg == null)
            {
                return(new KeyValuePair <bool, IMathFunc>(false, null));
            }

            return(new KeyValuePair <bool, IMathFunc>(true, new CBinOp(op_type, left_arg, right_arg)));
        }
Esempio n. 3
0
        static KeyValuePair <bool, IMathFunc> CheckOneOrMany(int inStartPos, int inEndPos, List <SBuildElem> inList, ILogger inLogger)
        {
            if (inStartPos == inEndPos)
            {
                CArg arg = BuildElemToArg(inList[inStartPos], inLogger);
                return(new KeyValuePair <bool, IMathFunc>(true, arg));
            }

            List <SBuildElem> lst_wo_bracers = ChangeBracers(inStartPos, inEndPos, inList, inLogger);

            if (lst_wo_bracers == null)
            {
                return(new KeyValuePair <bool, IMathFunc>(false, null));
            }

            KeyValuePair <bool, IMathFunc> res_op = BuildBinOp(lst_wo_bracers, inLogger);

            return(res_op);
        }