/// <summary>
        /// Visit the anyof expression.
        /// </summary>
        /// <param name="expr">AnyOf expression.</param>
        /// <returns></returns>
        public object VisitAnyOf(AnyOfExpr expr)
        {
            var result     = false;
            var leftExpr   = expr.CompareExpr;
            var leftResult = leftExpr.Evaluate(this) as LObject;

            if (expr.ParamListExpressions == null || expr.ParamListExpressions.Count == 0)
            {
                return(new LBool(result));
            }

            // Resolve the parameters.
            ParamHelper.ResolveNonNamedParameters(expr.ParamListExpressions, expr.ParamList, this);

            foreach (var rvalue in expr.ParamList)
            {
                var rightResult   = rvalue as LObject;
                var compareResult = EvalHelper.Compare(expr, Operator.EqualEqual, leftResult, rightResult) as LObject;
                if (compareResult != null && compareResult.Type == LTypes.Bool && ((LBool)compareResult).Value == true)
                {
                    result = true;
                    break;
                }
            }
            return(new LBool(result));
        }
Exemple #2
0
        /// <summary>
        /// run step 123.
        /// </summary>
        /// <returns></returns>
        public override Expr Parse()
        {
            // 1. move past "of"
            _tokenIt.Advance(2);

            var anyofExpr = new AnyOfExpr();

            anyofExpr.Ctx = Ctx;
            anyofExpr.ParamListExpressions = new List <Expr>();
            anyofExpr.ParamList            = new List <object>();

            // 2. any of ( <expression>* )
            if (_tokenIt.NextToken.Token == Tokens.LeftParenthesis)
            {
                _parser.ParseParameters(anyofExpr, true, true, false);
            }
            else
            {
                _parser.ParseParameters(anyofExpr, false, true, true);
            }
            return(anyofExpr);
        }
 public object VisitAnyOf(AnyOfExpr expr)
 {
     return(null);
 }