Exemplo n.º 1
0
        public override object VisitExprNot([NotNull] MiniSQLParser.ExprNotContext context)
        {
            Expression left = (Expression)Visit(context.expr());
            // if (left.Operator == Operator.AtomConcreteValue)
            // {
            //     if (left.ConcreteValue.Type == AttributeType.Char)
            //         throw new System.InvalidOperationException("Operator '!' cannot be applied to operand of type 'string'");
            //     if (left.ConcreteValue.Type == AttributeType.Float)
            //         throw new System.InvalidOperationException("Operator '!' cannot be applied to operand of type 'float'");
            //     if (left.ConcreteValue.Type == AttributeType.Int)
            //     {
            //         if (left.ConcreteValue.IntegerValue == 0)
            //             left.ConcreteValue.IntegerValue = 1;
            //         else
            //             left.ConcreteValue.IntegerValue = 0;
            //     }
            //     return left;
            // }
            Expression obj = new Expression();

            obj.LeftOperand = left;
            obj.Operator    = Operator.Not;
            // optimize expression
            if (left.Operator == Operator.AtomConcreteValue)
            {
                left.ConcreteValue = obj.Calculate(null);
                return(left);
            }
            return(obj);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Exit a parse tree produced by the <c>exprNot</c>
 /// labeled alternative in <see cref="MiniSQLParser.expr"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitExprNot([NotNull] MiniSQLParser.ExprNotContext context)
 {
 }
Exemplo n.º 3
0
 /// <summary>
 /// Visit a parse tree produced by the <c>exprNot</c>
 /// labeled alternative in <see cref="MiniSQLParser.expr"/>.
 /// <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 VisitExprNot([NotNull] MiniSQLParser.ExprNotContext context)
 {
     return(VisitChildren(context));
 }