Best way to create AST from ANTLR4

1,368 views
Skip to first unread message

Hans Uhlig

unread,
Feb 24, 2013, 9:25:04 PM2/24/13
to antlr-di...@googlegroups.com
I know that direct AST generation was deprecated from the 4.0 but is there a simple way to generate an AST from the ANTLR Parse Tree either via Visitors or Listeners? If so are there any examples available?

Terence Parr

unread,
Feb 25, 2013, 12:39:12 PM2/25/13
to antlr-di...@googlegroups.com
Hi.  In the grammar itself or in the event or visitor methods, you would create an AST manually with new AddNode(...) type stuff.  A visitor is probably the easiest because then you can have each of the visitor methods  return an AST node.
Ter


On Sun, Feb 24, 2013 at 6:25 PM, Hans Uhlig <huh...@gmail.com> wrote:
I know that direct AST generation was deprecated from the 4.0 but is there a simple way to generate an AST from the ANTLR Parse Tree either via Visitors or Listeners? If so are there any examples available?

--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Dictation in use. Please excuse homophones, malapropism, and nonsense. 
Reply all
Reply to author
Forward
0 new messages