Ejemplo n.º 1
0
        void ResultSaver_ProcessText(object sender, ProcessTextEventArgs e)
        {
            int n = mGenerator.ResultSaver.SavedCount + 1;

            BeginInvoke((ThreadStart) delegate
            {
                lblStatTest.Text = string.Format("Test {0} / {1}", n, mGenerator.Options.TestsAmount);
            });
            // Форматирование и построцессинг
            string s = e.Text;

            if (mGenerationOptionsForm.cbPPprocessingEnabled.Checked)
            {
                string   configDir = Program.WorkingDir + VALID_PROCESSING_PATH;
                string[] myArgs    = new string[4] {
                    "-c-10", "-l-C", "-p-" + configDir + "config.xml", "-s-ForTests"
                };
                ArgsParser     aParser = new ArgsParser(myArgs);
                ConfigParser   parser  = new ConfigParser(aParser.configTest, configDir + @"\members.xml");
                replaceHolding sFormat =
                    new replaceHolding(s, parser.inds, parser.arrayLength(), parser.IndexCount());
                s = sFormat.PrintText();
            }
            else
            {
                s = Formatter.Format(s);
            }
            e.Text = s;
            // Проверка компилятором
            if (mGenerationOptionsForm.cbMinGWEnabled.Checked)
            {
                MinGWProcessing checkMinGW = new MinGWProcessing();
                bool            testPassed = checkMinGW.MinGW(s);
                e.CancelSave = !testPassed;
                if (e.CancelSave)
                {
                    e.CancelReason = checkMinGW.WarningString;
                }
                else
                {
                    if (s.Length < 1024)
                    {
                        e.CancelSave   = true;
                        e.CancelReason = "Result is too short";
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void m_Cl(object sender, EventArgs e)
        {
            Grammar   gr        = Grammar.FromTextFile("c:/grams/gramset/gram800.txt");
            Generator generator = new Generator(gr);

            generator.Options.LevelRestriction = 60;
            generator.Options.AlternativeAlg   = AlternativeSelectAlg.NormalDistr;
            generator.Options.TestsAmount      = 1;
            generator.Options.AllEnumInOne     = false;
            string s = generator.GenerateAll();


            if (mGenerationOptionsForm.cbPPprocessingEnabled.Checked)
            {
                string   configDir = Program.WorkingDir + VALID_PROCESSING_PATH;
                string[] myArgs    = new string[4] {
                    "-c-10", "-l-C", "-p-" + configDir + "config.xml", "-s-ForTests"
                };
                ArgsParser     aParser = new ArgsParser(myArgs);
                ConfigParser   parser  = new ConfigParser(aParser.configTest, configDir + @"\members.xml");
                replaceHolding sFormat =
                    new replaceHolding(s, parser.inds, parser.arrayLength(), parser.IndexCount());
                s = sFormat.PrintText();
            }
            else
            {
                s = Formatter.Format(s);
            }
            // e.Text = s;
            // Проверка компилятором

            if (mGenerationOptionsForm.cbMinGWEnabled.Checked)
            {
                MinGWProcessing checkMinGW = new MinGWProcessing();
                bool            testPassed = checkMinGW.MinGW(s);
                //  e.CancelSave = !testPassed;
                if (!testPassed)
                {
                    //  e.CancelReason = checkMinGW.WarningString;
                }
                else
                {
                    File.WriteAllText("c:/gram_pv/sc1deps_grams", s);
                }
            }
        }
Ejemplo n.º 3
0
        private void generateBySetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //generator.
            DirectoryInfo dir            = new DirectoryInfo("c:/gram_pv/pv_deps_grams");
            string        pathToGrammar  = "";
            string        fileToSaveTest = "";
            bool          testPassed     = false;
            bool          TestGenerated  = false;

            foreach (FileInfo f in dir.GetFiles())
            {
                pathToGrammar  = f.FullName;
                fileToSaveTest = f.Name.Substring(4, f.Name.Length - 8);
                if (File.Exists("c:/gram_pv/pv_deps_tests/SF1D-test_" + fileToSaveTest + ".c"))
                {
                    continue;
                }
                Grammar   gr        = Grammar.FromTextFile(pathToGrammar);
                Generator generator = new Generator(gr);
                generator.Options.LevelRestriction = 1000;
                generator.Options.AlternativeAlg   = AlternativeSelectAlg.RndDistr;
                generator.Options.RREnable         = true;
                generator.Options.TestsAmount      = 1;
                generator.Options.AllEnumInOne     = false;
                generator.ConfigFilePath           = mTaskDoc.CurrentFilePath;
                TestGenerated = false;
                while (!TestGenerated)
                {
                    string s = generator.GenerateAll();


                    if (mGenerationOptionsForm.cbPPprocessingEnabled.Checked)
                    {
                        string   configDir = Program.WorkingDir + VALID_PROCESSING_PATH;
                        string[] myArgs    = new string[4] {
                            "-c-10", "-l-C", "-p-" + configDir + "config.xml", "-s-ForTests"
                        };
                        ArgsParser     aParser = new ArgsParser(myArgs);
                        ConfigParser   parser  = new ConfigParser(aParser.configTest, configDir + @"\members.xml");
                        replaceHolding sFormat =
                            new replaceHolding(s, parser.inds, parser.arrayLength(), parser.IndexCount());
                        s = sFormat.PrintText();
                    }
                    else
                    {
                        s = Formatter.Format(s);
                    }
                    // e.Text = s;
                    // Проверка компилятором
                    MinGWProcessing checkMinGW = new MinGWProcessing();
                    testPassed = checkMinGW.MinGW(s);

                    if (testPassed)
                    {
                        File.WriteAllText("c:/gram_pv/pv_deps_tests/SF1D-test_" + fileToSaveTest + ".c", s);
                        TestGenerated = true;
                    }
                    else
                    {
                        TestGenerated = false;
                    }
                }
            }
        }