Antlr4: pretty printing a Java code

534 views
Skip to first unread message

Artyom Aleksyuk

unread,
May 24, 2015, 5:41:47 AM5/24/15
to antlr-di...@googlegroups.com

Hello. I'm writing a proof-of-concept code transformation tool for Java, so I need to turn a parse tree back into the Java code. The result code shouldn't be character-precise compared to the input, as I understand, this is called "pretty printing".
I've tried to find any tools which are able to do this, but found only several Antlr3-era posts which tell that there's no such tool.
Maybe anyone have made such tool since this time? As I understand, it's a huge task and would require me to write several thousands lines of code.

Thanks, Artyom.

Terence Parr

unread,
May 24, 2015, 2:34:10 PM5/24/15
to antlr-di...@googlegroups.com
it’s nontrivial for sure. getting original text is trivial, though, if that’s all you need.
T
--
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/d/optout.

Artyom Aleksyuk

unread,
May 25, 2015, 1:03:35 PM5/25/15
to antlr-di...@googlegroups.com
Thank you for the answer, Terence. Is it possible to get an original text which corresponds to a subtree?

--
You received this message because you are subscribed to a topic in the Google Groups "antlr-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/antlr-discussion/H9nvLvtjwmI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to antlr-discussi...@googlegroups.com.

Terence Parr

unread,
May 25, 2015, 3:28:06 PM5/25/15
to antlr-di...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages