Example #1
0
 public Field(string name, object value, Comparison comparison, Logical? logical)
 {
     Name = name;
     Value = value;
     Comparison = comparison;
     Logical = logical;
 }
        public void Parse_DadaQuery_DeveRetornarLogical(string query, Logical expected)
        {
            Where actual = query;

            foreach (var item in actual)
            {
                item.Logical.Should().Be(expected);
            }
        }
Example #3
0
        private Expr or()
        {
            Expr expr = and();

            while (match(TokenType.OR))
            {
                Token myOperator = previous();
                Expr  right      = and();
                expr = new Logical(expr, myOperator, right);
            }

            return(expr);
        }
Example #4
0
            public bool Equals(PulsarUrl?other)
            {
                if (ReferenceEquals(null, other))
                {
                    return(false);
                }

                if (ReferenceEquals(this, other))
                {
                    return(true);
                }
                return(Physical.Equals(other.Physical) && Logical.Equals(other.Logical));
            }
Example #5
0
        private Expr And()
        {
            Expr expr = Equality();

            while (Match(TokenType.AND))
            {
                Token op    = Previous();
                Expr  right = Equality();
                expr = new Logical(expr, op, right);
            }

            return(expr);
        }
        public async Task <JsonResult> getBookingDetails(String refcode)
        {
            var result = await Logical.GetBookingDetailsByRef(refcode);

            if (result.Item1.Object != null)
            {
                Session["bookingStatus"] = result.Item1.Object;
            }

            return(new JsonResult {
                Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Example #7
0
        private Expr and()
        {
            Expr expr = equality();

            while (match(TokenType.AND))
            {
                Token myOperator = previous();
                Expr  right      = equality();
                expr = new Logical(expr, myOperator, right);
            }

            return(expr);
        }
Example #8
0
        /// <summary>
        /// Parse a logical 'or' expression
        /// </summary>
        /// <returns>A logical 'or' expression node or an expression node<</returns>
        private Expr Or()
        {
            Expr expr = And();

            if (Match(TokenType.OR))
            {
                Token opr   = Previous();
                Expr  right = And();
                expr = new Logical(expr, opr, right);
            }

            return(expr);
        }
Example #9
0
        public void TestLogical()
        {
            var logical = new Logical(Word.and, Constant.True, Constant.False);

            Assert.AreEqual("true && false", logical.ToString());
            logical.Gen();

            //output:
            //iffalse true && false goto L1
            //        t1 = true
            //        goto L2
            //L1:	  t1 = false
            //L2:
        }
Example #10
0
 public override void Initialise()
 {
     // unlike most engines this will also create switches
     PhysicalSwitch.AssignSwitch(0, PhysicalSwitch.Types.Pointer, (int)m_Method);
     if (m_Method == Methods.DwellAveragePointer)
     {
         Logical.CreateSwitches(Logical.Number.PassThrough, this);
         (PhysicalSwitch.Switch(0) as PointerDwellAverageSwitch).Engine = this;
     }
     else
     {
         Logical.CreateSwitches(m_Dwell ? Logical.Number.DwellOnly : Logical.Number.One, this);
     }
     base.Initialise();             // must be AFTER switches assigned
 }
Example #11
0
        public void Visit(Logical e)
        {
            o.Write("( ");
            e.Left.Accept(this);
            o.Write(" ");
            switch (e.Op)
            {
            case LogicalOp.And:             o.Write("and");       break;

            case LogicalOp.Or:              o.Write("or");        break;
            }
            o.Write(" ");
            e.Right.Accept(this);
            o.Write(" )");
        }
Example #12
0
        /// <summary>
        /// Build And/Or Expression
        /// </summary>
        /// <param name="logical"></param>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        private static IWhereExpression BuildLogicalExpression(Logical logical, IWhereExpression left, IWhereExpression right)
        {
            //And/Or
            switch (logical)
            {
            case Logical.And:
                return(new AndAlsoExpression(left, right));

            case Logical.Or:
                return(new OrElseExpression(left, right));

            default:
                throw new NotSupportedException();
            }
        }
        public async Task <JsonResult> login(GigmsSignInModel user)
        {
            if (user != null)
            {
                var loginResponse = await Logical.SignIn(user);

                return(new JsonResult {
                    Data = loginResponse
                });
            }

            return(new JsonResult {
                Data = null, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Example #14
0
 public static void Post(string guid, string key)
 {
     //Check if there is already a Seen by the user
     if (!CheckExistence(guid, key))
     {
         //post new Seen
         Seen Seen = new Seen
         {
             Owner_Guid   = key,
             Confess_Guid = guid
         };
         Seen.Id = Logical.Setter(Seen.Id);
         contextLite.Seen.Insert(Seen);
         // context.Seen.InsertOne(Seen);
     }
 }
Example #15
0
        internal void Should_Apply_And_Or_Xor_Operands(Logical operand, bool firstTriggerValue, bool secondTriggerValue, bool expected)
        {
            var firstTrigger = A.Fake <ITrigger>();

            A.CallTo(() => firstTrigger.WillAffect()).Returns(firstTriggerValue);
            var secondTrigger = A.Fake <ITrigger>();

            A.CallTo(() => secondTrigger.WillAffect()).Returns(secondTriggerValue);

            var trigger = new CombinedTrigger(operand, firstTrigger)
            {
                Second = secondTrigger
            };

            Assert.Equal(expected, trigger.WillAffect());
        }
        public async Task <JsonResult> CustomerBookings(String Id)
        {
            if (!String.IsNullOrEmpty(Id))
            {
                var detail = await Logical.CustomerBookings(Id.Trim());

                return(new JsonResult {
                    Data = detail, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            else
            {
                return new JsonResult {
                           Data = null, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                }
            };
        }
Example #17
0
        public TypeSpecifier VisitLogicalExpression(Logical exp)
        {
            var tleft  = Examine(exp.Left);
            var tright = Examine(exp.Right);

            if (tleft.Type != TypeEnum.BOOL || tright.Type != TypeEnum.BOOL)
            {
                Console.WriteLine($"Not a boolean on either side of a logical operator on line: {exp.Operator.Line}");
                return(new TypeSpecifier {
                    Type = TypeEnum.UNKNOWN
                });
            }

            return(new TypeSpecifier {
                Type = TypeEnum.BOOL
            });
        }
Example #18
0
        private void FillTimings()
        {
            tblTimings.SuspendLayout();
            while (tblTimings.Controls.Count > 0)
            {
                tblTimings.Controls[0].Dispose();
            }
            if (m_Engine == null || !m_Loaded)
            {
                return;
            }
            Engine.Timings needed = m_Engine.RelevantTimings;
            for (int index = 0; index <= Logical.Count - 1; index++)
            {
                Logical logical = Logical.Switch(index);
                if (logical != null)
                {
                    needed = needed | logical.RequiredTimings;
                }
            }
            int row = 0;

            foreach (Engine.Timings timing in Enum.GetValues(typeof(Engine.Timings)))
            {
                if ((needed & timing) > 0)
                {
                    Label label = new Label {
                        Text = Strings.Item("Switch_Timing_" + timing), TextAlign = System.Drawing.ContentAlignment.MiddleRight, Dock = DockStyle.Fill
                    };
                    tblTimings.Controls.Add(label);
                    tblTimings.SetRow(label, row);
                    ctrEditTiming ctr = new ctrEditTiming {
                        Meaning = timing, Value = m_Engine.ConfiguredTiming(timing), Dock = DockStyle.Fill
                    };
                    ctr.UserChangedValue += TimingChanged;
                    tblTimings.Controls.Add(ctr);
                    tblTimings.SetRow(ctr, row);
                    tblTimings.SetColumn(ctr, 1);
                    row++;
                }
            }
            tblTimings.ResumeLayout();
        }
Example #19
0
        /// <summary>
        /// Parses a logical expression.
        /// </summary>
        /// <param name="callback">The function handling the higher precedence operators.</param>
        /// <param name="tokens">The tokens to be consumed.</param>
        /// <returns>An <see cref="AST.Expression"/> representing the expression.</returns>
        private Expression LogicalExpression(Func <Expression> callback, params TokenType[] tokens)
        {
            var expression = callback();

            while (AdvanceIfMatches(out _, tokens))
            {
                if (PreviousToken(out var @operator))
                {
                    expression = new Logical(expression, @operator, callback());
                }
                else
                {
                    // No previous token was available
                    break;
                }
            }

            return(expression);
        }
Example #20
0
        /*
         * Gets a composite logical (AndComposite or OrComposite based on the keyword on parts[1]).
         * */
        private static Logical GetLogicalFromParts(String[] parts)
        {
            // Get the left side and right side
            Logical leftSide = GetSideLogical(parts[0]), rightSide = GetSideLogical(parts[2]);

            // If the keyword is AND, build an AndCompositeLogical
            if (parts[1].Equals("and"))
            {
                return(new AndCompositeLogical(leftSide, rightSide));
            }
            // If the keyword is OR, build an AndCompositeLogical
            else if (parts[1].Equals("or"))
            {
                return(new OrCompositeLogical(leftSide, rightSide));
            }

            // If no keyword is found, throw an exception
            throw new ParseException("Invalid query format!");
        }
Example #21
0
        public async Task <ActionResult> PaySwitchPayment()
        {
            string queryRef = Request.QueryString["transaction_id"]?.ToString();

            ProcessTheTellerPayment pswpayment = new ProcessTheTellerPayment();

            pswpayment.RefCode = queryRef;



            var bookingResult = await Logical.PostPaySwitchPayment(pswpayment);

            var error = bookingResult.Item2;

            Session["queryRef"] = pswpayment.RefCode;

            if (error != null)
            {
                Session["transactionDetails"] = bookingResult.Item1;
                Session["Errormsg"]           = "Transaction Failed";
                return(RedirectToAction("PaymentError"));
            }

            if (bookingResult.Item1.Object != null)
            {
                Session["transactionDetails"] = bookingResult.Item1;
                //var refCode =
                if (bookingResult.Item1.Object.Response.ToLower() == "approved")
                {
                    return(RedirectToAction("PaymentConfirmation"));
                }
                else
                {
                    Session["Errormsg"] = bookingResult.Item1.Object.Response;
                    return(RedirectToAction("PaymentError"));
                }
            }
            else
            {
                Session["Errormsg"] = "Transaction Failed";
                return(RedirectToAction("PaymentError"));
            }
        }
Example #22
0
        public async Task <ActionResult> FlutterwavePay(string refcode)
        {
            string queryRef = refcode;

            ProcessFlutterWavePayment flwpayment = new ProcessFlutterWavePayment();

            flwpayment.RefCode = queryRef;

            var bookingResult = await Logical.PostFlutterWavePayment(flwpayment);


            var error = bookingResult.Item2;

            Session["queryRef"] = flwpayment.RefCode;

            if (error != null)
            {
                Session["transactionDetails"] = bookingResult.Item1;
                Session["Errormsg"]           = "Transaction Failed";
                return(RedirectToAction("PaymentError"));
            }

            if (bookingResult.Item1.Object != null)
            {
                Session["transactionDetails"] = bookingResult.Item1;
                //var refCode =
                if (bookingResult.Item1.Object.Response.ToLower() == "approved")
                {
                    return(RedirectToAction("PaymentConfirmation"));
                }
                else
                {
                    Session["Errormsg"] = bookingResult.Item1.Object.Response;
                    return(RedirectToAction("PaymentError"));
                }
            }
            else
            {
                Session["Errormsg"] = "Transaction Failed";
                return(RedirectToAction("PaymentError"));
            }
        }
Example #23
0
        object Expr.Visitor <object> .visitLogicalExpr(Logical expr)
        {
            Object left = evaluate(expr.left);

            if (expr.myOperator.type == TokenType.OR)
            {
                if (isTruthy(left))
                {
                    return(left);
                }
            }
            else
            {
                if (!isTruthy(left))
                {
                    return(left);
                }
            }
            return(evaluate(expr.right));
        }
Example #24
0
    public static bool IsSet <T>(T mask, T flagMask, Logical mode) where T : struct
    {
        Debug.AssertFormat(mode == Logical.AND ||
                           mode == Logical.OR,
                           "invalid mode provided");

        var shift   = 1;
        var matches = 0;
        var flags   = 0;
        var result  = false;

        for (var i = 0; i < 8 * sizeof(int); ++i)
        {
            var check = (T)(object)(shift << i);

            if (IsSet(flagMask, check))
            {
                // The flagmask has this bit set
                flags++;

                if (IsSet(mask, check))
                {
                    // There was a flag match for the input mask
                    matches++;
                }
            }
        }

        switch (mode)
        {
        case Logical.AND:
            result = matches == flags;
            break;

        case Logical.OR:
            result = matches > 0;
            break;
        }

        return(result);
    }
Example #25
0
 protected virtual void Dispose(bool disposing)
 {
     if (m_Disposed)
     {
         return;
     }
     if (disposing)
     {
         if (m_Timer != null)
         {
             m_Timer.Dispose();
             m_Timer = null;
         }
         if (Switch1 != null)
         {
             Switch1.StateChanged -= Switch1Changed;
             Switch1 = null;                     // note we don't dispose the switch - it isn't owned by this
             // but we do dereference it to make sure nothing is held in memory
         }
     }
 }
Example #26
0
        public object VisitLogicalExpr(Logical expr)
        {
            object left = Evaluate(expr.Left);

            if (expr.Op.Type == TokenType.OR)
            {
                if (IsTruthy(left))
                {
                    return(left);
                }
            }
            else
            {
                if (!IsTruthy(left))
                {
                    return(left);
                }
            }

            return(Evaluate(expr.Right));
        }
Example #27
0
        object Expressions.IVisitor <object> .VisitLogicalExpr(Logical expr)
        {
            object left = Evaluate(expr.Left);

            if (expr.Operator.Type == TokenType.OR)
            {
                if (IsTruthy(left))
                {
                    return(left);
                }
            }
            else
            {
                if (!IsTruthy(left))
                {
                    return(left);
                }
            }

            return(Evaluate(expr.Right));
        }
        public async Task <JsonResult> ForgotPassword(PasswordReset obj)
        {
            var result = new Object();

            try
            {
                var result_ = await Logical.ForgotPassword(obj);

                return(new JsonResult {
                    Data = result_
                });
            }
            catch (Exception ex)
            {
                Logical.WriteToLog(ex.Message);
            }


            return(new JsonResult {
                Data = result
            });
        }
Example #29
0
 private NodoAvl reemplazar(NodoAvl n, NodoAvl act, Logical cambiaAltura)
 {
     if (act.subarbolDcho() != null)
     {
         NodoAvl d;
         d = reemplazar(n, (NodoAvl)act.subarbolDcho(), cambiaAltura);
         act.ramaDcho(d);
         if (cambiaAltura.booleanValue())
         {
             act = equilibrar2(act, cambiaAltura);
         }
     }
     else
     {
         n.nuevoValor(act.valorNodo());
         n   = act;
         act = (NodoAvl)act.subarbolIzdo();
         n   = null;
         cambiaAltura.setLogical(true);
     }
     return(act);
 }
Example #30
0
        public Expression EXPLOGICA_PRIMA(ParseTreeNode actual, Expression izq)
        {
            /*
             * EXPLOGICA_PRIMA.Rule
             *  = AND + EXPRELACIONAL + EXPLOGICA_PRIMA
             | OR + EXPRELACIONAL + EXPLOGICA_PRIMA
             | Empty
             |  ;
             */

            if (actual.ChildNodes.Count > 0)
            {
                var simb    = actual.ChildNodes[0].Token.Text.ToLower();
                var derecho = EXPRELACIONAL(actual.ChildNodes[1]);
                var row     = actual.ChildNodes[0].Token.Location.Line;
                var col     = actual.ChildNodes[0].Token.Location.Column;

                var relacional = new Logical(izq, derecho, simb, row, col);
                return(EXPLOGICA_PRIMA(actual.ChildNodes[2], relacional));
            }
            return(izq);
        }
Example #31
0
        public static void CreateTable()
        {
            var varList     = Enumerable.Range(80, numberOfVariables).Select(it => Convert.ToChar(it));
            var varListText = string.Join(" | ", varList);

            var count = 4 * numberOfVariables + 6;
            var line  = new String('-', count);

            Console.WriteLine($"{varListText} | result");
            Console.WriteLine(line);

            var sampleSpace = Logical.CreateSampleSpace(numberOfVariables);

            foreach (var pattern in sampleSpace)
            {
                var truthList     = pattern.ToList().Select(it => it = (it == '1') ? 'T' : 'F');
                var truthListText = string.Join(" | ", truthList);

                var result = logicalFunc(pattern) ? 'T' : 'F';

                Console.WriteLine($"{truthListText} |   {result}");
            }
        }
Example #32
0
        /// <summary>
        /// Evaluate a logical expression
        /// </summary>
        /// <param name="expr">Logical expression to evaluate</param>
        /// <returns>Evaluated logical expressed</returns>
        public object VisitLogicalExpr(Logical expr)
        {
            object left = Evaluate(expr.Left);

            if (expr.Operator.Type == TokenType.OR)
            {
                if (IsTruthy(left))
                {
                    return(true);
                }
            }
            else
            {
                // if it's an and operator and left side is false
                // return false without checking right side
                if (!IsTruthy(left))
                {
                    return(false);
                }
            }

            return(Evaluate(expr.Right));
        }
Example #33
0
 private Logical GetLogical(Func<ITrack, Logical> getLogical, ref Logical result)
 {
     if (result == Logical.Unknown && Files != null)
         foreach (var value in Files.Select(getLogical))
         {
             result |= value;
             if (result == (Logical.Yes | Logical.No))
                 break;
         }
     return result;
 }
Example #34
0
 /// <summary>
 /// Build And/Or Expression
 /// </summary>
 /// <param name="logical"></param>
 /// <param name="left"></param>
 /// <param name="right"></param>
 /// <returns></returns>
 private static IWhereExpression BuildLogicalExpression(Logical logical, IWhereExpression left, IWhereExpression right)
 {
     //And/Or
     switch (logical)
     {
         case Logical.And:
             return new AndAlsoExpression(left, right);
         case Logical.Or:
             return new OrElseExpression(left, right);
         default:
             throw new NotSupportedException();
     }
 }
Example #35
0
        protected virtual String ParseLogical(Logical logical) {
            String parsed = "";

            if (logical is Or) {
                parsed = "$or";
            }
            else if (logical is And) {
                parsed = "$and";
            }

            return parsed;
        }