factorial test, grammar conversion