Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Is there a library for .NET that does parenthesis or expression reduction and optimization? 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

like image 443
Matt Avatar asked Dec 06 '25 04:12

Matt


1 Answers

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.

like image 170
John Feminella Avatar answered Dec 08 '25 18:12

John Feminella