GraSs: A Taxonomy of Grammar Smells
Related smells: Subsystem-API Too Large, Long Method, Long Parameter List, Complex Expression, Long Statement, Multiple Operations, Multiple References
This smell is designed to recognise production rules which are too wide – that is, their right hand side is too long. There could be at least three different ways to define what is “too long”:
- The number of consequent terminals is too high, which is harmful because long streaks of consequent terminals obscure the syntactic structure.
- The number of nonterminals is too high, which is harmful because it requires knowledge about referenced nonterminals to debug a grammar (so we should not count preterminals).
- The number of metasymbols (stars, optionals, crosses, separator lists and other combinators) is too high, which is harmful because the importance of knowing the notation is stressed when a grammar engineer needs to understand such a production rule.
The last option also correlates to the omnipresent notion of cyclomatic complexity (covered by the TooRamose smell), because many metasymbols imply branching that is done during parsing or analysing an instance.