0% found this document useful (0 votes)
57 views

Counting Standards Ada v1.0

SLOC - Source Lines Of Code is a unit used to measure the size of software program. SLOC counts the program source code based on a certain set of rules. Physical SLOC is corresponding to one line starting with the first character and ending by a carriage return or an end-file marker of the same line.

Uploaded by

Carlos Loa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Counting Standards Ada v1.0

SLOC - Source Lines Of Code is a unit used to measure the size of software program. SLOC counts the program source code based on a certain set of rules. Physical SLOC is corresponding to one line starting with the first character and ending by a carriage return or an end-file marker of the same line.

Uploaded by

Carlos Loa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Ada CodeCount Counting Standard

University of Southern California Center for Systems and Software Engineering July, 2007

Center for Systems and Software Engineering

Revision Sheet
Date
07/25/07

Version
1.0

Revision Description
Original Release

Author
CSSE

Ada CodeCount Coding Standard

Page i

Center for Systems and Software Engineering

1.0

CHECKLIST FOR SOURCE STATEMENT COUNTS


PHYSICAL AND LOGICAL SLOC COUNTING RULES
Order of Precedence 1 Logical SLOC See table below See table below See table below

Measurement Unit Executable lines Non-executable lines Declaration (Data) lines Compiler directives Comments On their own lines Embedded Blank lines

Physical SLOC One per line

Comments Defined in 2.8 Defined in 2.4 Defined in 2.5 Defined in 2.7

2 3

One per line One per line

4 5 6

Not included (NI) NI NI

NI NI NI Defined in 2.6

Table 1 Physical and Logical SLOC Counting Counts

LOGICAL SLOC COUNTING RULES


No. R01 Structure Statements ending by a semicolon Order of Precedence 1 Logical SLOC Rules Count once per statement, including empty statement. Comments Semicolons as part of parameter list in function, procedure, or task entry definition is not counted.

Table 2 Logical SLOC Counting Rules

Ada CodeCount Coding Standard

Page 1

Center for Systems and Software Engineering

2.0

DEFINITIONS

