I have 2 problems:
In my ANTLR parser, I have this rewrite rule:
msg: msg_content (COMMA msg_content)* -> ^(MSG_CTS msg_content+);
In my tree grammar, how can I make use of the collected msg_content tokens? $msg_content.text is returning a null exception.
More generally, can you please provide some guide to me, as to how I can use my generated AST tree? I basically want to walk over the nodes and create Java classes for the different things for e.g.
I have this simple tree that gets printed:
(MSG (AGENTS A B) (MSG_CTS x y))
I'd like to have some Java class "Message" with fields for "Agents" containing A, B and some Content field that will hold X, Y.
I've gone through the ANTLR definitive guide, but haven't sen references on how to use the combined tokens, or even, how to navigate down the tree like I want. It's as if every ANTLR tutorial out there is about expression evaluators!
I've seen: "Interfacing AST with Java" and "Expression evaluator" from the ANTLR online manual, but I don't quite get how to apply those to my problem. If you can provide a simple example, it'd be very helpful!
Please help... Thank you!