Ejemplo n.º 1
0
 private void generate(StringBuilder builder, State state) {
   List<Transition> transitions = state.getSortedTransitions(true);
   if (transitions.size() == 0) {
     assert state.isAccept();
     return;
   }
   int nroptions = state.isAccept() ? transitions.size() : transitions.size() - 1;
   int option = XegerUtils.getRandomInt(0, nroptions, random);
   if (state.isAccept() && option == 0) { // 0 is considered stop
     return;
   }
   // Moving on to next transition
   Transition transition = transitions.get(option - (state.isAccept() ? 1 : 0));
   appendChoice(builder, transition);
   generate(builder, transition.getDest());
 }
Ejemplo n.º 2
0
 private void appendChoice(StringBuilder builder, Transition transition) {
   char c = (char) XegerUtils.getRandomInt(transition.getMin(), transition.getMax(), random);
   builder.append(c);
 }