public override Node VisitUnaryExpr(ML4DParser.UnaryExprContext context) { UnaryExpressionNode node; switch (context.op.Type) { case ML4DLexer.MINUS: node = new UnaryMinusNode("-"); node.Inner = (ExpressionNode)Visit(context.right); break; case ML4DLexer.NOT: node = new NotNode("not"); node.Inner = (ExpressionNode)Visit(context.inner); break; default: throw new NotSupportedException( $"The operator {context.op.Text}, is not a valid unary operator."); } return(node); }
/// <summary> /// Exit a parse tree produced by the <c>unaryExpr</c> /// labeled alternative in <see cref="ML4DParser.expr"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitUnaryExpr([NotNull] ML4DParser.UnaryExprContext context) { }
/// <summary> /// Visit a parse tree produced by the <c>unaryExpr</c> /// labeled alternative in <see cref="ML4DParser.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 VisitUnaryExpr([NotNull] ML4DParser.UnaryExprContext context) { return(VisitChildren(context)); }