We propose an evolutionary flow for finite state machine inference through the cooperation of grammatical evolution and a genetic algorithm. This coevolution has two main advantages. First, a high-level description of the target problem is accepted by the flow, being easier and affordable for system designers. Second, the designer does not need to define a training set of input values because it is automatically generated by the genetic algorithm at run time. Our experiments on the sequence recognizer and the vending machine problems obtained the FSM solution in 99.96% and 100% of the optimization runs, respectively.