public override Node VisitIfStmt([NotNull] FlyLangParser.IfStmtContext context) { var statement = new IfStatement(Visit(context.expression()), Visit(context.action())); if (context.elifStmt() != null) { var expr = new List <Node>(); var actions = new List <Node>(); var elifs = context.elifStmt(); foreach (var e in elifs) { expr.Add(Visit(e.expression())); actions.Add(Visit(e.action())); } statement.ElifActions = actions.ToArray(); statement.ElifExpressions = expr.ToArray(); } if (context.elseStmt() != null) { statement.ElseAction = Visit(context.elseStmt().action()); } return(statement); }
/// <summary> /// Visit a parse tree produced by <see cref="FlyLangParser.ifStmt"/>. /// <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 VisitIfStmt([NotNull] FlyLangParser.IfStmtContext context) { return(VisitChildren(context)); }