antlr: Best practice to integrate generated parser into the system
Posted
by
green
on Stack Overflow
See other posts from Stack Overflow
or by green
Published on 2012-06-26T02:51:27Z
Indexed on
2012/06/26
3:15 UTC
Read the original article
Hit count: 171
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?
© Stack Overflow or respective owner