code: protected CompactMealy<I, O> parseMealy(Reader reader)
              throws FSMParseException, IOException {
  
          parse(reader);
  
          // create the alphabet
          final Alphabet<I> alphabet;
  
          if (targetInputs != null) {
              alphabet = Alphabets.fromCollection(targetInputs);
          } else {
              alphabet = Alphabets.fromCollection(getInputs());
          }
  
          // create a CompactMealy
          final CompactMealy<I, O> mealy = new CompactMealy<>(alphabet);
  
          // create a mapping states in the FSM source to states in the CompactMealy
          final Map<Integer, Integer> stateMap = new HashMap<>();
  
          // set the initial state
          mealy.setInitialState(stateMap.computeIfAbsent(states.iterator().next(), i -> mealy.addState()));
  
          // iterate over all transitions, add them to the CompactMealy
          getTransitions().entrySet().stream().filter(e -> alphabet.containsSymbol(e.getKey().getSecond())).forEach(e -> {
              final Integer from = stateMap.computeIfAbsent(e.getKey().getFirst(), i -> mealy.addState());
              final Integer to = stateMap.computeIfAbsent(e.getValue().getSecond(), i -> mealy.addState());
  
              final I i = e.getKey().getSecond();
              final O o = e.getValue().getFirst();
  
              mealy.addTransition(from, i, to, o);
          });
  
          // clean our state for next parse call
          states.clear();
          transitions.clear();
  
          return mealy;
      }
docs: Constructs the actual {@link net.automatalib.automata.transducers.MealyMachine}, using {@link #states}, and
  {@link #transitions}.
  
  @return the Mealy machine defined in the FSM source.
  
  @throws FSMParseException (see {@link #parse(Reader)}).
  @throws IOException (see {@link #parse(Reader)}).