Ejemplo n.º 1
0
        /// <summary>
        /// Eliminate unit rules (e.g., &lt;X> -> &lt;Y>)
        /// </summary>
        /// <param name="productions"></param>
        private void StepUnit(ISet <Production> productions)
        {
            // TODO: maybe we shouldn't allow self loops?
            RemoveSelfLoops(productions);

            var toRemove = BaseGrammar.RemoveDuplicatesHelper(productions);

            foreach (var production in toRemove)
            {
                productions.Remove(production);
            }

            var finalProductions = RemoveUnits(productions);

            productions.Clear();
            productions.UnionWith(finalProductions);
        }
Ejemplo n.º 2
0
        protected void RemoveDuplicates()
        {
            var toRemove = BaseGrammar.RemoveDuplicatesHelper(this.Productions);

            this.RemoveProductionsWithoutSimplifying(toRemove);
        }