public override Value VisitRelationalExpr(AbstractIfStmtParser.RelationalExprContext ctx) { Value left = this.Visit(ctx.expr(0)); Value right = this.Visit(ctx.expr(1)); if ((!left.isNumeric()) && right.isNumeric()) { return(new Value(false));//Condition where double values are not defined } if ((left.isNumeric()) && !right.isNumeric()) { return(new Value(false)); } int ctxType = ctx.op.Type; switch (ctxType) { case AbstractIfStmtParser.LT: return(new Value(left.asDouble() < right.asDouble())); case AbstractIfStmtParser.LTEQ: return(new Value(left.asDouble() <= right.asDouble())); case AbstractIfStmtParser.GT: return(new Value(left.asDouble() > right.asDouble())); case AbstractIfStmtParser.GTEQ: return(new Value(left.asDouble() >= right.asDouble())); default: return(new Value(false)); } }
/// <summary> /// Visit a parse tree produced by <see cref="AbstractIfStmtParser.relationalExpr"/>. /// <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 VisitRelationalExpr([NotNull] AbstractIfStmtParser.RelationalExprContext context) { return(VisitChildren(context)); }
/// <summary> /// Exit a parse tree produced by <see cref="AbstractIfStmtParser.relationalExpr"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitRelationalExpr([NotNull] AbstractIfStmtParser.RelationalExprContext context) { }