Free source code diagramming programs [message #48304] |
Sun, 09 April 2006 14:24  |
idlwizard-1@yahoo.com
Messages: 11 Registered: December 2005
|
Junior Member |
|
|
The latest revision of my source code diagramming programs are
available at
http://www.geocities.com/grunes/diagram.html
These programs diagram source code in the following languages:
C and C++<br>
FORTRAN<br>
HTML (very incomplete)<br>
IDL, PV-WAVE, GDL and FL
They do things like draw lines showing the start and end of routines
and blocks, put * next to jumps, and = next to commented out sections,
and can warn you of certain classes of error.
They can help you find problems in your own code, or help you look at
long complicated legacy code other people give you.
The programs themselves are in FORTRAN. I know that is a problem for
users of other programming languages, but it is freely available as g77
or g95 under Cygwin (under Windows) or Linux, and is available on many
other platforms.
|
|
|
Re: Free source code diagramming programs [message #48344 is a reply to message #48304] |
Thu, 13 April 2006 17:43   |
Al Balmer
Messages: 3 Registered: April 2006
|
Junior Member |
|
|
On 13 Apr 2006 17:20:40 -0700, "mitch grunes" <idlwizard-1@yahoo.com>
wrote:
>> Pretty printers (auto-indentation, etc.) lose a lot of information...
>> and tend to mess up comments,
>> especially when the author carefully lined up the columns of his/her
>> comments or code in some sort of table.
>
> Could you elaborate on this? What information is lost by reformatting?
>
> Here is an example from a FORTRAN calculator program, which will also
> only line up right if you display in a fixed width font like Courier:
>
> ! Problems
> if((a.eq.'/' .and. y.eq.0).or. ! Divide by 0
> & (a.eq.'1/'.and. y.eq.0).or. ! reciprocal of 0
> & (a.eq.'^' .and.(y.lt.0 ! Negatives to
> negative power
> & .or.(x.eq.0.and.y.eq.0))) then ! Zero to zero power
>
> If you only know IDL,
> ; Problems
> if (a eq '/' and y eq 0) or $ ; Divide by 0
> (a eq '1/' and y eq 0) or $ ; reciprocal of 0
> (a eq '^' and (y lt 0 $ ; Negatives to
> negative power
> or (x eq 0 and y eq 0)) then begin ; Zero to zero
> power
>
> If you only know C,
> /* Problems */
> if((strcmp(a,'/' )==0 && y==0) || /* Divide by 0 */
> (strcmp(a,'1/')==0 && y==0) || /* reciprocal of 0 */
> (strcmp(a,'^' )==0 && (y==0 /* Negatives to negative
> power */
> || (x==0 && y==0))) { /* Zero to zero power */
>
> No pretty printer is gonna preserve that.
I wouldn't ask a pretty printer to format anything that won't compile.
Count your parentheses and braces. Check the definition of strcmp().
--
Al Balmer
Sun City, AZ
|
|
|
|
Re: Free source code diagramming programs [message #48360 is a reply to message #48304] |
Thu, 13 April 2006 10:47   |
James Kuyper
Messages: 425 Registered: March 2000
|
Senior Member |
|
|
Gary L. Scott wrote:
> Edward Gregor wrote:
>
>> slebetman@yahoo.com wrote:
...
>>> Well... my favourite text editor already does what your program do and
>>> does it live while I'm editing code. On top of that it also
>>> *highlights* the relevant line when the cursor is on either the opening
>>> or closing brace {}. On top of that it does syntax highlighting. On top
>>> of that it also allows me to fold sections of code to temporarily hide
>>> things I'm not interested in (and remember this is "live" while I'm
>>> editing). And to top it all off it can print, save as RTF save as PDF
>>> and save as HTML the nicely formatted code along with the nice lines.
>>> The only difference is that my editor draws lines based on indentation
>>> while your program auto-indent and draws lines based on braces. But
>>> that's OK, that's what "indent" is for. Oh and yes my editor supports
>>> syntax of more than 40 different languages including C/C++, Tcl,
>>> Fortan, Forth, VB, Perl...
>>>
>>
>> May I ask which editor you are using?
>
> Most decent editors do most of this.
I suppose that's true, for suitable definitions of "most" and "decent".
I've seen editors that do what you say, but they are not as commonplace
in my experience as they seem to be in yours. Would you care to
identify some editors that you consider decent?
|
|
|
Re: Free source code diagramming programs [message #48361 is a reply to message #48304] |
Thu, 13 April 2006 10:27   |
Al Balmer
Messages: 3 Registered: April 2006
|
Junior Member |
|
|
On 13 Apr 2006 10:03:07 -0700, "mitch grunes" <idlwizard-1@yahoo.com>
wrote:
>> Well... my favourite text editor already does what your program do and
>> does it live while I'm editing code...
>
> Are you talking about the EMACS editor?
Many modern program editors do it. Most are easier to learn than emacs
<g>.
> I confess I'm not smart enough
> to learn it well, and when I tried it it did some things I didn't
> expect. I prefer simpler editors that only do predictable things.
> Perhaps it is because I never learned much LISP.
>
> I do remember EMACS did something right - you could make it jump to the
> beginning or end of the current block - at least if you trust the code
> block structure to be correct. When you are fixing that struture in
> someone else's code, you don't want your text editor to be so "smart"
> it won't let you. (Taking again the example of debugging tens of
> thousands of lines of legacy code that doesn't quite work right.)
>
> Pretty printers (auto-indentation, etc.) lose a lot of information,
> when you are trying to fix such,
Could you elaborate on this? What information is lost by reformatting?
> and tend to mess up comments,
> especially when the author carefully lined up the columns of his/her
> comments or code in some sort of table.
That can happen, but some (most?) reformatters can be told to leave
comments alone.
> So I leave the source code
> intact, and create seperate diagrams.
>
> I've written a lot of operational code over the last 25 years that ran
> various places and was sometimes embedded in ship, air and space-borne
> platforms. Sometimes I've had to debug monsters. (Like the pretty lady
> said, professionals do what they are paid to do.
As a professional, I've often considered it my duty to educate those
who tell me what to do ;-)
> Though, at the moment,
> I am between jobs.) I've found these tools useful. But every programmer
> has their own way of working. If you don't like mine, don't use it!
--
Al Balmer
Sun City, AZ
|
|
|
Re: Free source code diagramming programs [message #48362 is a reply to message #48304] |
Thu, 13 April 2006 10:03   |
idlwizard-1@yahoo.com
Messages: 11 Registered: December 2005
|
Junior Member |
|
|
> Well... my favourite text editor already does what your program do and
> does it live while I'm editing code...
Are you talking about the EMACS editor? I confess I'm not smart enough
to learn it well, and when I tried it it did some things I didn't
expect. I prefer simpler editors that only do predictable things.
Perhaps it is because I never learned much LISP.
I do remember EMACS did something right - you could make it jump to the
beginning or end of the current block - at least if you trust the code
block structure to be correct. When you are fixing that struture in
someone else's code, you don't want your text editor to be so "smart"
it won't let you. (Taking again the example of debugging tens of
thousands of lines of legacy code that doesn't quite work right.)
Pretty printers (auto-indentation, etc.) lose a lot of information,
when you are trying to fix such, and tend to mess up comments,
especially when the author carefully lined up the columns of his/her
comments or code in some sort of table. So I leave the source code
intact, and create seperate diagrams.
I've written a lot of operational code over the last 25 years that ran
various places and was sometimes embedded in ship, air and space-borne
platforms. Sometimes I've had to debug monsters. (Like the pretty lady
said, professionals do what they are paid to do. Though, at the moment,
I am between jobs.) I've found these tools useful. But every programmer
has their own way of working. If you don't like mine, don't use it!
|
|
|
|
|
|
Re: Free source code diagramming programs [message #48370 is a reply to message #48304] |
Wed, 12 April 2006 07:55   |
Gary L. Scott
Messages: 3 Registered: September 2003
|
Junior Member |
|
|
Edward Gregor wrote:
> slebetman@yahoo.com wrote:
>
>> idlwizard-1@yahoo.com wrote:
>>
>>> The latest revision of my source code diagramming programs are
>>> available at
>>>
>>> http://www.geocities.com/grunes/diagram.html
>>>
>>> These programs diagram source code in the following languages:
>>>
>>> C and C++<br>
>>> FORTRAN<br>
>>> HTML (very incomplete)<br>
>>> IDL, PV-WAVE, GDL and FL
>>>
>>> They do things like draw lines showing the start and end of routines
>>> and blocks, put * next to jumps, and = next to commented out sections,
>>> and can warn you of certain classes of error.
>>>
>>> They can help you find problems in your own code, or help you look at
>>> long complicated legacy code other people give you.
>>>
>>> The programs themselves are in FORTRAN. I know that is a problem for
>>> users of other programming languages, but it is freely available as g77
>>> or g95 under Cygwin (under Windows) or Linux, and is available on many
>>> other platforms.
>>
>>
>> Well... my favourite text editor already does what your program do and
>> does it live while I'm editing code. On top of that it also
>> *highlights* the relevant line when the cursor is on either the opening
>> or closing brace {}. On top of that it does syntax highlighting. On top
>> of that it also allows me to fold sections of code to temporarily hide
>> things I'm not interested in (and remember this is "live" while I'm
>> editing). And to top it all off it can print, save as RTF save as PDF
>> and save as HTML the nicely formatted code along with the nice lines.
>> The only difference is that my editor draws lines based on indentation
>> while your program auto-indent and draws lines based on braces. But
>> that's OK, that's what "indent" is for. Oh and yes my editor supports
>> syntax of more than 40 different languages including C/C++, Tcl,
>> Fortan, Forth, VB, Perl...
>>
>
> May I ask which editor you are using?
Most decent editors do most of this.
--
Gary Scott
mailto:garyscott@ev1.net
Fortran Library: http://www.fortranlib.com
Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html
Why are there two? God only knows.
If you want to do the impossible, don't hire an expert because he knows
it can't be done.
-- Henry Ford
|
|
|
Re: Free source code diagramming programs [message #48371 is a reply to message #48304] |
Wed, 12 April 2006 07:54   |
Gary L. Scott
Messages: 3 Registered: September 2003
|
Junior Member |
|
|
mitch grunes wrote:
>> Well yeah, but it's a lot of
>> hard work to trace over
>> 3914 lines of useless Usenet post...
>
>
> OK, next time I'll limit the source code to alt.sources, or maybe find
> another free web hoster that lets me store source code files.
>
> Didn't occur to me that some Usenet reading programs make you read
> everything.
>
> As to the Ben Pfaff, who prefered identation, I do that on my own code.
> It's good enough for short programs, if I make no mistakes.
>
> But the next time someone hands you a 20000 or so line legacy program
> developed by 200 people over 30 years, that no one alive understands,
> you may appreciate whatever help you can get. There is a lot of code
> out there like that. The definition of a professional is that you do
> what you are payed to do.
>
> Brooks Moses's idea of coloring indentation stuff to make it more clear
> sounds neat. But a lot of work - I was trying to stay away from
> postscript.
>
On windows, color would be quite easy using an RTF edit box. You can
then output the RTF content to disk. RTF is widely supported as an
import format to most word processors on other platforms and it remains
editable. Postscript is a printer data stream. It shouldn't be used as
a document interchange format. I would think that it would be
desireable for this output to remain editable so that you can import it
into presentations or other documents and tweak it (fonts, spacing, etc).
--
Gary Scott
mailto:garyscott@ev1.net
Fortran Library: http://www.fortranlib.com
Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html
Why are there two? God only knows.
If you want to do the impossible, don't hire an expert because he knows
it can't be done.
-- Henry Ford
|
|
|
Re: Free source code diagramming programs [message #48374 is a reply to message #48304] |
Wed, 12 April 2006 05:58   |
Edward Gregor
Messages: 1 Registered: April 2006
|
Junior Member |
|
|
slebetman@yahoo.com wrote:
> idlwizard-1@yahoo.com wrote:
>> The latest revision of my source code diagramming programs are
>> available at
>>
>> http://www.geocities.com/grunes/diagram.html
>>
>> These programs diagram source code in the following languages:
>>
>> C and C++<br>
>> FORTRAN<br>
>> HTML (very incomplete)<br>
>> IDL, PV-WAVE, GDL and FL
>>
>> They do things like draw lines showing the start and end of routines
>> and blocks, put * next to jumps, and = next to commented out sections,
>> and can warn you of certain classes of error.
>>
>> They can help you find problems in your own code, or help you look at
>> long complicated legacy code other people give you.
>>
>> The programs themselves are in FORTRAN. I know that is a problem for
>> users of other programming languages, but it is freely available as g77
>> or g95 under Cygwin (under Windows) or Linux, and is available on many
>> other platforms.
>
> Well... my favourite text editor already does what your program do and
> does it live while I'm editing code. On top of that it also
> *highlights* the relevant line when the cursor is on either the opening
> or closing brace {}. On top of that it does syntax highlighting. On top
> of that it also allows me to fold sections of code to temporarily hide
> things I'm not interested in (and remember this is "live" while I'm
> editing). And to top it all off it can print, save as RTF save as PDF
> and save as HTML the nicely formatted code along with the nice lines.
> The only difference is that my editor draws lines based on indentation
> while your program auto-indent and draws lines based on braces. But
> that's OK, that's what "indent" is for. Oh and yes my editor supports
> syntax of more than 40 different languages including C/C++, Tcl,
> Fortan, Forth, VB, Perl...
>
May I ask which editor you are using?
|
|
|
Re: Free source code diagramming programs [message #48375 is a reply to message #48304] |
Wed, 12 April 2006 05:53   |
slebetman@yahoo.com
Messages: 1 Registered: April 2006
|
Junior Member |
|
|
idlwizard-1@yahoo.com wrote:
> The latest revision of my source code diagramming programs are
> available at
>
> http://www.geocities.com/grunes/diagram.html
>
> These programs diagram source code in the following languages:
>
> C and C++<br>
> FORTRAN<br>
> HTML (very incomplete)<br>
> IDL, PV-WAVE, GDL and FL
>
> They do things like draw lines showing the start and end of routines
> and blocks, put * next to jumps, and = next to commented out sections,
> and can warn you of certain classes of error.
>
> They can help you find problems in your own code, or help you look at
> long complicated legacy code other people give you.
>
> The programs themselves are in FORTRAN. I know that is a problem for
> users of other programming languages, but it is freely available as g77
> or g95 under Cygwin (under Windows) or Linux, and is available on many
> other platforms.
Well... my favourite text editor already does what your program do and
does it live while I'm editing code. On top of that it also
*highlights* the relevant line when the cursor is on either the opening
or closing brace {}. On top of that it does syntax highlighting. On top
of that it also allows me to fold sections of code to temporarily hide
things I'm not interested in (and remember this is "live" while I'm
editing). And to top it all off it can print, save as RTF save as PDF
and save as HTML the nicely formatted code along with the nice lines.
The only difference is that my editor draws lines based on indentation
while your program auto-indent and draws lines based on braces. But
that's OK, that's what "indent" is for. Oh and yes my editor supports
syntax of more than 40 different languages including C/C++, Tcl,
Fortan, Forth, VB, Perl...
|
|
|
|
|
|
Re: Free source code diagramming programs [message #48430 is a reply to message #48304] |
Fri, 14 April 2006 11:50  |
Al Balmer
Messages: 3 Registered: April 2006
|
Junior Member |
|
|
On 14 Apr 2006 07:40:59 -0700, "mitch grunes" <idlwizard-1@yahoo.com>
wrote:
>> I wouldn't ask a pretty printer to format anything that won't compile.
>> Count your parentheses and braces. Check the definition of strcmp().
>
> You win. My keyboard made minor errors.
>
Darn cheap Chinese keyboards!
> The idea is still the same.
But remains to be demonstrated. In the example given, I could have
corrected the code sufficiently that reformatting was possible (the
unbalanced braces and parens) but you could legitimately claim that
the result wasn't what you intended.
I did, in fact, balance the code and run the beautifier. It left the
comments (which you seemed to be concerned about) in the same relative
position, but the formatting of the last line depended on where I put
the balancing parens.
> When a programmer formats his/her code
> and/or comments carefully, pretty printers destroy it. Here is another
> example, FORTRAN only, in which you have a useful comment table that
> explains things (again, you need a fixed width font).
>
> c variable Initial Value Meaning Permanence
> c --------- ------------- ------------------ ----------
> a = 5 ! Happiness quotient Transitory
> b = 17 ! Unhappiness factor Changeable
> garbage = 3 ! Time differential Irrelevant
> silly = 5.23 ! Semantics Who cares?
> example = 18 ! Meaningfulness A lifetime
> ohmy = 999 ! Wizard of Oz Forever
>
Unfortunately, I don't have a pretty-printer for FORTRAN, but I
believe that indent would process this without destroying the layout.
Perhaps someone else could try it.
> Again, a pretty printer will kill all this extremely useful
> information. If you casually apply a pretty printer to tens of
> thousands of lines of code, and that gets passed on to the next
> benighted programmer, you will lose something he/she will need to
> understand.
>
No, what will happen, in the usual case, is that the program will
become much easier to read, and the maintenance programmer will take
less time and make fewer mistakes.
Been there, done that. For over 30 years.
> Enough.
If you say so.
--
Al Balmer
Sun City, AZ
|
|
|
Re: Free source code diagramming programs [message #48438 is a reply to message #48344] |
Fri, 14 April 2006 07:40  |
idlwizard-1@yahoo.com
Messages: 11 Registered: December 2005
|
Junior Member |
|
|
> I wouldn't ask a pretty printer to format anything that won't compile.
> Count your parentheses and braces. Check the definition of strcmp().
You win. My keyboard made minor errors.
The idea is still the same. When a programmer formats his/her code
and/or comments carefully, pretty printers destroy it. Here is another
example, FORTRAN only, in which you have a useful comment table that
explains things (again, you need a fixed width font).
c variable Initial Value Meaning Permanence
c --------- ------------- ------------------ ----------
a = 5 ! Happiness quotient Transitory
b = 17 ! Unhappiness factor Changeable
garbage = 3 ! Time differential Irrelevant
silly = 5.23 ! Semantics Who cares?
example = 18 ! Meaningfulness A lifetime
ohmy = 999 ! Wizard of Oz Forever
Again, a pretty printer will kill all this extremely useful
information. If you casually apply a pretty printer to tens of
thousands of lines of code, and that gets passed on to the next
benighted programmer, you will lose something he/she will need to
understand.
Enough.
|
|
|