2.1 SLOC Source Lines Of Code is a unit used to measure the size of software program. SLOC counts the program source code based on a certain set of rules. SLOC is a key input for estimating project effort and is also used to calculate productivity and other measurements. 2.2 Physical SLOC One physical SLOC is corresponding to one line starting with the first character and ending by a carriage return or an end-of-file marker of the same line, and which excludes the blank and comment line. 2.3 Logical SLOC Lines of code intended to measure statements, which normally terminate by a semicolon (C/C++, Java, C#, Ada) or a carriage return (VB, Assembly), etc. Logical SLOC are not sensitive to format and style conventions, but they are languagedependent. 2.4 Data declaration line or data line A line that contains declaration of data and used by an assembler or compiler to interpret other elements of the program. The following table lists Ada keywords that denote data declaration lines: program function package task generic body private separate constant type subtype array record access declare renames limited use with new

Table 3 Data Declaration Types

NOTE: See Section 3 of this document for examples of data declaration lines. 2.5 Compiler directive - A statement that tells the compiler how to compile a program, but not what to compile. A list of common Ada directives is presented in the table below: pragma controlled elaborate inline interface list memory_size optimize pack page priority shared storage_unit suppress system_name

Table 4 Compiler Directives

NOTE: See Section 3 of this document for examples of compile directive lines. 2.6 Blank line A physical line of code, which contains any number of white space characters (spaces, tabs, form feed, carriage return, line feed, or their derivatives). 2.7 Comment line A comment is defined as a string of zero or more characters that follow language-specific comment delimiter. Ada comment delimiter is --. A whole comment line may span one or more lines and does not contain any compilable source code. An embedded comment can co-exist with compilable source code on the same physical line.
Ada CodeCount Coding Standard Page 1

Center for Systems and Software Engineering

2.8 Executable line of code - A line that contains software instruction executed during runtime and on which a breakpoint can be set in a debugging tool. An instruction can be stated in a simple or compound form. o An executable line of code may contain the following program control statements: Selection statements (if, case) Iteration statements (loop) Empty statements (one or more ;) Jump statements (return, goto, exit) Expression statements (function calls, procedure calls, assignment statements, operations, etc.) Block statements NOTE: See Section 3 of this document for examples of control statements. o An executable line of code may not contain the following statements: Compiler directives Data declaration (data) lines Whole line comments Blank lines

Ada CodeCount Coding Standard

Page 2

Center for Systems and Software Engineering

3.0

EXAMPLES OF LOGICAL SLOC COUNTING

EXECUTABLE LINES
SELECTION STATEMENTS
ID STATEMENT DESCRIPTION GENERAL FORM SPECIFIC EXAMPLE SLOC COUNT

ESS1

if-elsif-else statements

if <boolean expression> then <statements> end if; if <boolean expression> then <statement> else <statement> end if; if <boolean expression> then <statements> elsif <boolean expression> then <statements> else <statements> end if; NOTE: complexity is not considered, i.e. multiple and or or as part of the expression. case <expression> is when <choice1> => <statements> when <choice2> => <statements> when <choiceN> => <statements> when others => <statements> end case; exception when <exception_choice1> => <statements> when <exception_choice2> => <statements> when others => <statements> end;

if x /= 0 then Put_Line (non-zero); end if; if x > 0 THEN Put_Line (positive); else Put_Line (negative); end if; if x = 0 then Put_Line (zero); elsif x > 0 then Put_Line (positive); else Put_Line (negative); end if; if x /= 0 and x > 0 then Put (x); end if; case number is when 1 | 11 => foo1(); when 2 => foo2(); when 3: => foo3(); when others => Put_Line (invalid); end case; exception when Constraint_Error => Put_Line (range error); when Storage_Error => Put_Line (out of RAM); when others => Put_Line (other error); raise; -- raise exception end;

0 1 1 0 1 0 1 1 0 1 0 1 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 1

ESS2

case statements

ESS3

exception statements

Ada CodeCount Coding Standard

Page 1

Center for Systems and Software Engineering

ITERATIONS STATEMENTS
ID STATEMENT DESCRIPTION GENERAL FORM SPECIFIC EXAMPLE SLOC COUNT

EIS1

simple loop

loop <statements> end loop; while <boolean expression> loop <statements> end loop; for <loop counter> in <range> loop <statements> end loop;

loop null; end loop; while i < 10 loop Put (i); i := i + 1; end loop; for i in 1 .. 5 loop Put (i); end loop;

0 1 1 0 1 1 1 0 1 1

EIS2

while-loop

EIS3

for-loop

JUMP STATEMENTS (ARE COUNTED AS THEY INVOKE ACTION PASS TO THE NEXT STATEMENT)
ID STATEMENT DESCRIPTION GENERAL FORM SPECIFIC EXAMPLE SLOC COUNT

EJS1 EJS2

return goto, label

return <expression>; goto label; <<label>> exit;

EJS3

exit

if i = 0 then return null; end if; <<loop1>> x := x + 1; if (x < y) then goto loop1; end if; loop if x < 0 then exit; end if; end loop; loop exit when x < 0; end if;

0 1 1 0 1 0 1 1 0 0 1 1 1 0 1 1

exit when <boolean expression>;

EXPRESSION STATEMENTS
ID STATEMENT DESCRIPTION GENERAL FORM SPECIFIC EXAMPLE SLOC COUNT

function and <func_name> [( <params> )]; procedure call EES2 assignment <name> := <value>; statement EES3 empty one or more ; in succession statement (is counted as Ada CodeCount Coding Standard it is considered to be a placeholder for something to EES1

Put_Line (name); x := y; a := 1; b := 2; c := 3; ;

1 1 3 1 per each
Page 2

Center for Systems and Software Engineering

BLOCK STATEMENTS
ID STATEMENT DESCRIPTION GENERAL FORM SPECIFIC EXAMPLE SLOC COUNT

EBS1

simple block (related statements treated as a unit) procedure definition

-- start of block begin <statements> end; -- end of block procedure <proc_name> [( <params> )] is <declarations> begin <statements> end [<proc_name>]; function <func_name> [( <params> )] return <ret_type> is <declarations> begin <statements> end [<func_name>]; task body <task_name> is <declarations> begin <statements> end [<task_name>]; package body <pkg_name> is <declarations> begin <statements> end [<pkg_name>];

-- start of block begin Put _Line (Hello); end; -- end of block procedure foo (i : in Integer) is begin Put (i); end foo; function sum (a, b : in Float) return Float is begin return a + b; end sum; task body activity is begin loop exit; end loop; end; package body foo_pkg is begin procedure foo_proc is begin Put_Line(Foo Pkg); end foo_proc; end;

0 0 1 1 0 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 1 0 0 0 0 1 1 1

function definition

task definition

package definition

Ada CodeCount Coding Standard

Page 3

Center for Systems and Software Engineering

DECLARATION (DATA) LINES


ID STATEMENT DESCRIPTION GENERAL FORM SPECIFIC EXAMPLE SLOC COUNT

DDL1

procedure specification function specification task specification package specification

procedure <proc_name> [( <params> )]; function <func_name> [( <params> )] return <ret_type>; task <task_name>; package <pkg_name> is <declarations> end [<pkg_name>];

procedure foo (p : in Integer); function foo return Integer; task action; package foo is procedure foo1 (x : Float ); function foo2 (x : Integer; y : Float ) return Float; end area; type answer is (y, n); subtype digits is Integer range 0 .. 9; type position is record x : Integer; y : Integer; end record; declare amount, price : Float; index : Integer; entry foo;

0 1 1 1 0 1 0 0 1 1 1 0 1 0 0 1 1 1 0 1 1 1

enumeration type definition subtype definition record definition

type <name> is ( <enumeration_list> ); subtype <type_name> is <type> range <discrete_range>; type <name> is record <record structure> end record; declare <name> : <type>; entry <entry_name> [(<params>)];

variable declaration task entry

COMPILER DIRECTIVES
ID STATEMENT DESCRIPTION GENERAL FORM SPECIFIC EXAMPLE SLOC COUNT

CDL1

directive types

pragma <name> [( <params> )];

pragma Export (C, foo, foo);

Ada CodeCount Coding Standard

Page 4

You might also like