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);
        }
        public override string CodeOutput(int level)
        {
            string levelString = new string('\t', level);
            string Code        = "";

            if (comboBox1.SelectedIndex != -1)
            {
                if (string.IsNullOrEmpty(textBox1.Text) == false)
                {
                    CheckLetters.CheckName(textBox1.Text, true);
                    List <String> vList = Util.GetVariableList(this, 0);
                    if (vList.Contains(textBox1.Text) == true)
                    {
                        Form1.MessageBoxValue("同じ名前が存在します", false);
                    }
                    else
                    {
                        Code = levelString + "List<" + itemType + ">" + textBox1.Text + " = new List<" + itemType + ">();";
                    }
                }
                else
                {
                    Form1.MessageBoxValue("リストの名前が設定されていません", true);
                }
            }
            else
            {
                Form1.MessageBoxValue("リストの型が設定されていません", true);
            }
            return(Code);
        }
Example #3
0
 private void ComboBox4_TextChanged(object sender, EventArgs e)
 {
     if (checkBox2.Checked)
     {
         CheckLetters.CheckNumbers(comboBox4.Text, false);
     }
 }
Example #4
0
 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);
     }
 }
        private void TextBox1_TextChanged(object sender, EventArgs e)
        {
            CheckLetters.CheckName(textBox1.Text, false);
            List <String> vList = Util.GetVariableList(this, 0);

            if (vList.Contains(textBox1.Text) == true)
            {
                Form1.MessageBoxValue("同じ名前が存在します", false);
            }
        }
        public override string CodeOutput(int level)
        {
            string levelString = new string('\t', level);
            string CodeOutput  = "";

            if (VariableDefine.NameList.Contains(textBox1.Text))
            {
                Form1.MessageBoxValue("同じ名前の変数が既にあります", true);
            }
            else
            {
                VariableDefine.NameList.Add(textBox1.Text);
            }
            if (itemType == "")
            {
                Form1.MessageBoxValue("配列の型が選択されていません", true);
            }
            else
            {
                if (string.IsNullOrWhiteSpace(textBox1.Text))
                {
                    Form1.MessageBoxValue("配列の宣言で配列の名前が入力されていません", true);
                }
                else
                {
                    CheckLetters.CheckName(textBox1.Text, true);


                    if (string.IsNullOrWhiteSpace(textBox2.Text))
                    {
                        Form1.MessageBoxValue("配列の宣言で配列の数の値が入力されていません", true);
                    }
                    else
                    {
                        int OkNumber;
                        if (int.TryParse(textBox2.Text, out OkNumber))
                        {
                            if (OkNumber < 0)
                            {
                                Form1.MessageBoxValue("配列の宣言の配列の数で不正な数値が入力されています", true);
                            }
                            else
                            {
                                CodeOutput = levelString + itemType + "[] " + textBox1.Text + " = new " + itemType + "[" + OkNumber + "];\r\n";
                            }
                        }
                        else
                        {
                            Form1.MessageBoxValue("配列の宣言の配列の数で数値以外が入力されています", true);
                        }
                    }
                }
            }
            return(CodeOutput);
        }
        private void TextBox2_TextChanged(object sender, EventArgs e)
        {
            CheckLetters.CheckNumbers(textBox2.Text, false);
            List <String> vList = Util.GetVariableList(this, 0);

            if (vList.Contains(textBox2.Text) == true)
            {
                Form1.MessageBoxValue("同じ名前が存在します", false);
            }
            ((StatementBlock)this.Parent).CheckName("nothingnothing", "nothingnothing", false);
        }
