Пример #1
0
        public int CompareTo(PRule <T> other)
        {
            var fromCmp   = FromSymbol.CompareTo(other.FromSymbol);
            var symbolCmp = Letter.CompareTo(other.Letter);
            var toCmp     = 1;

            if (ToSymbol != null)
            {
                toCmp = ToSymbol.CompareTo(other.ToSymbol);
            }

            return(fromCmp != 0 ? fromCmp : (symbolCmp != 0 ? symbolCmp : toCmp));
        }
Пример #2
0
        public void AddProductionRule(PRule <T> rule)
        {
            this.ProductionRules.Add(rule);

            if (rule.FromSymbol != null)
            {
                this.Symbols.Add(rule.FromSymbol);
            }

            if (rule.ToSymbol != null)
            {
                this.Symbols.Add(rule.ToSymbol);
            }
        }