Example #1
0
        public void TestConcatNotEmpty()
        {
            var expected = new ConcatRegex <int>(new ConcatRegex <int>(1.ToRegex(), 2.ToRegex()), 3.ToRegex());
            var actual   = RegexUtils.Concat(1.ToRegex(), 2.ToRegex(), 3.ToRegex());

            Assert.AreEqual(expected, actual);
        }
Example #2
0
        private Regex ParseWithoutSum()
        {
            var alreadyParsedBackup = this.alreadyParsed;

            try
            {
                var result = this.ParseWithoutSumAndCatenation();
                try
                {
                    while (true)
                    {
                        var other = this.ParseWithoutSumAndCatenation();
                        if (other is EpsilonRegex <char> )
                        {
                            break;
                        }

                        result = new ConcatRegex <char>(result, other);
                    }
                }
                catch (RegexParserInternalException)
                {
                    // Concat do not require special character,
                    // so parser does not know if it should stop parsing or not.
                    // Therefore fail in this branch does not necessarily means global fail.
                }

                return(result);
            }
            catch (RegexParserInternalException)
            {
                this.alreadyParsed = alreadyParsedBackup;
                throw;
            }
        }
        public void Catenation()
        {
            const string input    = "abcd";
            var          expected = new ConcatRegex <char>(
                new ConcatRegex <char>(
                    new ConcatRegex <char>(
                        new AtomicRegex <char>('a'),
                        new AtomicRegex <char>('b')),
                    new AtomicRegex <char>('c')), new AtomicRegex <char>('d'));
            var actual = this.converter.Convert(input);

            Assert.AreEqual(expected, actual);
        }