Tuesday, July 31, 2007

FLEE - Fast Lightweight Expression Evaluator

Eugene Ciloci has created a new project on Codeplex - FLEE.  This work is also on CodeProject.

The project description says: "A .NET expression parser and evaluator that uses a custom compiler and lightweight codegen to compile expressions to IL and emit them to a dynamic method."

Worthy of a look.

Technorati Tags:

1 comment:

Winston Johnston said...

CodePlex is a community site and the author has requested feedback on the current functionality. We could therefore post a list of feature suggestions.

As far as I can tell, the expression language is a mix of C# and VB since the author has defined his own gramma. The parser is actually generated using a tool called Grammatica which is similar in concept to LEX & YAK. The gramma is case-insensitive, handles designators, cast operations and IF expressions. It should be trivial to augment the gramma to handle nested strings (if not already supported).

The parser also implements short circuit expression evaluation. It’s unclear whether the author has implemented any other optimisations. We’d need to test the generated IL to gain a clearer understanding.

Another great feature is the ability to import extension classes like System.Math. This means that you can augment the gramma with static methods like System.Math.Sin.

Perhaps the best part is that the compiled IL is only written to a MemoryStream so it’s easy to garbage collect discarded expressions.

Have a read of the corresponding CodeProject site http://www.codeproject.com/useritems/Flee.asp

This tool actually looks very good and I think it’s worth a closer look!