Example #8
0
        private void ComboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            Dictionary <string, string> TypeDictionary = Util.GetVariableType(this);

            if (string.IsNullOrWhiteSpace(comboBox4.Text) == false)
            {
                if (string.IsNullOrWhiteSpace(comboBox2.Text) == false)
                {
                    List <string> vList = Util.GetVariableList(this, 0);
                    if (vList.Contains(comboBox2.Text) == false || vList.Contains(comboBox4.Text) == false)
                    {
                    }
                    else
                    {
                        CheckLetters.CheckVariablesAndVariables(comboBox2.Text, comboBox4.Text, TypeDictionary, false);
                    }
                }
            }
        }
        private void TextBox1_TextChanged(object sender, EventArgs e)
        {
            CheckLetters.CheckName(textBox1.Text, false);
            List <String> vList = Util.GetVariableList(this, 0);

            if (vList.Contains(textBox1.Text) == true)
            {
                Form1.MessageBoxValue("同じ名前が存在します", false);
            }
            else
            {
                if (string.IsNullOrEmpty(textBox1.Text) == false)
                {
                    ((StatementBlock)this.Parent).CheckName(textBox1.Text, Name, true);
                }
                else
                {
                    ((StatementBlock)this.Parent).CheckName(textBox1.Text, Name, false);
                }
                Name = textBox1.Text;
            }
        }
Example #10
0
 private void TextBox1_KeyDown(object sender, KeyEventArgs e)
 {
     CheckLetters.CheckNumbers(textBox1.Text, false);
 }
Example #11
0
        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);
        }
Example #12
0
 private void TextBox1_TextChanged(object sender, EventArgs e)
 {
     CheckLetters.CheckNumbers(textBox1.Text, false);
 }
Example #13
0
        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);
        }
 private void TextBox2_TextChanged(object sender, EventArgs e)
 {
     CheckLetters.CheckValue(itemType, textBox2.Text, false);
     //((StatementBlock)this.Parent).CheckName(textBox1.Text, Name, false);
 }
        public override string CodeOutput(int level)
        {
            string Quotation = "";


            String levelString = new string('\t', level);

            CheckLetters.CheckName(textBox1.Text, true);
            if (NameList.Contains(textBox1.Text))
            {
                Form1.MessageBoxValue("同じ名前の変数が既にあります", true);
            }
            else
            {
                NameList.Add(textBox1.Text);
                if (string.IsNullOrWhiteSpace(textBox1.Text))
                {
                    Form1.MessageBoxValue("変数の名前が入力されていません", true);
                }
            }
            switch (comboBox1.SelectedIndex)
            {
            case -1:
                Form1.MessageBoxValue("変数の型が選択されていません", true);
                break;

            case 0:
                itemType = "int";
                break;

            case 1:
                itemType = "string";
                break;

            case 2:
                itemType = "char";
                break;

            case 3:
                itemType = "double";
                break;

            case 4:
                itemType = "byte";
                break;

            case 5:
                itemType = "bool";
                break;
            }
            if (checkBox1.Checked == true)
            {
                if (String.IsNullOrWhiteSpace(textBox2.Text) == false)
                {
                    if (itemType == "char")
                    {
                        char a;
                        if (char.TryParse(textBox2.Text, out a))
                        {
                            Quotation = "\'";
                        }
                        else
                        {
                            Form1.MessageBoxValue("型にあっていません", true);
                        }
                        if (string.IsNullOrWhiteSpace(textBox1.Text))
                        {
                            Form1.MessageBoxValue("入力されていないところがあります", true);
                        }
                    }
                    else if (itemType == "string")
                    {
                        Quotation = "\"";
                    }
                    CheckLetters.CheckValue(itemType, textBox2.Text, true);
                    return(levelString + itemType + " " + this.textBox1.Text + " = " + Quotation + textBox2.Text + Quotation + ";\r\n");
                }
                else
                {
                    if (itemType != "string")
                    {
                        Form1.MessageBoxValue("変数に代入する値が入力されていません", true);
                    }
                    else
                    {
                        return(levelString + itemType + " " + this.textBox1.Text + " = " + "\"\"" + ";\r\n");
                    }
                }
            }


            return(levelString + itemType + " " + this.textBox1.Text + ";\r\n");
        }