public override Expression VisitUnaryOpExp([NotNull] ExpressionAntlrParser.UnaryOpExpContext context) { var unaryOperationName = context.GetChild(0).GetText(); var operand = Visit(context.expression()); if (unaryOperationName == ExpressionType.Subtract || unaryOperationName == ExpressionType.Add) { return(MakeExpression(unaryOperationName, new Constant(0), operand)); } return(MakeExpression(unaryOperationName, operand)); }
/// <summary> /// Exit a parse tree produced by the <c>unaryOpExp</c> /// labeled alternative in <see cref="ExpressionAntlrParser.expression"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitUnaryOpExp([NotNull] ExpressionAntlrParser.UnaryOpExpContext context) { }
/// <summary> /// Visit a parse tree produced by the <c>unaryOpExp</c> /// labeled alternative in <see cref="ExpressionAntlrParser.expression"/>. /// <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 VisitUnaryOpExp([NotNull] ExpressionAntlrParser.UnaryOpExpContext context) { return(VisitChildren(context)); }