public override String VisitWhileCommand([NotNull] NewGrammarParser.WhileCommandContext context) { String expr = Visit(context.GetChild(2)); String temp_tab = this.tab; this.tab += "\t"; String lines = ""; for (int i = 4; i < context.ChildCount; i++) { if (context.GetChild(i).GetType().Name.Equals("LineContext")) { lines += Visit(context.GetChild(i)); } else if (context.GetChild(i).GetText().Equals("end while")) { break; } } this.tab = temp_tab; return("while (" + expr + "):" + Environment.NewLine + lines); //return base.VisitWhileStatement(context); }
/// <summary> /// Exit a parse tree produced by <see cref="NewGrammarParser.whileCommand"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitWhileCommand([NotNull] NewGrammarParser.WhileCommandContext context) { }
/// <summary> /// Visit a parse tree produced by <see cref="NewGrammarParser.whileCommand"/>. /// <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 VisitWhileCommand([NotNull] NewGrammarParser.WhileCommandContext context) { return(VisitChildren(context)); }