Detect more invalid grammars. Fixes #5.