antlr: Best practice to integrate generated parser into the system
- by green
Here is the background, I am trying to create a DSL to allow customer write simple scripts to query into our mongodb based database. I choose antlr to implement the DSL.
From my understanding (and pls let me know if it's not correct) there are 2 approaches to integrate antlr generated parser into the system:
Embed code into the grammar file so that the generated parser could
be used directly to make query to the database and return result in
a certain format (e.g. json encoded)
Keep the parser purely a parser, after feed the DSL file to it, and construct the query in another class by retrieving the AST from generated parser class
So antlrers, which one do you think is the way I as an antlr newbie should go? Can you list the pros and cos of each approach, or you have other way to recommend?