comp.lang.ada
 help / color / mirror / Atom feed
  • * Re: Lines-Of-Code Utility?
           [not found] <Auij4FgA#GA.64@samson.airnet.net>
           [not found] ` <3642c88c.24407137@news.geccs.gecm.com>
    @ 1998-11-04  0:00 ` Tucker Taft
      1998-11-05  0:00 ` Stephen Leake
      2 siblings, 0 replies; 7+ messages in thread
    From: Tucker Taft @ 1998-11-04  0:00 UTC (permalink / raw)
    
    
    joecool (nobody@nowhere.com) wrote:
    
    : Does anyone know if there is a utility that will run on NT 4.0 that can be
    : run in batch mode to generate a report on the lines of code contained in Ada
    : source files located within a directory tree (that is, it needs to
    : recursively look for Ada source within a dir tree)?  And if so, what is it
    : capable of doing?
    
    See below for an (n)awk script we use.
    
    It counts totally blank lines, lines that consist of only a comment,
    and all other lines.  This corresponds with our definition of 
    line-of-code, which is non-comment, non-blank lines.
    
    If you prefer a count of lines with semicolons, this counts
    those as well, though because things like "if/elsif" and "case" 
    only add one semicolon no matter how long they are, our
    experience is that semicolon counts are not as useful as lines
    of non-comment, non-blank code for sizing development effort.
    
    Of course comments involve some typing effort, but they generally
    pay back in ease of debugging and understanding, so a comment
    line if anything has a negative correlation with development time.
    Similarly, well-placed blank lines can also speed development.
    
    And the usual disclaimer applies that lines-of-code is not
    a great indicator of development effort, though it is
    generally better than nothing!
    
    : Thanks.
    
    : George
    
    --
    -Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
    Intermetrics, Inc.  Burlington, MA  USA
    An AverStar Company
    -----------------------------------------------
    #!/bin/nawk  -f
    
    BEGIN		{
    			tcmnt = 0; tsloc = 0; tblnk = 0; tmloc = 0; files = 0;
    		}
    
    function show(fil,cmnt,sloc,blnk,mloc) { 
    	  printf("\nComment lines: %5d\n", cmnt);
    	  printf("Blank lines:   %5d\n", blnk);
    	  printf("Ada lines:     %5d\n", sloc);
    	  printf("-----------------------\n");
    	  printf("Total lines:   %5d ", cmnt+sloc+blnk);
    	  printf(fil, files);
    	  printf("\n");
    	  printf("      semis:   %5d ", mloc);
    	  printf("\n");
    	  files++;
    	}
    
    FNR == 1	{	if (fil != "") show(fil,cmnt,sloc,blnk,mloc);
    			fil=FILENAME;
    			tcmnt += cmnt; tsloc += sloc; tblnk += blnk; 
    			tmloc += mloc;
    			cmnt = 0; sloc = 0; blnk = 0; mloc = 0;
    		}
    
    /;/		{ mloc++; }
    /^[ \t]*--/	{ cmnt++; next; }
    /^[ \t\r]*$/	{ blnk++; next; }
    /^*$/		{ sloc++; next; }
    
    END		{ 
    			show(fil,cmnt,sloc,blnk,mloc);
    			tcmnt += cmnt; tsloc += sloc; tblnk += blnk;
    			tmloc += mloc;
    			if (files > 1) 
    			    show("Total for %d files",tcmnt,tsloc,tblnk,tmloc);
    		}
    
    
    
    
    ^ permalink raw reply	[flat|nested] 7+ messages in thread
  • * Re: Lines-Of-Code Utility?
           [not found] <Auij4FgA#GA.64@samson.airnet.net>
           [not found] ` <3642c88c.24407137@news.geccs.gecm.com>
      1998-11-04  0:00 ` Tucker Taft
    @ 1998-11-05  0:00 ` Stephen Leake
      2 siblings, 0 replies; 7+ messages in thread
    From: Stephen Leake @ 1998-11-05  0:00 UTC (permalink / raw)
    
    
    "joecool" <nobody@nowhere.com> writes:
    
    > Does anyone know if there is a utility that will run on NT 4.0 that can be
    > run in batch mode to generate a report on the lines of code contained in Ada
    > source files located within a directory tree (that is, it needs to
    > recursively look for Ada source within a dir tree)?  And if so, what is it
    > capable of doing?
    
    I wrote a wrapper for an old "count of Ada statements" program from
    the PAL; it counts all lines, terminal semicolons, and comment lines
    in files listed on the command line. Using the cygwin tools 'find' and
    'xargs', you can count lines in directory trees:
    
    bash$ find . -name "*.ad?" -print | xargs ada_stats
    File name	Statements, Lines, Comments
    ./Ada_Stats/ada_stats.adb	 47, 102, 29
    ./Ada_Stats/character_set.adb	 152, 264, 0
    ./Ada_Stats/character_set.ads	 22, 58, 30
    ./Ada_Stats/count_of_ada_statements.adb	 72, 225, 100
    ./hexdump/Source/hexdump.adb	 78, 140, 9
    ./command_line_io.adb	 38, 110, 8
    ./command_line_io.ads	 11, 74, 39
    ./time_convert.adb	 207, 463, 20
    
    Total files      :  8
    Total statements :  627
    Total lines      :  1436
    Total comments   :  235
    
    Guess I need to allow more space for the file names :).
    
    It does enough parsing to not count semicolons in strings and
    comments. You might be able to enhance it enough to count tokens, as
    Robert Dewar suggests.
    
    Source is too long to post here, but I'd be happy to email on request
    (I _really_ need to get web page at work!).
    
    -- Stephe
    
    
    
    
    ^ permalink raw reply	[flat|nested] 7+ messages in thread

  • end of thread, other threads:[~1998-11-05  0:00 UTC | newest]
    
    Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
    -- links below jump to the message on this page --
         [not found] <Auij4FgA#GA.64@samson.airnet.net>
         [not found] ` <3642c88c.24407137@news.geccs.gecm.com>
    1998-11-02  0:00   ` Lines-Of-Code Utility? joecool
    1998-11-04  0:00     ` dewarr
    1998-11-05  0:00       ` Marc A. Criley
    1998-11-04  0:00     ` dennison
    1998-11-05  0:00     ` Martin C. Carlisle
    1998-11-04  0:00 ` Tucker Taft
    1998-11-05  0:00 ` Stephen Leake
    

    This is a public inbox, see mirroring instructions
    for how to clone and mirror all data and code used for this inbox