public override object VisitWhileLoopStatement([NotNull] DoshikParser.WhileLoopStatementContext context)
        {
            _compilationContext.SetParsingAntlrContext(context);

            var statement = new WhileStatement(_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");
            }

            _isInLoopCounter++;

            statement.BodyStatement = (Statement)Visit(context.body);

            _isInLoopCounter--;

            return(statement);
        }
예제 #2
0
 /// <summary>
 /// Visit a parse tree produced by the <c>whileLoopStatement</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 VisitWhileLoopStatement([NotNull] DoshikParser.WhileLoopStatementContext context)
 {
     return(VisitChildren(context));
 }
 /// <summary>
 /// Exit a parse tree produced by the <c>whileLoopStatement</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 ExitWhileLoopStatement([NotNull] DoshikParser.WhileLoopStatementContext context)
 {
 }