Пример #1
0
        public override AstNode VisitIfElseIfExpr(StannumParser.IfElseIfExprContext 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.AltIf) is IfExpr alternative))
            {
                throw new Exception("Unrecognized if expression!");
            }

            return(new IfExpr(condition, consequent, alternative));
        }
Пример #2
0
 /// <summary>
 /// Visit a parse tree produced by the <c>IfElseIfExpr</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 VisitIfElseIfExpr([NotNull] StannumParser.IfElseIfExprContext context)
 {
     return(VisitChildren(context));
 }