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

Spaghetti
scattering details over the grammar
Shortage
incompleteness
Mixture
spicing the grammar with alien fragments

Uncluster
related nonterminals too far from one another
Unsequence
confusing order of the production rules
StartInTheMiddle
the root symbol should not occur in the middle

Unsequence Edit!

Related smells: Spaghetti Code

The order of the production rules in the grammar should be set up in a consistent manner, such that referred nonterminals in production rules refer either up or down in the grammar. If Uncluster and Splat are concerned with general placement of production rules, this smell is about how they need to be structured to keep the reading experience optimal.

In the past we have been using a grammar mutation called SubGrammar to improve the readability of grammars extracted from language manuals [SLEIR2014]. It would reorder the rules in the following way: grab the starting symbol (usually the root of the grammar) and list all its production rules, and then go through all nonterminals used in their right hand sides one by one in the same sequence that they occur, add their production rules to the target grammar and add the newly used nonterminals to the backlog. Once the backlog was empty, the mutation stopped. This was one of the possible strategies to get rid of both Splat and Unsequence, and to some extent of Uncluster, but not the only one.


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