_Core/Lang/Plugins/Parser/DateNumberPlugin.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ComLib.Lang;
namespace ComLib.Lang.Extensions
{
/* *************************************************************************
<doc:example>
// Date number plugin allow you to specify dates in the form of numbers as
// samples below.
// The separator between months/days/years can be "/", "-", "\"
var date1 = 1/27/1978;
var date2 = 4-20-1979 at 4:30pm;
var date3 = 6\10\2012 at 7:45am;
</doc:example>
***************************************************************************/
/// <summary>
/// Combinator for handling date numbers such as 1/27/1978
/// </summary>
public class DateNumberPlugin : LexPlugin
{
private static Dictionary<string, string> _keywords = new Dictionary<string, string>();
private int _endPos = -1;
/// <summary>
/// Initialize
/// </summary>
public DateNumberPlugin()
{
_tokens = new string[] { "$NumberToken" };
_canHandleToken = true;
}
/// <summary>
/// Whether or not this uri plugin can handle the current token.
/// </summary>
/// <param name="current"></param>
/// <returns></returns>
public override bool CanHandle(Token current)
{
_endPos = -1;
string next = "";
int pos = _lexer.State.Pos + 1;
// Check position.
if (pos > _lexer.LAST_POSITION)
return false;
char n = _lexer.State.Text[pos];
// Check that the next char is date part separator as in 3/10/2012 or 3-10-2012
后面还有 83 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
