Example #1
0
        /// <summary>
        /// Gets the collection of non-epsilon transitions from this node grouped by non-overlapping ranges.
        /// </summary>
        public IEnumerable <KeyValuePair <RegExInputRange, ICollection <NfaState> > > GetGroupedTransition()
        {
            var splitPoints = new SortedSet <char>();

            foreach (var map in NfaMap)
            {
                if (map.Key == RegExInputRange.EPS)
                {
                    continue;
                }
                if (map.Key.Min > 0)
                {
                    splitPoints.Add((char)map.Key.Min);
                }
                if (map.Key.Max != char.MaxValue)
                {
                    splitPoints.Add((char)(map.Key.Max + 1));
                }
            }
            var groupedMap = new SortedMultiMap <RegExInputRange, NfaState>();

            foreach (var map in NfaMap)
            {
                if (map.Key == RegExInputRange.EPS)
                {
                    continue;
                }
                foreach (var split in SplitRange(map.Key, splitPoints))
                {
                    foreach (var state in map.Value.EpsilonStates)
                    {
                        groupedMap.Add(split, state);
                    }
                }
            }
            return(groupedMap.GroupedPairs);
        }