|
| Language.Sdf.Metrics.Size | | Portability | portable
| | Stability | experimental
| | Maintainer | Tiago Alves and Joost Visser
|
|
|
|
|
|
| Description |
| Metrics regarding the size of Sdf grammars.
|
|
| Synopsis |
|
|
|
|
| Representation |
|
| data SizeMetrics |
| Data type to hold all metric results | | Constructors | | SizeMetrics | | | term :: Float | Number of unique used non-terminals. | | var :: Float | Number of defined terminals. | | uvar :: Float | Number of used terminals. | | prod :: Float | Number of context-free productions | | mcc :: Float | McCabe cyclomatic complexity. Measures the number of linearly
independent paths through a flow graph. | | avsN :: Float | Average RHS per non-terminal. Calculated by the quotient of size
and var. | | avsP :: Float | Average RHS per production. Calculated by the quotient of size and
prod. |
|
|
|
|
| sizeMetrics :: SizeMetrics -> GroupMetric |
| Creates a uniform representation of the metrics converting the internal
SizeMetrics 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 |
|
| calcSizeMetrics :: SDF -> SizeMetrics |
| Calculates all size metrics |
|
| Individual metric calculation functions |
|
| calcTERM :: [Production] -> Float |
| Calculates the number of unique of terminals used in a list of productions. |
|
| calcVAR :: [Production] -> Float |
| Calculates the number of defined non-terminals in a list of productions |
|
| calcUVar :: [Production] -> Float |
| Calculates the number of unique used non-terminals in a list of production.
This number can differ from calcVAR because a regular expression in a
grammar is used as a non-terminal but is not defined in contex-free syntax. |
|
| calcMCC :: [Production] -> Float |
| Function that calculates the McCabe cyclomatic complexity |
|
| calcMCC1 :: [Production] -> Float |
|
| calcMCC2 :: [Production] -> Float |
|
| calcAvsN :: Float -> Float -> Float |
| Calculates the Average RHS size per defined non-terminal. This value is
computed by dividing the total sum of the RHS (of all rules) by the number
of non-terminals. |
|
| calcAvsP :: Float -> Float -> Float |
| Calculates the Average RHS size per production. This value is computed
by dividing the total sum of the RHS size (of all rules) by the number of
productions. |
|
| calcSize :: [Production] -> Float |
| Calculates the total RHS size of a grammar |
|
| Auxiliary functions |
|
| collectLiterals :: Term a => a -> [Literal] |
| Function that collect all literals of a term. |
|
| getRHSsymbols :: Production -> [Symbol] |
| Function that returns the RHS symbols of a production. This function is
a little more general that getSyms (SdfLib module) because it also returns
the literal from Sdf_prod_fun. It seems that some rules are recognized as
Sdf_prod_fun. |
|
| Produced by Haddock version 0.6 |