warsaw@nlm.nih.gov (Barry A. Warsaw) (12/21/90)
Last week I posted a request to c.l.c++ asking for C++ pretty printers. Well I suppose C++ is being introduced into the mainstream so rapidly that there just isn't much currently available -- I received more responses asking for summaries than I did with actual information! Anyway, thanks to Tom Ngo who told me about c++2latex (see below). As you'll see, there are some hidden things in SunOS 4.1, indicating perhaps that the state of C++ pretty printers and other support tools will become more widely available as C++ takes over the world :-). 1. C++ code reformatters There are currently no reformatting filters which understand C++ syntax along the lines of cb and indent for C. Both of these tools perform rather poorly when gobbing down C++. Specifically constructs such as "::" and "//" don't get handled very well. Something along the lines of indent++ which understands these special C++ constructs and provides all the reformatting capabilities that indent does would fit the bill nicely. This is what I really thought of when I asked for pretty printers, but I guess I'll have to wait. 2. C++ code stylizers What I mean by this are programs which will take C++ code and somehow highlight certain constructs such as comment blocks and keywords, outputting printer-ready files. Here there appears to be a few more options. The first comes with SunOS (4.1 atleast): vgrind. The manpage for vgrind(1) doesn't indicate that it understands the C++ language, but the -lC++ switch works on my machine, though I've heard that others with SunOS4.1 haven't be able to get it to work. Vgrind uses a file /usr/lib/vgrindsdef. Check for the section beginning with C++|c++:. If they're in there (after the yacc definitions), then -lC++ should work. I suspect the manpage will eventually catch up with reality... Tom Ngo describes a package written by Norbert Kiesel called c++2latex which does a similar thing as vgrind, but spits out complete LaTeX files. It seems to have a few more highlighting options than vgrind, such as the ability to specify the font for keywords, cpp directives, and string constants. Apparently it can be got from: tupac-amaru.informatik.rwth-aachen.de (192.35.229.9) In the file: C++2LaTeX-1.1.PL.1.tar.Z. There must be Stateside ftp sites which have this, but I haven't yet gone poking around, either on tupac or perhaps uunet. Tom also sent me some "trivial patches to c++2latex.l which make it recognize #line directives and not double space // comments." I include this patch at after my .siggy. From the manpage Tom sent me: C++2LATEX(1) ConvexOS Programmer's Manual C++2LATEX(1) NAME c++2latex - C/C++ to LaTeX converter SYNOPSIS c++2latex [-a] [-c] [-h] [-i length] [-o [-H font] [-K font] [-P font] [+ansi-c] [+complete-file] [+header] [+indentation length] [+output path] [+font-size size] [+pipe] [+comment- font [+keyword-font font] [+cpp-font font] [+header-font font] [+string-font font] [+tabstop wide] [+version] [path] DESCRIPTION c++2latex is a tool for generating LateX source from ANSI-C or C++ programs. It recogizes all keywords, strings, and comments. These recognized parts can be set in different fonts. c++2latex can generate complete LaTeX files which can directly passed through latex(1) or parts of LaTeX files which can be included in other files (either direct or by the \input or \include commands). 3. C++ editing Finally, though this isn't strictly what I had in mind regarding pretty printers, and most of you probably know these exist, I thought it might be worth mentioning that there are at least two different versions of a C++ mode for GNUemacs. lisp-dir-apropos shows one version by David Detlefs, et al, and another by Bruce Eckel and Thomas Keffer. Here are the relevent details: c++-mode-2 (1.0) 87-12-08 Bruce Eckel,Thomas Keffer, <eckel@beluga.ocean.washington.edu,uw-beaver!beluga!eckel,keffer@sperm.ocean.washington.edu> tut.cis.ohio-state.edu:pub/gnu/emacs/elisp-archive/as-is/c++-mode-2.el.Z Another C++ major mode. c++-mode 89-11-07 Dave Detlefs, et al, <dld@cs.cmu.edu> tut.cis.ohio-state.edu:pub/gnu/emacs/elisp-archive/modes/c++-mode.el.Z C++ major mode. Personally, I'm using Detlefs' C++ mode and in general it works very nice. I've noticed a few pecularities and have emailed to the authors, but haven't heard back yet. I have yet to try c++-mode-2 so I can't comment on that, but c++-mode works just fine for the most part. Well that's about the state of affairs as of 17:31pm 20-Dec-1990. No doubt this information will be obsolete tomorrow morning, the way C++ usage is growing in leaps and bounds! :-). Hope this was helpful, and please post any new findings or corrections to the whole newsgroup. Judging from my incoming mail, there's lots of us who are interested. Waiting anxiously to taste Saber-C++, -Barry NAME: Barry A. Warsaw USMAIL: National Library of Medicine TELE: (301) 496-1936 Lister Hill National Center for INET: warsaw@nlm.nih.gov Biomedical Communications UUCP: uunet!nlm.nih.gov!warsaw Information Technology Branch 8600 Rockville Pike Bldg. 38A, Rm. 7s722 Bethesda, Md. 20894 =========================================================================== *** /tmp/,RCSt1019814 Tue Nov 27 13:08:59 1990 --- c++2latex.l Tue Nov 27 13:07:45 1990 *************** *** 89,94 **** --- 89,95 ---- "#"[ \t]*"elif" | "#"[ \t]*"else" | "#"[ \t]*"error" | + "#"[ \t]*"line" | "#"[ \t]*"endif" CPP; *************** *** 206,212 **** <BCOMMENT>^[ \t]+ IND; <BCOMMENT>. SUB (yytext); ! <CPLUSPLUS>"//".*$ { OUT ("{$//$\\"); OUT (comment_font); OUT ("{}"); SUB (yytext + 2); OUT ("}\\mbox{}\\\\\n"); } --- 208,214 ---- <BCOMMENT>^[ \t]+ IND; <BCOMMENT>. SUB (yytext); ! <CPLUSPLUS>"//".*"\n" { OUT ("{$//$\\"); OUT (comment_font); OUT ("{}"); SUB (yytext + 2); OUT ("}\\mbox{}\\\\\n"); }