tags:

views:

65

answers:

2

In a C# app, I would like users to be able to enter search criteria in this kind of format:

(Name = 'Fred' OR Name = 'Jim') AND Age > 30

What I need is some way to parse the input so I can test potential search matches against the criteria. I did experiment with Malcolm Crowe's compiler tools for .NET years ago, but I'm wondering if there is any new stuff I should be aware of in these days of DSLs and expression trees. What is the best way of approaching this problem?

+2  A: 

I've been looking at Irony, recently. It's almost overpowered for what you need, but does fall into the category of "new stuff I should be aware of".

Here's an example, using Irony, which seems to do what you require (registration required to read it, though).

Craig Stuntz
+1  A: 

Another tool you could use if you have a standardized grammer for you search criteria would be MGrammer which has several tools available for helping to structure the parsing. A good link for information that is to Scott Hanselman's Blog. There are also some sample videos of how to use it there.

Adam Gritt