开发者

Is there a library for .NET that does parenthesis or expression reduction and optimization?

开发者 https://www.devze.com 2022-12-25 06:45 出处:网络
Is there a library for .NET that does parenthesis or expression reduction and o开发者_JAVA技巧ptimization?

Is there a library for .NET that does parenthesis or expression reduction and o开发者_JAVA技巧ptimization? Something that would take an expression such as (A & (((B) | (C)) | D))) and return

A & (B | C | D)

But also take (A & A) and return A


This is more in the domain of a standalone parser/lexical analyzer. But ANTLR has a rather nice C# binding, if that would suit your purposes.

It probably wouldn't be very much work to write a simple parser for strings of this sort and do the reduction yourself.


I'm not a LINQ expert, but if you wanna get your hands dirty, the datastructures for such a task already exist in .Net Expression Trees:

http://msdn.microsoft.com/en-us/library/bb397951.aspx

You'd still have to parse the string to create the tree though.

0

精彩评论

暂无评论...
验证码 换一张
取 消