Ejemplo n.º 1
0
        /// <summary>
        /// 获取此推导式的复制品
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            var result = new DerivationList();

            foreach (var item in this)
            {
                var derivation = item.Clone() as Derivation;
                result.Add(derivation);
            }
            //if (this.Left != null)
            //    result.Left = this.Left.Clone() as ProductionNode;
            //if (this.Right != null)
            //    result.Right = this.Right.Clone() as ProductionNodeList;
            return(result);
        }
Ejemplo n.º 2
0
        ///// <summary>
        ///// 设置给定行、列位置的推导式
        ///// </summary>
        ///// <param name="line"></param>
        ///// <param name="column"></param>
        ///// <param name="derivation"></param>
        //public void SetCell(int line, int column, Derivation derivation)
        //{
        //    if (0 <= line && line < this.m_LineCount
        //        && 0 <= column && column < this.m_ColumnCount)
        //    {
        //        //this.m_ParserMap[line, column].Add(derivation);
        //        string key = string.Format("{0}-{1}",)
        //    }
        //}
        /// <summary>
        /// 设置给定语法类型、单词类型所对应的推导式
        /// </summary>
        /// <param name="leftNode"></param>
        /// <param name="nextLeave"></param>
        /// <param name="function"></param>
        public void SetCell(ProductionNode leftNode, ProductionNode nextLeave, Derivation function)
        {
            //SetCell(this.m_LeftNodes[leftNode], this.m_NextLeaves[nextLeave], function);
            string         key  = string.Format("Left:{0} Terminal:{1}", leftNode, nextLeave);
            DerivationList list = null;

            if (this.m_ParserMap.TryGetValue(key, out list))
            {
                list.Add(function);
            }
            else
            {
                list = new DerivationList();
                list.Add(function);
                this.m_ParserMap.Add(key, list);
            }
        }