Ejemplo n.º 1
0
        internal override GrammarBuilderBase Clone()
        {
            RuleElement ruleElement = new RuleElement(_name);

            ruleElement.CloneItems(this);
            return(ruleElement);
        }
Ejemplo n.º 2
0
        internal SemanticKeyElement(string semanticKey)
        {
            _semanticKey = semanticKey;
            RuleElement ruleElement = new RuleElement(semanticKey);

            _ruleRef = new RuleRefElement(ruleElement, _semanticKey);
            base.Items.Add(ruleElement);
            base.Items.Add(_ruleRef);
        }
Ejemplo n.º 3
0
        protected void Optimize(Collection <RuleElement> newRules)
        {
            SortedDictionary <int, Collection <BuilderElements> > sortedDictionary = new SortedDictionary <int, Collection <BuilderElements> >();

            GetDictionaryElements(sortedDictionary);
            int[] array = new int[sortedDictionary.Keys.Count];
            int   num   = array.Length - 1;

            foreach (int key in sortedDictionary.Keys)
            {
                array[num--] = key;
            }
            for (int i = 0; i < array.Length && array[i] >= 3; i++)
            {
                Collection <BuilderElements> collection = sortedDictionary[array[i]];
                for (int j = 0; j < collection.Count; j++)
                {
                    RuleElement    ruleElement    = null;
                    RuleRefElement ruleRefElement = null;
                    for (int k = j + 1; k < collection.Count; k++)
                    {
                        if (collection[j] == null || !collection[j].Equals(collection[k]))
                        {
                            continue;
                        }
                        BuilderElements builderElements = collection[k];
                        BuilderElements parent          = builderElements.Parent;
                        if (builderElements is SemanticKeyElement)
                        {
                            parent.Items[parent.Items.IndexOf(builderElements)] = collection[j];
                        }
                        else
                        {
                            if (ruleElement == null)
                            {
                                ruleElement = new RuleElement(builderElements, "_");
                                newRules.Add(ruleElement);
                            }
                            if (ruleRefElement == null)
                            {
                                ruleRefElement = new RuleRefElement(ruleElement);
                                collection[j].Parent.Items[collection[j].Parent.Items.IndexOf(collection[j])] = ruleRefElement;
                            }
                            parent.Items[builderElements.Parent.Items.IndexOf(builderElements)] = ruleRefElement;
                        }
                        builderElements.RemoveDictionaryElements(sortedDictionary);
                        collection[k] = null;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public override bool Equals(object obj)
        {
            RuleElement ruleElement = obj as RuleElement;

            if (ruleElement == null)
            {
                return(false);
            }
            if (!base.Equals(obj))
            {
                return(false);
            }
            return(_name == ruleElement._name);
        }
Ejemplo n.º 5
0
 internal RuleRefElement(RuleElement rule, string semanticKey)
 {
     _rule        = rule;
     _semanticKey = semanticKey;
 }
Ejemplo n.º 6
0
 internal RuleRefElement(RuleElement rule)
 {
     _rule = rule;
 }