public override AstNode VisitIfElseExpr(StannumParser.IfElseExprContext context) { if (!(Visit(context.Cond) is Expr condition)) { throw new Exception("Unrecognized expression!"); } if (!(Visit(context.Cons) is BlockExpr consequent)) { throw new Exception("Unrecognized block expression!"); } if (!(Visit(context.Alt) is BlockExpr alternative)) { throw new Exception("Unrecognized block expression!"); } return(new IfExpr(condition, consequent, alternative)); }
/// <summary> /// Visit a parse tree produced by the <c>IfElseExpr</c> /// labeled alternative in <see cref="StannumParser.ifExpr"/>. /// <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 VisitIfElseExpr([NotNull] StannumParser.IfElseExprContext context) { return(VisitChildren(context)); }