Way back when, I remember someone published a paper on some tools they
had that would automatically improve the expression of the grammar of
a language into a form suitable for a compiler compiler like
yacc/bison.