Exemplo n.º 1
0
 /// <summary>
 /// 获取给定推导式对应的函数名称
 /// <para>DerivationVn___VList</para>
 /// </summary>
 /// <param name="derivation">推导式</param>
 /// <returns></returns>
 public string GetMethodDerivationName(Derivation derivation)
 {
     //return string.Format("Derivation{0}___{1}",
     //    ConvertToIdentifier(derivation.Left), ConvertToIdentifier(derivation.Right.ToString()));
     return string.Format("Derivation{0}___{1}",
         GetEnumVTypeSGItem(derivation.Left), GetEnumVTypeSGItem(derivation.Right));
 }
Exemplo n.º 2
0
        /// <summary>
        /// 获取此推导式的复制品
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            var result = new 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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// From
        /// </summary>
        /// <param name="xDerivation"></param>
        /// <returns></returns>
        public static Derivation From(XElement xDerivation)
        {
            if (xDerivation == null)
            {
                return(null);
            }
            if (xDerivation.Name != strDerivation)
            {
                return(null);
            }
            var result = new Derivation();

            result.Left  = ProductionNode.From(xDerivation.Element(strLeft));
            result.Right = ProductionNodeList.From(xDerivation.Element(strRight));
            return(result);
        }
Exemplo n.º 4
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);
            }
        }