public override object VisitExpressionContentNegative(FaParser.ExpressionContentNegativeContext context) { object expToNegate = Visit(context.expressionContent()); object result = null; if (expToNegate is double) { result = -Convert.ToDouble(expToNegate); } if (expToNegate is int) { result = -(int)expToNegate; } if (expToNegate is string || expToNegate is bool) { Debug.LogError("No es posible aplicar el operador - a string o bool"); // Console.WriteLine("No es posible aplicar el operador - a string o bool"); MyConsole.main.AppendText("No es posible aplicar el operador - a string o bool"); } return(result); }
/// <summary> /// Visit a parse tree produced by the <c>expressionContentNegative</c> /// labeled alternative in <see cref="FaParser.expressionContent"/>. /// <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 VisitExpressionContentNegative([NotNull] FaParser.ExpressionContentNegativeContext context) { return(VisitChildren(context)); }