예제 #1
0
 public override CompilerParser VisitWhile([NotNull] CompilerParser.WhileContext context)
 {
     VisitCondition(context.cond);
     if (context.cond.val)
     {
         // Перебираем все дочерние Statement'ы, по сути представляет собой одну итерацию
         for (int i = 0; i < context.statement().Length; i++)
         {
             // Если встречаем break, то сразу выходим из правила
             if (context.statement()[i].@break != null)
             {
                 return(null);
             }
             // Если встретили continue, то выходим только из текущей итерации
             if (context.statement()[i].cont != null)
             {
                 break;
             }
             // В остальных случаях просто заходим в очередной statement
             Visit(context.statement()[i]);
         }
         // Следующая итерация
         return(VisitWhile(context));
     }
     return(null);
 }
예제 #2
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="CompilerParser.while"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitWhile([NotNull] CompilerParser.WhileContext context)
 {
 }
예제 #3
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="CompilerParser.while"/>.
 /// <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 VisitWhile([NotNull] CompilerParser.WhileContext context)
 {
     return(VisitChildren(context));
 }