コード例 #1
0
        protected override void Visit(LogicalBindaryExpression exp)
        {
            // OR is the 3rd level
            if (exp.Operator == LogicalOperator.OR)
            {
                // Simply visit the 3rd OR level and build all ComparisonModels
                Visit(exp.Left);
                Visit(exp.Right);
            }
            if (exp.Operator == LogicalOperator.AND)
            {
                // Because this class only build for ONE condition at a time.
                // So if we encounter a AND expression, it must be the 2nd level, that is, the (ComparisonGroup AND ComparisonGroup) level
                Visit(exp.Left);
                BuildComparisonGroup();

                Visit(exp.Right);
                BuildComparisonGroup();
            }
        }
コード例 #2
0
ファイル: ExpressionVisitor.cs プロジェクト: Kooboo/Ecommerce
 protected virtual void Visit(LogicalBindaryExpression exp)
 {
     Visit(exp.Left);
     Visit(exp.Right);
 }
コード例 #3
0
ファイル: ExpressionVisitor.cs プロジェクト: Kooboo/Ecommerce
 void IExpressionVisitor.Visit(LogicalBindaryExpression exp)
 {
     Visit(exp);
 }
コード例 #4
0
 void IExpressionVisitor.Visit(LogicalBindaryExpression exp)
 {
     Visit(exp);
 }
コード例 #5
0
 protected virtual void Visit(LogicalBindaryExpression exp)
 {
     Visit(exp.Left);
     Visit(exp.Right);
 }
コード例 #6
0
        protected override void Visit(LogicalBindaryExpression exp)
        {
            Visit(exp.Left);

            // Check if we can get result by only checking left expression.
            // If yes, then the result in the stack is alreay the result.
            var leftResult = _results.Peek();

            // A and B, if A is false, the result will always be false, no need to check B
            if (exp.Operator == LogicalOperator.AND && leftResult == false)
            {
                return;
            }
            // A or B, if A is true, the result will always be true, no need to check B
            if (exp.Operator == LogicalOperator.OR && leftResult == true)
            {
                return;
            }

            // Pop the result of the left expression
            _results.Pop();

            // If we cannot get result by checking left expression,
            // then check right expression.
            // The final result is same as the result of the right expression.
            // For example,
            // A and B, if A is true, then final result = B
            // A or B, if A is false, then final result = B
            Visit(exp.Right);
        }
コード例 #7
0
ファイル: Parser.cs プロジェクト: Kooboo/Ecommerce
        // term : factor [ AND factor ]
        private Expression Term()
        {
            var exp = Factor();

            if (exp != null)
            {
                while (!_tokenzier.IsEndOfFile)
                {
                    using (var lookahead = _tokenzier.BeginLookahead())
                    {
                        var op = _tokenzier.NextToken();
                        if (op != null && op.Kind == TokenKind.AND)
                        {
                            var sourceLocation = _tokenzier.CurrentLocation;

                            var right = Factor();
                            if (right != null)
                            {
                                lookahead.Accept();
                                exp = new LogicalBindaryExpression(exp, right, LogicalOperator.AND);
                            }
                            else
                            {
                                _context.AddError("Missing right operand for operator " + op.Kind + ".", sourceLocation);
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }

            return exp;
        }