修复一些错误并更新README
This commit is contained in:
@@ -8,7 +8,9 @@ using System;
|
||||
|
||||
namespace Flee.ExpressionElements.Base
|
||||
{
|
||||
[Obsolete("Base class for expression elements that operate on two child elements")]
|
||||
/// <summary>
|
||||
/// 操作两个子元素的表达式元素的基类
|
||||
/// </summary>
|
||||
internal abstract class BinaryExpressionElement : ExpressionElement
|
||||
{
|
||||
|
||||
|
@@ -6,7 +6,9 @@ using Flee.InternalTypes;
|
||||
|
||||
namespace Flee.ExpressionElements.MemberElements
|
||||
{
|
||||
[Obsolete("Encapsulates an argument list")]
|
||||
/// <summary>
|
||||
/// 封装参数列表的类
|
||||
/// </summary>
|
||||
internal class ArgumentList
|
||||
{
|
||||
private readonly IList<ExpressionElement> _myElements;
|
||||
|
@@ -10,7 +10,9 @@ using Flee.PublicTypes;
|
||||
|
||||
namespace Flee.ExpressionElements.MemberElements
|
||||
{
|
||||
[Obsolete("Represents a function call")]
|
||||
/// <summary>
|
||||
/// 表示函数调用的表达式元素
|
||||
/// </summary>
|
||||
internal class FunctionCallElement : MemberElement
|
||||
{
|
||||
private readonly ArgumentList _myArguments;
|
||||
|
@@ -15,7 +15,9 @@ using System;
|
||||
|
||||
namespace Flee.ExpressionElements.MemberElements
|
||||
{
|
||||
[Obsolete("Represents an identifier")]
|
||||
/// <summary>
|
||||
/// 表示标识符的表达式元素
|
||||
/// </summary>
|
||||
internal class IdentifierElement : MemberElement
|
||||
{
|
||||
private FieldInfo _myField;
|
||||
|
@@ -9,7 +9,9 @@ using Flee.PublicTypes;
|
||||
|
||||
namespace Flee.ExpressionElements.MemberElements
|
||||
{
|
||||
[Obsolete("Element representing an array index")]
|
||||
/// <summary>
|
||||
/// 表示数组索引的表达式元素
|
||||
/// </summary>
|
||||
internal class IndexerElement : MemberElement
|
||||
{
|
||||
private ExpressionElement _myIndexerElement;
|
||||
|
@@ -4,7 +4,9 @@ using System.Reflection.Emit;
|
||||
|
||||
namespace Flee.InternalTypes
|
||||
{
|
||||
[Obsolete("Manages branch information and allows us to determine if we should emit a short or long branch")]
|
||||
/// <summary>
|
||||
/// 管理分支信息,允许我们确定是否应该发出短分支或长分支
|
||||
/// </summary>
|
||||
internal class BranchManager
|
||||
{
|
||||
private readonly IList<BranchInfo> MyBranchInfos;
|
||||
@@ -143,7 +145,9 @@ namespace Flee.InternalTypes
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Represents a location in an IL stream")]
|
||||
/// <summary>
|
||||
/// 表示IL流中的位置
|
||||
/// </summary>
|
||||
internal class ILLocation : IEquatable<ILLocation>, IComparable<ILLocation>
|
||||
{
|
||||
private int _myPosition;
|
||||
@@ -214,7 +218,9 @@ namespace Flee.InternalTypes
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Represents a branch from a start location to an end location")]
|
||||
/// <summary>
|
||||
/// 表示从起始位置到结束位置的分支
|
||||
/// </summary>
|
||||
internal class BranchInfo
|
||||
{
|
||||
private readonly ILLocation _myStart;
|
||||
|
@@ -160,7 +160,9 @@ namespace Flee.InternalTypes
|
||||
public static object Instance => OurInstance;
|
||||
}
|
||||
|
||||
[Obsolete("Helper class to resolve overloads")]
|
||||
/// <summary>
|
||||
/// 用于解析重载的辅助类
|
||||
/// </summary>
|
||||
internal class CustomMethodInfo : IComparable<CustomMethodInfo>, IEquatable<CustomMethodInfo>
|
||||
{
|
||||
/// <summary>
|
||||
@@ -494,7 +496,9 @@ namespace Flee.InternalTypes
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Wraps an expression element so that it is loaded from a local slot")]
|
||||
/// <summary>
|
||||
/// 包装表达式元素,使其从本地槽位加载
|
||||
/// </summary>
|
||||
internal class LocalBasedElement : ExpressionElement
|
||||
{
|
||||
private readonly int _myIndex;
|
||||
@@ -514,7 +518,9 @@ namespace Flee.InternalTypes
|
||||
public override System.Type ResultType => _myTarget.ResultType;
|
||||
}
|
||||
|
||||
[Obsolete("Helper class for storing strongly-typed properties")]
|
||||
/// <summary>
|
||||
/// 用于存储强类型属性的辅助类
|
||||
/// </summary>
|
||||
internal class PropertyDictionary
|
||||
{
|
||||
private readonly Dictionary<string, object> _myProperties;
|
||||
|
@@ -6,7 +6,9 @@ using System.Reflection.Emit;
|
||||
|
||||
namespace Flee.InternalTypes
|
||||
{
|
||||
[Obsolete("Holds various shared utility methods")]
|
||||
/// <summary>
|
||||
/// 包含各种共享实用方法的工具类
|
||||
/// </summary>
|
||||
internal class Utility
|
||||
{
|
||||
private Utility()
|
||||
|
@@ -3,7 +3,9 @@ using System.Collections;
|
||||
|
||||
namespace Flee.Parsing
|
||||
{
|
||||
[Obsolete("Creates a new parse tree analyzer.")]
|
||||
/// <summary>
|
||||
/// 创建新的解析树分析器
|
||||
/// </summary>
|
||||
internal class Analyzer
|
||||
{
|
||||
public Analyzer()
|
||||
|
@@ -5,8 +5,9 @@ using System.Text;
|
||||
|
||||
namespace Flee.Parsing
|
||||
{
|
||||
|
||||
[Obsolete(" A base parser class. This class provides the standard parser interface, as well as token handling.")]
|
||||
/// <summary>
|
||||
/// 基础解析器类。此类提供标准解析器接口以及令牌处理功能
|
||||
/// </summary>
|
||||
internal abstract class Parser
|
||||
{
|
||||
private bool _initialized;
|
||||
|
@@ -8,6 +8,9 @@ using Flee.Parsing;
|
||||
|
||||
namespace Flee.PublicTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// 表达式上下文类,提供表达式编译和执行的环境
|
||||
/// </summary>
|
||||
public sealed class ExpressionContext
|
||||
{
|
||||
|
||||
@@ -186,11 +189,22 @@ namespace Flee.PublicTypes
|
||||
return this.CloneInternal(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编译动态表达式,返回类型在运行时确定
|
||||
/// </summary>
|
||||
/// <param name="expression">要编译的表达式字符串</param>
|
||||
/// <returns>编译后的动态表达式</returns>
|
||||
public IDynamicExpression CompileDynamic(string expression)
|
||||
{
|
||||
return new Flee.InternalTypes.Expression<object>(expression, this, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编译泛型表达式,返回指定类型的结果
|
||||
/// </summary>
|
||||
/// <typeparam name="TResultType">表达式结果的类型</typeparam>
|
||||
/// <param name="expression">要编译的表达式字符串</param>
|
||||
/// <returns>编译后的泛型表达式</returns>
|
||||
public IGenericExpression<TResultType> CompileGeneric<TResultType>(string expression)
|
||||
{
|
||||
return new Flee.InternalTypes.Expression<TResultType>(expression, this, true);
|
||||
|
@@ -7,7 +7,7 @@ using System.Reflection;
|
||||
namespace Flee.PublicTypes
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 变量集合类,用于管理表达式中使用的变量
|
||||
/// </summary>
|
||||
public sealed class VariableCollection : IDictionary<string, object>
|
||||
{
|
||||
|
70
README.md
70
README.md
@@ -1,48 +1,30 @@
|
||||
# Flee (Supports Net6.0, Net5.0, Netstandard2.1, Netstandard2.0)
|
||||
Fast Lightweight Expression Evaluator.
|
||||
Convert this project vb.net to c#.
|
||||
# FLEE
|
||||
快速轻量级表达式求值器。
|
||||
|
||||
## Project Description
|
||||
Flee is an expression parser and evaluator for the .NET framework. It allows you to compute the value of string expressions such as sqrt(a^2 + b^2) at runtime. It uses a custom compiler, strongly-typed expression language, and lightweight codegen to compile expressions directly to IL. This means that expression evaluation is extremely fast and efficient.
|
||||
## 项目描述
|
||||
FLEE 是一个用于 .NET 框架的表达式解析器和求值器。它允许您在运行时计算字符串表达式的值,例如 sqrt(a^2 + b^2)。它使用自定义编译器、强类型表达式语言和轻量级代码生成器将表达式直接编译为 IL。这意味着表达式求值极其快速和高效。
|
||||
|
||||
## Features
|
||||
* Fast and efficient expression evaluation
|
||||
* Small, lightweight library
|
||||
* Compiles expressions to IL using a custom compiler, lightweight codegen, and the DynamicMethod class
|
||||
* Expressions (and the IL generated for them) are garbage-collected when no longer used
|
||||
* Does not create any dynamic assemblies that stay in memory
|
||||
* Backed by a comprehensive suite of unit tests
|
||||
* Culture-sensitive decimal point
|
||||
* Fine-grained control of what types an expression can use
|
||||
* Supports all arithmetic operations including the power (^) operator
|
||||
* Supports string, char, boolean, and floating-point literals
|
||||
* Supports 32/64 bit, signed/unsigned, and hex integer literals
|
||||
* Features a true conditional operator
|
||||
* Supports short-circuited logical operations
|
||||
* Supports arithmetic, comparison, implicit, and explicit overloaded operators
|
||||
* Variables of any type can be dynamically defined and used in expressions
|
||||
* CalculationEngine: Reference other expressions in an expression and recalculate in natural order
|
||||
* Expressions can index arrays and collections, access fields and properties, and call functions on various types
|
||||
* Generated IL can be saved to an assembly and viewed with a disassembler
|
||||
## 功能特性
|
||||
* 快速高效的表达式求值
|
||||
* 小巧轻量的库
|
||||
* 使用自定义编译器、轻量级代码生成器和 DynamicMethod 类将表达式编译为 IL
|
||||
* 表达式(及其生成的 IL)在不再使用时会被垃圾回收
|
||||
* 不会创建任何保留在内存中的动态程序集
|
||||
* 由全面的单元测试套件支持
|
||||
* 支持区域敏感的小数点
|
||||
* 对表达式可使用的类型进行细粒度控制
|
||||
* 支持所有算术运算,包括幂运算符 (^)
|
||||
* 支持字符串、字符、布尔值和浮点数字面量
|
||||
* 支持 32/64 位、有符号/无符号和十六进制整数字面量
|
||||
* 具有真正的条件运算符
|
||||
* 支持短路逻辑运算
|
||||
* 支持算术、比较、隐式和显式重载运算符
|
||||
* 可以动态定义任何类型的变量并在表达式中使用
|
||||
* 计算引擎:在表达式中引用其他表达式并按自然顺序重新计算
|
||||
* 表达式可以索引数组和集合、访问字段和属性,以及调用各种类型的函数
|
||||
* 生成的 IL 可以保存到程序集中并使用反汇编器查看
|
||||
|
||||
### Installing Flee
|
||||
## 许可
|
||||
本FLEE是从原Flee发布者处未经许可更改与改进得来, 用于源码编译
|
||||
|
||||
You should install [Flee with NuGet](https://www.nuget.org/packages/Flee):
|
||||
|
||||
Install-Package Flee
|
||||
|
||||
Or via the .NET Core command line interface:
|
||||
|
||||
dotnet add package Flee
|
||||
|
||||
## NuGet Packages
|
||||
|
||||
| Name | NuGet |
|
||||
| :--- | :--- |
|
||||
| [Flee](https://www.nuget.org/packages/Flee) | [](https://www.nuget.org/packages/Flee)
|
||||
|
||||
## More information
|
||||
* [Examples](https://github.com/mparlak/Flee/wiki/Examples) to learn how to create and evaluate expressions.
|
||||
|
||||
## License
|
||||
Flee is licensed under the LGPL. This means that as long as you dynamically link (ie: add a reference) to the officially released assemblies, you can use it in commercial and non-commercial applications.
|
||||
原Flee发布者发布的Flee 使用 LGPL 许可证。这意味着只要您动态链接(即添加引用)到官方发布的程序集,就可以在商业和非商业应用程序中使用它。
|
||||
|
Reference in New Issue
Block a user