views:

93

answers:

2

Greetings

I'm working on a project that requires me to write queries in text form, then convert them to some easily processed nodes to be processed by some abiguous repository. Of everything there, the part I'm least interested is the part that converts the text to nodes. I'm hoping it's already done somewhere.

Because I'm making stuff up as I go, I chose to use a LINQish expression syntax.

from m in Movie select m.A, m.B

I started parsing it manually and got the basics, but it's pretty cheesy. I'm looking for the better solution. I made some progress using MGrammar, but it would be nice if such a thing already existed. Does anyone know of anything that already does this? I looked for existing ANTLR templates, but no luck.

Thanks for the help.

+1  A: 

You could start with a full C# grammar and throw away everything but the LINQ syntax :-}

The DMS Software Reengineering Toolkit is a tool for building parsers/program analyzers/transformers that has a full C# 4.0 front end, including all the LINQ syntax.

Ira Baxter
A: 

Try this example from the Pyparsing wiki Examples page. It should give you a start.

Paul McGuire