//chyba v mene, musim potom opravit (Commnad) public override String VisitIfCommnad([NotNull] NewGrammarParser.IfCommnadContext context) { String expr = Visit(context.GetChild(1)); String temp_tab = this.tab; this.tab += "\t"; String lines = ""; //"if " + expr + ":" + Environment.NewLine; for (int i = 2; i < context.ChildCount; i++) { if (context.GetChild(i).GetType().Name.Equals("LineContext")) { lines += Visit(context.GetChild(i)); } else if (context.GetChild(i).GetText().Equals("elif")) { //this.tab = temp_tab; //temp_tab = this.tab; lines += temp_tab + "elif (" + Visit(context.GetChild(i + 2)) + "):" + Environment.NewLine; // this.tab += "\t"; } else if (context.GetChild(i).GetText().Equals("else")) { lines += temp_tab + "else:" + Environment.NewLine; } else if (context.GetChild(i).GetText().Equals("end if")) { break; } } this.tab = temp_tab; //return lines; return("if " + expr + ":" + Environment.NewLine + lines); //return base.VisitIfStatement(context); }
/// <summary> /// Enter a parse tree produced by <see cref="NewGrammarParser.ifCommnad"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void EnterIfCommnad([NotNull] NewGrammarParser.IfCommnadContext context) { }
/// <summary> /// Visit a parse tree produced by <see cref="NewGrammarParser.ifCommnad"/>. /// <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 VisitIfCommnad([NotNull] NewGrammarParser.IfCommnadContext context) { return(VisitChildren(context)); }