Example #1
0
        public override int VisitIterative([NotNull] CBluntParser.IterativeContext context)
        {
#if DEBUG
            Console.WriteLine("VisitIterative");
#endif
            if (context.GetChild(0).GetText() == "while")
            {
                this.AddText("while (");
                Visit(context.condition());
                this.AddText(")");
                Visit(context.block());
            }
            else if (context.GetChild(0).GetText() == "for")
            {
                this.AddText("for (");
                for (int counter = 2; counter < 8; ++counter)
                {
                    if (context.GetChild(counter).GetText() == ";")
                    {
                        this.AddSemicolon(false);
                    }
                    else
                    {
                        Visit(context.GetChild(counter));
                    }
                }
                this.AddText(")");
                Visit(context.block());
            }
            return(0);
        }
Example #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="CBluntParser.iterative"/>.
 /// <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 VisitIterative([NotNull] CBluntParser.IterativeContext context)
 {
     return(VisitChildren(context));
 }