Hello,
The example is a good start getting one's feet wet with the parser listener issue.
However, I do not think it goes quite far enough.
The rub is really this:
class KeyPrinter : MyGrammarBaseListener {
// override default listener behavior
void ExitKey (MyGrammarParser.KeyContext context) {
Console.WriteLine("Oh, a key!");
}
}
Here, we marvel that we have a MyGrammarParser.KeyContext. However, great, so what? What do we do with the actual Context? This doesn't even attempt to scratch the Context surface. How do we get to the bits behind the Context to do anything useful with that? In my case, I'd like to round out an AST for internal use after visiting each node.
Best regards,
Michael W Powell