Context-free grammar generation algorithms