| ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
Description | ||||||||||||||||||||||||||||||||
Halstead metrics for Sdf grammars, taken from: http://mdp.ivv.nasa.gov/halstead_metrics.html http://www.sei.cmu.edu/str/descriptions/halstead_body.html | ||||||||||||||||||||||||||||||||
Synopsis | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
Representation | ||||||||||||||||||||||||||||||||
data HalsteadMetrics | ||||||||||||||||||||||||||||||||
halsteadMetrics :: HalsteadMetrics -> GroupMetric | ||||||||||||||||||||||||||||||||
Creates a uniform representation of the metrics converting the internal HalsteadMetrics record to a GroupMetric type which holds not only all the calculated metric values but also all information about the metrics: description and name. | ||||||||||||||||||||||||||||||||
Function to calculate all metrics | ||||||||||||||||||||||||||||||||
calcHalsteadMetrics :: SDF -> HalsteadMetrics | ||||||||||||||||||||||||||||||||
Calculates all Halstead metrics | ||||||||||||||||||||||||||||||||
Functions to separate Operators and Operands | ||||||||||||||||||||||||||||||||
calcOperatorsAndOperands :: [Production] -> ([Int], [String]) | ||||||||||||||||||||||||||||||||
Calculates all operators and operands from a list of productions. Each operator will be represented by its key (an unique number) and for each operand its value (string) will be used. | ||||||||||||||||||||||||||||||||
sepOperatorsAndOperands :: Production -> [Either Int String] | ||||||||||||||||||||||||||||||||
Separate Operators and Operands from an SDF Production. | ||||||||||||||||||||||||||||||||
sepOaOfromSymb :: Symbol -> [Either Int String] | ||||||||||||||||||||||||||||||||
Separate Operators and Operands of an SDF Symbol by recursively transverse the Symbol data-type. For each operator returns its key (number) and for each operand returns its value. | ||||||||||||||||||||||||||||||||
sepOaOfromLstSymbs :: [Symbol] -> [Either Int String] | ||||||||||||||||||||||||||||||||
Separates the operators and operands from a list of symbols. This function counts the invisible concatenation operator and invokes the sepOaOfromSymb function to traverse the Symbol data type. | ||||||||||||||||||||||||||||||||
Individual metric calculation functions | ||||||||||||||||||||||||||||||||
calcVolume :: Int -> Int -> Float | ||||||||||||||||||||||||||||||||
Calculates the Halstead Program Volume Halstead Program Volume is calculated by the following formula: N * log2 nÊ where
| ||||||||||||||||||||||||||||||||
calcDifficulty :: Int -> Int -> Int -> Float | ||||||||||||||||||||||||||||||||
Calculates the Halstead Program Difficulty Halstead Program Difficulty is calculated by the following formula: (u1 / 2) * (n2 / u2) where
| ||||||||||||||||||||||||||||||||
calcLevel :: Int -> Int -> Int -> Float | ||||||||||||||||||||||||||||||||
Calculates the Halstead Program Level Halstead Program Level is calculated by the following formula: (2 / u1) * (u2 / n2)Ê where
| ||||||||||||||||||||||||||||||||
Auxiliary functions | ||||||||||||||||||||||||||||||||
log2 :: Floating a => a -> a | ||||||||||||||||||||||||||||||||
Helper function that calculates the log2 of a floating point number | ||||||||||||||||||||||||||||||||
Produced by Haddock version 0.6 |