Vadim Zaytsev aka @grammarware

GraSs: A Taxonomy of Grammar Smells


Organisation
global problems
Navigation
problems with navigating through the grammar
Structure
harmful relationships among grammar components

Proxy
indirect uses
Dependency
antipatterns in use
Complexity
metric-based smells

Diamond
A is X and B is X, but C is A or B
Rivalry
overlapping alternatives
Ouroboros
a circular dependency among modules
Soulmates
nonterminals or modules are always changed together
Spillover
a nonterminal that is too linked to the adjacent symbols
Mythic
an alternative that is never exercised in the codebase

Rivalry Edit!

Related smells: Autogenerated Stovepipe, Alternative Classes with Different Interfaces, Repeated Conditionals

Traditionally grammar notations advertised to have a sequence combinator and a choice combinator as the ways to compose complex expressions from atomic symbols (terminals and nonterminals) [BNF]. Modern frameworks are more advanced and versatile, they feature several kinds of negation, conjunction, ordered choices, precede and follow restrictions, etc. However, there is none that explicitly provides an exclusive disjunction combinator [SAC-2012-Zaytsev], even though it was the original intent behind the choice: thus, a statement may be a conditional statement or a print statement, but not both at the same time. There is an entire research domain dedicated to disambiguation of grammars – that is, detecting when something intended as an exclusive choice, leads to several successful parses, only one of which must remain in the final tree [POPL-1973-AhoJU]. This smell is about such situations: it occurs whenever languages of alternative siblings overlap and create an ambiguity. Ambiguity detection and removal techniques can be powerful but not perfect, and the general case is undecidable because it requires decidability of language equivalence.


The GraSs taxonomy is a joint effort maintained by Dr. Vadim Zaytsev a.k.a. @grammarware. Page last updated in March 2021.
XHTML 1.1 CSS 3