I am a beginner at ANTLR, I have the 2 books by it’s creator and I am reading a lot of blogs/forums posts but it seems that I just don’t get it right now.
All I can find is grammar code for this, and tree grammar code for this, but I just can’t understand how exactly a control flow is made out of this.
Because I suppose that I can’t put my question clear enough for you, let me put it that way:
Can you please show me all necessary code that upon passing to the parser
for (i=0; i!=3; i=i+1) {
if (i==2) print i;
else print "not 2";
}
Will output:
not 2
not 2
2
Preferably in Java.
Edit: I found a small project hosted at code.google.com that uses ANTLR, and based on it I understood how silly is my question ! 🙂
As a scanner/parser, Antlr only implements what we call the front end of a compiler. Antlr’s task is to take free-form text and turn it into a data structure that’s easy for programs – particularly compiler back ends – to work with.
Writing that compiler back end (or interpreter, or whatever) is still your job, I’m afraid!