[antlr-interest] Code beautifier-indentation

John D. Mitchell johnm-antlr at non.net
Fri Mar 18 06:55:31 PST 2005


>>>>> "Meena" == Meena Moktali <mmoktali at bphx.dk> writes:
[...]

> hi John & Bryan, The example I have shown is just doing indentation...to
> start with..:) I also know that I have to keep track of the levels and
> change the columns...just not getting the proper grammar for it.I also
> have to reformat it --- keep track of line size,put the 'of' under
> another 'of' and 'map'under 'map'.

So, that now sounds like you want a full source-to-soruce translator.
If you want to do a very high-quality job, that can be very painful.  If
you want to merely do an okay job, that's pretty straight forward.

> I am trying out with the help of treewalk.g ,but getting stuck.  I shall
> be grateful if u can suggest me a sample grammar for the indentation,the
> rest I think I can manage.Also I welcome suggestions for any other option
> to ANTLR...:) I have a scary deadline..please help!

Check out the C/GCC translator that's available on antlr.org. In terms of
the rewriting, the idea is to start with a clean treeparser (like
GnuCTreeParser) and then, if you need to do any structural changes, create
one or more tree transformation passes.  In terms of printing out the tree,
check out GnuCEmitter.g for an example of one way of doing it.

Have fun,
	John


More information about the antlr-interest mailing list