Example #1
0
        public LookAheadSet CreateFilter(LookAheadSet set)
        {
            LookAheadSet result = new LookAheadSet(_maxLength);

            // Handle special cases
            if (this.Size() <= 0 || set.Size() <= 0)
            {
                return(this);
            }

            // Create combinations
            for (int i = 0; i < _elements.Count; i++)
            {
                var first = (Sequence)_elements[i];
                for (int j = 0; j < set._elements.Count; j++)
                {
                    var second = (Sequence)set._elements[j];
                    if (first.StartsWith(second))
                    {
                        result.Add(first.Subsequence(second.Length()));
                    }
                }
            }

            return(result);
        }
Example #2
0
        public LookAheadSet CreateCombination(LookAheadSet set)
        {
            LookAheadSet result = new LookAheadSet(_maxLength);

            // Handle special cases
            if (this.Size() <= 0)
            {
                return(set);
            }
            else if (set.Size() <= 0)
            {
                return(this);
            }

            // Create combinations
            for (int i = 0; i < _elements.Count; i++)
            {
                var first = (Sequence)_elements[i];
                if (first.Length() >= _maxLength)
                {
                    result.Add(first);
                }
                else if (first.Length() <= 0)
                {
                    result.AddAll(set);
                }
                else
                {
                    for (int j = 0; j < set._elements.Count; j++)
                    {
                        var second = (Sequence)set._elements[j];
                        result.Add(first.Concat(_maxLength, second));
                    }
                }
            }

            return(result);
        }