// возвращает Statement (IfStatement) public override object VisitIfStatement([NotNull] DoshikParser.IfStatementContext context) { _compilationContext.SetParsingAntlrContext(context); var statement = new IfStatement(_currentNode); _currentExpressionParent = statement; statement.Condition = ExpressionCreationVisitor.Apply(_compilationContext, _currentExpressionParent, context.condition); if (statement.Condition.RootExpression.ReturnOutputSlot.Type != _compilationContext.TypeLibrary.FindByKnownType(KnownType.Boolean)) { throw _compilationContext.ThrowCompilationError("condition must evaluate to bool value"); } statement.TrueStatement = (Statement)Visit(context.trueBody); if (context.falseBody != null) { statement.FalseStatement = (Statement)Visit(context.falseBody); } return(statement); }
/// <summary> /// Visit a parse tree produced by the <c>ifStatement</c> /// labeled alternative in <see cref="DoshikParser.statement"/>. /// <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 VisitIfStatement([NotNull] DoshikParser.IfStatementContext context) { return(VisitChildren(context)); }
/// <summary> /// Exit a parse tree produced by the <c>ifStatement</c> /// labeled alternative in <see cref="DoshikParser.statement"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitIfStatement([NotNull] DoshikParser.IfStatementContext context) { }