/// <summary> /// Visit a parse tree produced by <see cref="Z80TestParser.unaryExpr"/>. /// <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] Z80TestParser.UnaryExprContext context) { return(VisitChildren(context)); }
/// <summary> /// Exit a parse tree produced by <see cref="Z80TestParser.unaryExpr"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitUnaryExpr([NotNull] Z80TestParser.UnaryExprContext context) { }
/// <summary> /// Visit a parse tree produced by <see cref="Generated.Z80TestParser.unaryExpr"/>. /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public override object VisitUnaryExpr(Z80TestParser.UnaryExprContext context) { if (IsInvalidContext(context)) { return(null); } if (context.unaryExpr() != null) { var unexpr = (ExpressionNode)VisitUnaryExpr(context.unaryExpr()); var op = context.GetChild(0).GetText(); switch (op) { case "+": return(new UnaryPlusNode(context) { Operand = unexpr }); case "-": return(new UnaryMinusNode(context) { Operand = unexpr }); case "~": return(new UnaryBitwiseNotNode(context) { Operand = unexpr }); case "!": return(new UnaryLogicalNotNode(context) { Operand = unexpr }); } } if (context.literalExpr() != null) { return(VisitLiteralExpr(context.literalExpr())); } if (context.symbolExpr() != null) { return(VisitSymbolExpr(context.symbolExpr())); } if (context.registerSpec() != null) { return(VisitRegisterSpec(context.registerSpec())); } if (context.addrSpec() != null) { return(VisitAddrSpec(context.addrSpec())); } if (context.flag() != null) { return(VisitFlag(context.flag())); } if (context.reachSpec() != null) { return(VisitReachSpec(context.reachSpec())); } return(VisitExpr(context.GetChild(1) as Z80TestParser.ExprContext)); }