How to use antlr to generate c# code?

41 views
Skip to first unread message

deos...@gmail.com

unread,
Jun 10, 2013, 4:09:41 AM6/10/13
to antlr-di...@googlegroups.com
hi,

I have a basic set of rules as per my rule engine requirement. The syntax goes as follows:

---begin snippet---

if <conditions> then <return-string>
if <conditions> then <return-string>
if <conditions> then <return-string>
...
.
.

---end snippet---

I need to generate equivalent c# code out of this. Prior to antlr I had written my own implementation of a parser. The parser made use of System.CodeDom classes to build the necessary source code from the correct CodeConditionStatement objects. Each CodeConditionStatement will hold a CodeExpression (base class) object. I used to parse the text and figure out the correct CodeExpression object to form.

My parser program moves through various states which help me realize the token, i.e. identify if it is a variable, operation, or data.

I am kind of new to antlr and want to get started off in this direction. So where does antlr need to come in the picture here.

-Regards
Arun

Reply all
Reply to author
Forward
0 new messages