_Core/Lang/Plugins/Parser/UnitsPlugin.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ComLib.Lang;
namespace ComLib.Lang.Extensions
{
/* *************************************************************************
<doc:example>
// Units plugin allows the usage of units of measure such as length, weight
enable units;
// inches, bytes are base types. everything is relative to the base types
// In examples below, the units will get converted to the measurement on the
// left hand side. e.g. 3 feet + 5 inches will get converted to datatype
// LUnit with value in feet and basevalue in inches.
var result1 = 3 feet + 5 inches + 10 yards + 2 miles
var result2 = 1 meg + 30 kb + 50 B + 2 gigs
// Each unit of measure is based on a basevalue with a relative value.
// e.g.
// type basevalue relative values
// length inches feet, yard, mile
// weight ounces milligrams, grams, kilograms
// computerspace bytes kilobytes, megabytes, gigabytes
print feet: #{result1.Value} , inches: #{result1.BaseValue}
print megs: #{result2.Value} , bytes: #{result2.BaseValue}
</doc:example>
***************************************************************************/
/// <summary>
/// Plugin to allow using units such as length, weight, etc.
/// </summary>
public class UnitsPlugin : ExprPlugin
{
private static string[] _tokens = new string[] { "$Suffix" };
/// <summary>
/// Initialize
/// </summary>
public UnitsPlugin()
{
_startTokens = _tokens;
_hasStatementSupport = true;
}
/// <summary>
/// The grammer for the function declaration
/// </summary>
public override string Grammer
{
get
后面还有 59 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
