/// <inheritdoc /> public override IDictionary <char, State> NextStates() { if (this.nextstates == null) { Charset context = this.Context; // we are at the end of the word // look into parent context for continuation IDictionary <char, State> parentStates = this.ContextWordEnd ? context.Parent?.GetInitialState(context)?.NextStates() : null; // if the context can be repeated // look into next character IDictionary <char, State> nextStates = null; int repeatCount = this.RepeatCount + 1; if (repeatCount <= context.MaxRepeatCount) { nextStates = CharsetState.NextStates(this.Char, context, repeatCount); } // combine next and parent states this.nextstates = CompositeState.Merge(nextStates, parentStates); } return(this.nextstates); }
public override IDictionary <char, State> NextStates() { if (this.nextstates == null) { Vocabulary context = this.Context; int repeatCount = this.RepeatCount; IDictionary <char, State> parentStates = null; if (this.ContextWordEnd) { parentStates = context.Parent?.GetInitialState(context)?.NextStates(); } IDictionary <char, State> repeatStates = null; if (this.RepeatWordEnd && repeatCount < context.MaxRepeatCount) { /*if (Vocabulary.Separator != (char)0) * {*/ VocabularyState state = new VocabularyState( Vocabulary.Separator, false, false, 1.0f, 0.0f, false, repeatCount + 1, context, Vocabulary.SeekToBegin); repeatStates = new Dictionary <char, State>(); repeatStates.Add(Vocabulary.Separator, state); /*} * else * { * repeatStates = new VocabularyState( * (char)0, * false, * false, * 0.0f, * 0.0f, * false, * repeatCount + 1, * context, * Vocabulary.SeekToBegin).NextStates(); * }*/ } // if the state does not point to the end // look into next character IDictionary <char, State> nextStates = null; int seek = this.Seek; if (seek != Vocabulary.SeekToEnd) { nextStates = VocabularyState.NextStates(seek, context, repeatCount); } // combine next and parent states this.nextstates = CompositeState.Merge(nextStates, repeatStates, parentStates); } return(this.nextstates); }