⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 token.cs

📁 csharp-solution,C#高效编程源码
💻 CS
字号:

namespace CSharp
{
    /// <summary>
    /// Token provides a common abstract base class for 
    /// the concrete token implementation classes. It is 
    /// intended to be used in conjunction with a specific 
    /// token interface. For example, to implement string 
    /// literal tokens you would do this:
    /// <code>
    /// interface IStringLiteralToken : IToken {}
    /// class StringLiteralToken : Token, IStringLiteralToken
    /// { 
    /// ...
    /// }
    /// </code>
    /// </summary>
    
    internal abstract class Token : IToken
    {
        /// <param name="begin">begin</param>
        /// <param name="end">end</param>
        /// <remarks>
        /// It would be useful to check if
        /// (<paramref name="begin">begin</paramref> ==
        /// <paramref name="end">end</paramref>)
        /// and throw an exception if so.
        /// </remarks>

        protected Token(Position begin, Position end)
        {
            this.begin = begin;
            this.end = end;
        }
    
        public override string ToString()
        {
            return Position.MakeString(begin, end);
        }

        /// <remarks>
        /// Note that Accept is added to the internal
        /// implementation hierarchy and not to the 
        /// public interface hierarchy. That is, Accept
        /// is method of Token but not of IToken.
        /// </remarks>
        
        internal abstract void Accept(ITokenVisitor visitor);
                
        private readonly Position begin, end;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -