开源 - 轻型的表达式引擎 Flee

  在《报表引擎 - 报表应用思路》中的主要技术中说过表达式引擎对报表来说是很重要的一个技术,在以前的报表系统中表达式引擎也不是我开发的,我是使用我们公司内部开发的一个delphi引擎,运行的还很不错,如果报表转移到.Net下我就最好要找一个.Net版的表达式引擎了,而且最好更快一些,因为报表计算有时要计算很多次,效率是重要考虑因素之一。

  一两年前注意到了这个开源的表达式引擎 - Flee(Fast Lightweight Expression Evaluator),感兴趣的可以去尝试一下。由于我还是比较早关注的这个,如果有谁知道还有更好的表达式引擎,也请和我分享一下,OpenExpressApp中底层引擎中包括报表引擎,所以对表达式引擎的选择也是一件大事:)

优点

  1. 速度快,把表达式直接编译成IL代码
  2. 轻量级,使用简单方便
  3. 支持表达式变量解释,和我公司的一样,通过一个方法可以解释自定义变量
  4. 文档还行,看后就会用了
  5. 开发也有段时间了,相对来说比较稳定

如何使用

  由于轻量级又简单,大家可以使用在任何需要表达式解释的地方,可以参考Examples

为了方便我把它的主页介绍附在最后面。

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. Try out the demo, which lets you generate images based on expressions, and see for yourself.

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


More information


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.

 

欢迎转载,转载请注明:转载自周金根 [ http://zhoujg.cnblogs.com/ ]

posted on 2009-11-29 09:56  周 金根  阅读(6583)  评论(7编辑  收藏  举报

导航