_Core/Lang/Plugins/Parser/PrintPlugin.cs

(开头部分) 3KB

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

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


namespace ComLib.Lang.Extensions
{

    /* *************************************************************************
    <doc:example>	
    // Print plugin derives from the "TakeoverPlugin"
    // Takeovers are keywords that consume the entire line of text in the script
    // after the keyword. 
    // In this case of the Print plugin, it consume the rest of the line and you
    // don't need to wrap text around quotes.
    
    var language = 'fluentscript';
    print No need for quotes in #{language} if text to print is on one line    
    </doc:example>
    ***************************************************************************/

    /// <summary>
    /// Combinator for handling boolean values in differnt formats (yes, Yes, no, No, off Off, on On).
    /// </summary>
    public class PrintPlugin : LineReaderPlugin
    {
        /// <summary>
        /// Initialize
        /// </summary>
        public PrintPlugin()
        {
            _tokens = new string[] { "Print", "print" };
        }


        /// <summary>
        /// Can only handle print if no ( and " supplied.
        /// </summary>
        /// <param name="current"></param>
        /// <returns></returns>
        public override bool CanHandle(Token current)
        {
            var nextToken = _lexer.PeekToken();
            if (nextToken.Token == ComLib.Lang.Tokens.LeftParenthesis || nextToken.Token.Text == "\"")
                return false;
            return true;
        }
    }



    /// <summary>
    /// Prints the next token.
    /// </summary>
    public class PrintExpressionPlugin : ExprPlugin
    {
        /// <summary>
        /// Initialize.
后面还有 49 行代码,解锁后查看完整代码

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

AI 解读

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

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