I was giving a quick look on how could the code-formatter be better, and having researched a little on how would it do the 'pretty-print' I found some references:
Dealing with comments:
Approach 1 (using special token):
Approach 2 (not using special token and actually putting comments in the parsing.
Currently, I generate an asdl structure that would also need to be extended to be supported later, but I guess I'll have to work on this myself, as I could not find any reference about comments in asdl... anyone has any suggestions?
And a little 'offtopic' but also for javaCC:
Error recovery: http://www.cise.ufl.edu/help/software/JavaCC/errorrecovery.html
Getting special tokens: https://javacc.dev.java.net/doc/tokenmanager.html