diff --git a/ExpressionElements/Base/Binary.cs b/ExpressionElements/Base/Binary.cs index 3ce24f9..bd72659 100644 --- a/ExpressionElements/Base/Binary.cs +++ b/ExpressionElements/Base/Binary.cs @@ -8,7 +8,9 @@ using System; namespace Flee.ExpressionElements.Base { - [Obsolete("Base class for expression elements that operate on two child elements")] + /// + /// 操作两个子元素的表达式元素的基类 + /// internal abstract class BinaryExpressionElement : ExpressionElement { diff --git a/ExpressionElements/MemberElements/ArgumentList.cs b/ExpressionElements/MemberElements/ArgumentList.cs index 2c2797d..0a76539 100644 --- a/ExpressionElements/MemberElements/ArgumentList.cs +++ b/ExpressionElements/MemberElements/ArgumentList.cs @@ -6,7 +6,9 @@ using Flee.InternalTypes; namespace Flee.ExpressionElements.MemberElements { - [Obsolete("Encapsulates an argument list")] + /// + /// 封装参数列表的类 + /// internal class ArgumentList { private readonly IList _myElements; diff --git a/ExpressionElements/MemberElements/FunctionCall.cs b/ExpressionElements/MemberElements/FunctionCall.cs index 94a8331..f89fe39 100644 --- a/ExpressionElements/MemberElements/FunctionCall.cs +++ b/ExpressionElements/MemberElements/FunctionCall.cs @@ -10,7 +10,9 @@ using Flee.PublicTypes; namespace Flee.ExpressionElements.MemberElements { - [Obsolete("Represents a function call")] + /// + /// 表示函数调用的表达式元素 + /// internal class FunctionCallElement : MemberElement { private readonly ArgumentList _myArguments; diff --git a/ExpressionElements/MemberElements/Identifier.cs b/ExpressionElements/MemberElements/Identifier.cs index 6662af4..734461d 100644 --- a/ExpressionElements/MemberElements/Identifier.cs +++ b/ExpressionElements/MemberElements/Identifier.cs @@ -15,7 +15,9 @@ using System; namespace Flee.ExpressionElements.MemberElements { - [Obsolete("Represents an identifier")] + /// + /// 表示标识符的表达式元素 + /// internal class IdentifierElement : MemberElement { private FieldInfo _myField; diff --git a/ExpressionElements/MemberElements/Indexer.cs b/ExpressionElements/MemberElements/Indexer.cs index 2efd9ec..8ec7dd1 100644 --- a/ExpressionElements/MemberElements/Indexer.cs +++ b/ExpressionElements/MemberElements/Indexer.cs @@ -9,7 +9,9 @@ using Flee.PublicTypes; namespace Flee.ExpressionElements.MemberElements { - [Obsolete("Element representing an array index")] + /// + /// 表示数组索引的表达式元素 + /// internal class IndexerElement : MemberElement { private ExpressionElement _myIndexerElement; diff --git a/InternalTypes/BranchManager.cs b/InternalTypes/BranchManager.cs index bde39ed..02fe44b 100644 --- a/InternalTypes/BranchManager.cs +++ b/InternalTypes/BranchManager.cs @@ -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")] + /// + /// 管理分支信息,允许我们确定是否应该发出短分支或长分支 + /// internal class BranchManager { private readonly IList MyBranchInfos; @@ -143,7 +145,9 @@ namespace Flee.InternalTypes } } - [Obsolete("Represents a location in an IL stream")] + /// + /// 表示IL流中的位置 + /// internal class ILLocation : IEquatable, IComparable { private int _myPosition; @@ -214,7 +218,9 @@ namespace Flee.InternalTypes } } - [Obsolete("Represents a branch from a start location to an end location")] + /// + /// 表示从起始位置到结束位置的分支 + /// internal class BranchInfo { private readonly ILLocation _myStart; diff --git a/InternalTypes/Miscellaneous.cs b/InternalTypes/Miscellaneous.cs index fb5c55e..df51a80 100644 --- a/InternalTypes/Miscellaneous.cs +++ b/InternalTypes/Miscellaneous.cs @@ -160,7 +160,9 @@ namespace Flee.InternalTypes public static object Instance => OurInstance; } - [Obsolete("Helper class to resolve overloads")] + /// + /// 用于解析重载的辅助类 + /// internal class CustomMethodInfo : IComparable, IEquatable { /// @@ -494,7 +496,9 @@ namespace Flee.InternalTypes } } - [Obsolete("Wraps an expression element so that it is loaded from a local slot")] + /// + /// 包装表达式元素,使其从本地槽位加载 + /// 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")] + /// + /// 用于存储强类型属性的辅助类 + /// internal class PropertyDictionary { private readonly Dictionary _myProperties; diff --git a/InternalTypes/Utility.cs b/InternalTypes/Utility.cs index e37e098..aa5b18b 100644 --- a/InternalTypes/Utility.cs +++ b/InternalTypes/Utility.cs @@ -6,7 +6,9 @@ using System.Reflection.Emit; namespace Flee.InternalTypes { - [Obsolete("Holds various shared utility methods")] + /// + /// 包含各种共享实用方法的工具类 + /// internal class Utility { private Utility() diff --git a/Parsing/Analyzer.cs b/Parsing/Analyzer.cs index 17383bf..377d77d 100644 --- a/Parsing/Analyzer.cs +++ b/Parsing/Analyzer.cs @@ -3,7 +3,9 @@ using System.Collections; namespace Flee.Parsing { - [Obsolete("Creates a new parse tree analyzer.")] + /// + /// 创建新的解析树分析器 + /// internal class Analyzer { public Analyzer() diff --git a/Parsing/Parser.cs b/Parsing/Parser.cs index 2e9bbdb..410f4ec 100644 --- a/Parsing/Parser.cs +++ b/Parsing/Parser.cs @@ -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.")] + /// + /// 基础解析器类。此类提供标准解析器接口以及令牌处理功能 + /// internal abstract class Parser { private bool _initialized; diff --git a/PublicTypes/ExpressionContext.cs b/PublicTypes/ExpressionContext.cs index ca7052e..aefbaeb 100644 --- a/PublicTypes/ExpressionContext.cs +++ b/PublicTypes/ExpressionContext.cs @@ -8,6 +8,9 @@ using Flee.Parsing; namespace Flee.PublicTypes { + /// + /// 表达式上下文类,提供表达式编译和执行的环境 + /// public sealed class ExpressionContext { @@ -186,11 +189,22 @@ namespace Flee.PublicTypes return this.CloneInternal(true); } + /// + /// 编译动态表达式,返回类型在运行时确定 + /// + /// 要编译的表达式字符串 + /// 编译后的动态表达式 public IDynamicExpression CompileDynamic(string expression) { return new Flee.InternalTypes.Expression(expression, this, false); } + /// + /// 编译泛型表达式,返回指定类型的结果 + /// + /// 表达式结果的类型 + /// 要编译的表达式字符串 + /// 编译后的泛型表达式 public IGenericExpression CompileGeneric(string expression) { return new Flee.InternalTypes.Expression(expression, this, true); diff --git a/PublicTypes/VariableCollection.cs b/PublicTypes/VariableCollection.cs index 59ee2ab..954bdfa 100644 --- a/PublicTypes/VariableCollection.cs +++ b/PublicTypes/VariableCollection.cs @@ -7,7 +7,7 @@ using System.Reflection; namespace Flee.PublicTypes { /// - /// + /// 变量集合类,用于管理表达式中使用的变量 /// public sealed class VariableCollection : IDictionary { diff --git a/README.md b/README.md index c078ef5..ed9063b 100644 --- a/README.md +++ b/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) | [![Flee](https://img.shields.io/badge/nuget-v2.0.0-blue.svg)](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 许可证。这意味着只要您动态链接(即添加引用)到官方发布的程序集,就可以在商业和非商业应用程序中使用它。