I made several changes (not a rewrite, since there is much in the original design that I wish to keep). This version improves the parsing algorithm by marking the state of all characters, recognizes a wider range of indention structures, and implements a simple algorithm for indenting embedded SQL.
Download: The source (gzip'd tar)