extendedTransition method

  1. @override
Set<NonDeterministicState> extendedTransition(
  1. NonDeterministicState state,
  2. String input
)
override

Implementation

@override
Set<NonDeterministicState> extendedTransition(
  NonDeterministicState state,
  String input,
) {
  if (input.isEmpty) return {state};
  final possibleNextStates = state.executeTransition(input[0]);
  if (possibleNextStates.isEmpty) return {};
  return possibleNextStates
      .map(
        (nextState) => epsilonClosure(nextState)
            .map(
              (closureState) => extendedTransition(
                closureState,
                input.substring(1),
              ),
            )
            .reduce((a, b) => {...a, ...b}),
      )
      .reduce((a, b) => {...a, ...b});
}