_Core/Lang/Parser/Lexer.cs

(开头部分) 31KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ComLib.Lang
{
    /// <summary>
    /// Converts script from a series of characters into a series of tokens.
    /// Main method is NextToken();
    /// A script can be broken down into a sequence of tokens.
    /// e.g.
    /// 
    /// 1. var name = "kishore";
    /// Tokens:
    /// 
    ///  TOKEN VALUE:         TOKEN TYPE:
    ///  var         keyword
    ///  ""          literal ( whitespace )
    ///  name        id
    ///  ""          literal ( whitespace )
    ///  =           operator
    ///  ""          literal ( whitespace )
    ///  "kishore"   literal
    ///  ;           operator
    /// </summary>
    public class Lexer : LexerBase
    {
        enum TokenLengthCalcMode
        {
            /// <summary>
            /// Use the size the token text
            /// </summary>
            Direct,


            /// <summary>
            /// Use the length of whitespace
            /// </summary>
            WhiteSpace,


            /// <summary>
            /// Use the length of the token plus 2 chars for string literal
            /// </summary>
            String,


            /// <summary>
            /// MUltiline comment.
            /// </summary>
            MultilineComment
        }


        #region Private members
        private Context _ctx;      
        private Token _lastToken;
        private TokenData _lastTokenData;
后面还有 858 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。