Exemple #1
0
        //Evaluate a check into a raw boolean (no value wrapper).
        public override object VisitCheck([NotNull] algoParser.CheckContext context)
        {
            //Switch for the type of check.
            if (context.BIN_AND() != null)
            {
                //Binary AND.
                //Evaluate the left and right values.
                AlgoValue left  = (AlgoValue)VisitCheck(context.check());
                AlgoValue right = (AlgoValue)VisitCheckfrag(context.checkfrag());

                //Return the comparison result of these two (as AlgoValue).
                return(new AlgoValue()
                {
                    Type = AlgoValueType.Boolean,
                    Value = AlgoComparators.AND(context, left, right),
                });
            }
            else if (context.BIN_OR() != null)
            {
                //Binary OR.
                //Evaluate the left and right values.
                AlgoValue left  = (AlgoValue)VisitCheck(context.check());
                AlgoValue right = (AlgoValue)VisitCheckfrag(context.checkfrag());

                //Return an OR on these values.
                return(new AlgoValue()
                {
                    Type = AlgoValueType.Boolean,
                    Value = AlgoComparators.OR(context, left, right),
                });
            }
            else if (context.LBRACKET() != null)
            {
                //Bracketed check.
                return((AlgoValue)VisitCheck(context.check()));
            }
            else if (context.INVERT_SYM() != null)
            {
                //Boolean invert.
                AlgoValue evaled = (AlgoValue)VisitCheck(context.check());

                //Get the boolean value for the evaluated value.
                bool evaledBool = AlgoComparators.GetBooleanValue(evaled, context);

                //Return the inverted bool.
                return(new AlgoValue()
                {
                    Type = AlgoValueType.Boolean,
                    Value = !evaledBool,
                });
            }
            else
            {
                //Just a checkfrag. Evaluate and return.
                return((AlgoValue)VisitCheckfrag(context.checkfrag()));
            }
        }
Exemple #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="algoParser.check"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitCheck([NotNull] algoParser.CheckContext context)
 {
     return(VisitChildren(context));
 }
Exemple #3
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="algoParser.check"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitCheck([NotNull] algoParser.CheckContext context)
 {
 }