public override string Execute(Ambit_Trad ambit) { var ambitName = "Global_For"; if (!ambit.IsNull) { ambitName = ambit.Ambit_name + "_For"; } var forAmbit = new Ambit_Trad(ambit, ambitName, "For", false); var val_init = inicializacion.Execute(forAmbit); var val_fin = actualizacion.Execute(forAmbit); var sentencias = sentence.Execute(forAmbit); var tabs = ""; for (int i = 0; i < cant_tabs; i++) { tabs = tabs + " "; } return (tabs + "for " + initId + ":= " + val_init + " " + direccion + " " + val_fin + " do \n" + tabs + "begin\n" + sentencias + tabs + "end\n"); }
public override string Execute(Ambit_Trad ambit) { var tabs = ""; for (int i = 0; i < cant_tabs; i++) { tabs = tabs + " "; } var ifAmbit = new Ambit_Trad(ambit, ambit.Ambit_name, "If", false); //CONDICION var condition = this.condition.Execute(ifAmbit); //SENTENCIAS var if_sentencias = this.sentences.Execute(ifAmbit); var if_total = tabs + "if " + condition + " then\n" + tabs + "begin\n" + if_sentencias + tabs + "end\n"; if (elif.IsNull) { return(if_total); } var elseAmbit = new Ambit_Trad(ambit, ambit.Ambit_name, "Else", false); var else_sentence = elif.Execute(elseAmbit); if_total += tabs + "else \n" + tabs + "begin \n" + else_sentence + tabs + "end;\n"; return(if_total); }