CSharp listener example rather incomplete

13 views
Skip to first unread message

Michael Powell

unread,
Jan 31, 2019, 11:15:51 AM1/31/19
to antlr-discussion
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

Reply all
Reply to author
Forward
0 new messages