Enumerating Sentences of Context Free Language Based on First One in Order

Enumerating sentences for CFL is often needed in SAQ(specification acquisition system) and some formal proof systems. The current methods are not very efficient and enough. Some of them are limited to deal with specific CFL like regular CFL. First and last sentences of the same length in order can be found by parsing the productions. Then scanning those strings from first sentence to last sentence in order covers all the sentences of the same length. The scanned strings are determined to be outputted or skipped by Earley algorithm. Earley algorithm is modified to judge whether a string is the left subword of some sentences of CFL. Two control strategies, reduction and look-ahead, are adopted in the scanning process. So the number of those scanned strings are decreased greatly. And good time and space efficiencies can be acquired in practice. Compared with other methods, the method shows some advantages by test data.