public override string CodeOutput(int level) { string levelString = new string ('\t', level); string Code = ""; Conditions ThisParent = ((Conditions)this.Parent.Parent); if (ThisParent.comboBox2.SelectedIndex != -1) { string type = ""; Dictionary <string, string> constant = Util.GetVariableType(this); CheckLetters.CheckVariables(ThisParent.comboBox2.Text, this.textBox1.Text, Util.GetVariableType(this), true); if (constant[ThisParent.comboBox2.Text] == "string") { type = "\"" + textBox1.Text + "\""; } else if (constant[ThisParent.comboBox2.Text] == "char") { type = "\'" + textBox1.Text + "\""; } else { type = textBox1.Text; } Code = levelString + "case " + type + ":" + statementBlock1.CodeOutput(level, false); } else { Form1.MessageBoxValue("caseの定数が入力されていません", true); } return(Code); }
private void ComboBox4_TextChanged(object sender, EventArgs e) { if (checkBox1.Checked) { Dictionary <string, string> TypeDictionary = Util.GetVariableType(this); CheckLetters.CheckVariables(comboBox2.Text, comboBox4.Text, TypeDictionary, false); } }
public override string CodeOutput(int level) { string CodeOutput = ""; string childcontrol = this.statementBlock1.CodeOutput(level, true); string childcontrol2 = this.statementBlock2.CodeOutput(level, true); string levelString = new string('\t', level); Dictionary <string, string> TypeDictionary = Util.GetVariableType(this); string value; if (comboBox1.SelectedIndex == 0) { List <string> vList = Util.GetVariableList(this, 0); if (comboBox2.SelectedIndex == -1) { Form1.MessageBoxValue("条件の変数又は定数が入力されていません", true); } else if (comboBox3.SelectedIndex == -1) { Form1.MessageBoxValue("条件が正しくありません", true); } else if (vList.Contains(comboBox1.Text)) { Form1.MessageBoxValue("未宣言の変数が使われています", true); } else { if (checkBox1.Checked) { CheckLetters.CheckVariables(comboBox2.Text, comboBox4.Text, TypeDictionary, true); if (TypeDictionary[comboBox2.Text] == "char") { value = "\'" + comboBox4.Text + "\'"; } else if (TypeDictionary[comboBox2.Text] == "string") { value = "\"" + comboBox4.Text + "\""; } else { value = comboBox4.Text; } } else { if (Util.VariableConfirmation(this).Contains(comboBox2.Text) == false || Util.VariableConfirmation(this).Contains(comboBox4.Text) == false) { Form1.MessageBoxValue("条件で使われている変数は未割当です", true); } if (string.IsNullOrWhiteSpace(comboBox4.Text) == true) { Form1.MessageBoxValue("条件の変数が入力されていません", true); } else { CheckLetters.CheckVariablesAndVariables(comboBox2.Text, comboBox4.Text, TypeDictionary, true); } value = comboBox4.Text; } if (checkBox2.Checked) { CodeOutput = levelString + "if(" + comboBox2.Text + ConditionsType + value + ")\r\n" + childcontrol + levelString + "else\r\n" + childcontrol2; } else { CodeOutput = levelString + "if(" + comboBox2.Text + ConditionsType + value + ")\r\n" + childcontrol; } } } else if (comboBox1.SelectedIndex == 1) { if (comboBox2.SelectedIndex == -1) { Form1.MessageBoxValue("変数が入力されていません", true); } else { if (Util.VariableConfirmation(this).Contains(comboBox2.Text) == false) { Form1.MessageBoxValue("条件で使われている変数は未割当です", true); } CodeOutput = levelString + "switch(" + comboBox2.Text + ")\r\n" + childcontrol; } } return(CodeOutput); }
public override string CodeOutput(int level) { string levelString = new string('\t', level); string childcontrol = this.statementBlock1.CodeOutput(level, true); string Code = ""; string Quotation = ""; if (comboBox1.SelectedIndex != -1) { List <string> vlist = Util.GetVariableList(this, 0); if (UseLoopType == "while" || UseLoopType == "do-while") { if (ConditionsType != "") { if (comboBox2.SelectedIndex != -1) { if (checkBox2.Checked) { if (UseLoopType == "while") { if (vlist.Contains(comboBox4.Text) == false) { CheckLetters.CheckVariables(comboBox2.Text, comboBox4.Text, Util.GetVariableType(this), true); if (Util.GetVariableType(this)[comboBox2.Text] == "char") { Quotation = "\'"; } else if (Util.GetVariableType(this)[comboBox2.Text] == "string") { Quotation = "\""; } } else { Form1.MessageBoxValue("未宣言の変数が使われています", true); } Code = levelString + "while" + "(" + comboBox2.Text + " " + ConditionsType + Quotation + comboBox4.Text + Quotation + ")" + "\r\n" + childcontrol; } else { if (vlist.Contains(comboBox2.Text) == false) { if (Util.GetVariableType(this)[comboBox2.Text] == "char") { Quotation = "\'"; } else if (Util.GetVariableType(this)[comboBox2.Text] == "string") { Quotation = "\""; } CheckLetters.CheckVariables(comboBox2.Text, comboBox4.Text, Util.GetVariableType(this), true); } else { Form1.MessageBoxValue("未宣言の変数が使われています", true); } Code = levelString + "do\r\n" + childcontrol + levelString + "while(" + comboBox2.Text + " " + ConditionsType + " " + Quotation + comboBox4.Text + Quotation + ")\r\n"; } } else { if (Util.VariableConfirmation(this).Contains(comboBox2.Text) == false || Util.VariableConfirmation(this).Contains(comboBox4.Text) == false) { Form1.MessageBoxValue("ループで未割当の変数が使われています", true); } CheckLetters.CheckVariablesAndVariables(comboBox2.Text, comboBox4.Text, Util.GetVariableType(this), true); Code = levelString + UseLoopType + "(" + comboBox2.Text + " " + ConditionsType + " " + comboBox4.Text + ")" + "\r\n" + childcontrol; } } else { Form1.MessageBoxValue("条件の一部が入力されていません", true); } } else { Form1.MessageBoxValue("条件が選択されていません", true); } } else if (UseLoopType == "for") { if (checkBox1.Checked == false) { int value; if (int.TryParse(textBox1.Text, out value)) { int i = 1; Control MyGparent = this.Parent.Parent; while (MyGparent.GetType() == (typeof(Loop))) { i++; MyGparent = MyGparent.Parent.Parent; } string forNumber = new string ('i', i); Code = levelString + UseLoopType + "(int " + forNumber + "= 0;" + forNumber + " < " + textBox1.Text + ";" + forNumber + "++)\r\n" + childcontrol; } } else { Code = levelString + "for(;;)\r\n" + childcontrol; } } } else { Form1.MessageBoxValue("ループの種類が選択されていません", true); } return(Code); }
private void TextBox1_TextChanged(object sender, EventArgs e) { Conditions ThisParent = ((Conditions)this.Parent.Parent); CheckLetters.CheckVariables(ThisParent.comboBox2.Text, textBox1.Text, Util.GetVariableType(this), true); }