How do I build a domain-specific query language?
I have a biology database that I would like to query. There is also a given terminology bank I have access to that has formalizable predicates. I would like to build a query language for th开发者_JAVA技巧is DB using the predicates mentioned. How would you go about it? My solution is the following:
- formalize the predicates
- translate into a query language (sql, sparql, depends)
- Build a specific language with ANTLR or other such tools
- Translate from 3 to 2.
Is this a valid approach? Are there better ones? Any pointers would be much appreciated.
Take a look at Booleano.
Use BNF to get a head-start into the language semantics..GoldParser will help you by playing around with the semantics and syntax (link here: http://www.devincook.com/). Once you have the BNF semantics sorted out, you can then build up actions based on the inputs, for example, a bnf grammar section dealing with extracting a composition of a limb's genetic makeup classification (I do not know if that is in existence, abstract example here but you get the gist) for a particular query...'fetch stats on limb where limb is leg', then behind the scenes you would issue a SQL select on a column alias or name from a predefined table ... I could be wrong on the approach... Hope it helps?
I suggest you take a look at the i2b2 framework, it's a graphical query language and query engine platform for patient databases.
It's probably hard to grasp all first but do take a look at the CRC cell or webservice in there, you'll see how they approached SQL generation from a clinical graphical query language in an interesting way (albeit, not so performance friendly :))
Consider using Irony.NET from here: Irony.NET
精彩评论