Example #1
0
 void DismissedEventHandler(SplashScreen sender, object e)
 {
     //вызываем метод, в котором парсим данные
     ParserClass.TestParser();
     //по окончанию вызываем метод открытия формы конвертера валют
     DismissExtendedSplash();
 }
Example #2
0
        static void Main(string[] args)
        {
            ParserClass foo = new ParserClass();

            foo.Parse("parse this file");

            Console.ReadLine();
        }
Example #3
0
        public void VorzeichenNachDemRechenzeichen()
        {
            string TestString = "5+-2";
            double expected   = 3;

            double actual = ParserClass.Start(TestString);

            Assert.AreEqual(expected, actual, 0.001);
        }
Example #4
0
        public void MinusamAnfang()
        {
            string TestString = "-2+5";
            double expected   = 3;

            double actual = ParserClass.Start(TestString);

            Assert.AreEqual(expected, actual, 0.001);
        }
Example #5
0
        public void verschiedeneKlammerpaare()
        {
            string TestString = "(3+4)-(2-3)";
            double expected   = 8;

            double actual = ParserClass.Start(TestString);

            Assert.AreEqual(expected, actual, 0.001);
        }
Example #6
0
        public void MultipleSubtraction()
        {
            string TestString = "5-5-5-5";
            double expected   = -10;

            double actual = ParserClass.Start(TestString);

            Assert.AreEqual(expected, actual, 0.001);
        }
        public void ShouldParsePunctuation()
        {
            string      text   = "test, test: test! test? test.";
            ParserClass parser = new ParserClass();
            Dictionary <string, int> wordsAmount = parser.ParseTest(text);

            wordsAmount.Should().NotBeNull();
            wordsAmount.Should().NotBeEmpty();
            wordsAmount.Should().HaveCount(1);
            wordsAmount.Should().Contain("test", 5);
        }
        public void ShouldParseSpaces()
        {
            string      text   = " test test    test    ";
            ParserClass parser = new ParserClass();
            Dictionary <string, int> wordsAmount = parser.ParseTest(text);

            wordsAmount.Should().NotBeNull();
            wordsAmount.Should().NotBeEmpty();
            wordsAmount.Should().HaveCount(1);
            wordsAmount.Should().Contain("test", 3);
        }
        public void ShouldParseLessThanThreeChars()
        {
            string      text   = "t te tes test tes te t";
            ParserClass parser = new ParserClass();
            Dictionary <string, int> wordsAmount = parser.ParseTest(text);

            wordsAmount.Should().NotBeNull();
            wordsAmount.Should().NotBeEmpty();
            wordsAmount.Should().HaveCount(2);
            wordsAmount.Should().Contain("tes", 2);
            wordsAmount.Should().Contain("test", 1);
        }
        public void ShouldIgnoreCase()
        {
            string text = "cat cAt CAT";

            ParserClass parser = new ParserClass();
            Dictionary <string, int> wordsAmount = parser.ParseTest(text);

            wordsAmount.Should().NotBeNull();
            wordsAmount.Should().NotBeEmpty();
            wordsAmount.Should().HaveCount(1);
            wordsAmount.Should().Contain("cat", 3);
            wordsAmount.Should().Contain("CAT", 3);
        }
        public void ShouldParseDashes()
        {
            string      text   = $"te\u2011st te\u2010st te-st -test -cat-cat-cat- are--results -- - test-";
            ParserClass parser = new ParserClass();
            Dictionary <string, int> wordsAmount = parser.ParseTest(text);

            wordsAmount.Should().NotBeNull();
            wordsAmount.Should().NotBeEmpty();
            wordsAmount.Should().HaveCount(5);
            wordsAmount.Should().Contain("test", 2);
            wordsAmount.Should().Contain("te-st", 3);
            wordsAmount.Should().Contain("cat-cat-cat", 1);
            wordsAmount.Should().Contain("are", 1);
            wordsAmount.Should().Contain("results", 1);
        }
Example #12
0
        /// <summary>
        /// Execute the parsing process, with the drawing process.
        /// </summary>
        /// <param name="panel">Where to put the parsed content.</param>
        public void Parse(PanelActive panel)
        {
            var FileName    = Path.GetFileName(panel.Label2.Text);
            var ParsingMode = GetParsingMode(FileName, panel.Label2.Text);

            if (ParsingMode == 1)
            {
                ParserClass = new ParserMode1();
            }
            else if (ParsingMode == 2)
            {
                ParserClass = new ParserMode2();
            }
            else if (ParsingMode == 3)
            {
                ParserClass = new ParserMode3();
            }
            else if (ParsingMode == 4)
            {
                ParserClass = new ParserMode4();
            }
            else
            {
                MessageBox.Show("Cross Log cannot read this file.\n\nTo get help, click the \"?\" button on the top menu.", "Invalid parsing mode");
                return;
            }

            var taskResult = new List <Log>();

            taskResult = ParserClass.Parse(panel.Label2.Text);

            var tmp = ParserClass.GetDateFromFileName(panel.Label2.Text);

            if (tmp.Year != 1)
            {
                panel.Label4.Text = tmp.Day + " - " + tmp.Month + " - " + tmp.Year;
            }
            else
            {
                panel.Label4.Text = "Cannot load date";
            }

            logList.Add(new LogList(panel, taskResult));

            return;
        }
Example #13
0
        private IList <IToken> LoadFile(string name)
        {
            string source = string.Empty;

            string path = Directory.GetCurrentDirectory() + "\\Scripts\\TokenParser\\" + name;

            path = path.Replace('\\', Path.DirectorySeparatorChar);
            if (File.Exists(path))
            {
                source = File.ReadAllText(path);

                ParserClass parser = new ParserClass(path, source);

                return(parser.GetAllTokens());
            }
            else
            {
                throw new Exception($"Файл {path} не найден.");
            }
        }
Example #14
0
        private IList <IToken> LoadFile(string name, IDictionary <string, bool> defines)
        {
            string source = string.Empty;

            string path = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + "Preprocessor" + Path.DirectorySeparatorChar + name;

            if (File.Exists(path))
            {
                source = File.ReadAllText(path);

                ParserClass      parser      = new ParserClass(path, source);
                PrecompilerClass precompiler = new PrecompilerClass(parser.GetEnumerator(), defines);

                return(precompiler.GetAllTokens());
            }
            else
            {
                throw new Exception($"Файл {path} не найден.");
            }
        }
        public void ShouldParseNewLines()
        {
            string[]      items   = { "Cat", "Dog", "Cat" };
            StringBuilder builder = new StringBuilder(
                "Required:").AppendLine();

            foreach (string item in items)
            {
                builder.Append(item).AppendLine();
            }
            string text = builder.ToString();

            ParserClass parser = new ParserClass();
            Dictionary <string, int> wordsAmount = parser.ParseTest(text);

            wordsAmount.Should().NotBeNull();
            wordsAmount.Should().NotBeEmpty();
            wordsAmount.Should().HaveCount(3);
            wordsAmount.Should().Contain("Required", 1);
            wordsAmount.Should().Contain("Cat", 2);
            wordsAmount.Should().Contain("Dog", 1);
        }
 public void Add(ParserClass item)
 {
     collection.Add(item);
 }