FormeleMethode/Automata.cs
/// <summary>
/// Check if S is accepted in the language
/// </summary>
/// <param name="s">The s.</param>
/// <returns></returns>
Check if S is accepted in the language
Check if S is accepted in the language
public bool Accept(string s, bool printTransitions = false)
		{
			char[] charArray = s.ToCharArray();
			foreach (T startState in startStates)
			{
				T currentState = startState;
				if(printTransitions)
					Console.WriteLine($"Start State : {currentState}  \nString : {s}");
				CharEnumerator c = s.GetEnumerator();
				while (c.MoveNext())
				{
					Transition<T> transition = new Transition<T>(currentState, c.Current);
					currentState = GetMatchingState(transition, printTransitions);
					if (currentState == null)
						break;
				}
				if (currentState == null)
					continue;
				return endStates.Contains(currentState);
			}
			return false;
		}
public bool Accept ( string s , bool printTransitions = false ) { char [ ] charArray = s . ToCharArray ( ) ; foreach ( T startState in startStates ) { T currentState = startState ; if ( printTransitions ) Console . WriteLine ( $" Start State :  { currentState } \n String :  { s } " ) ; CharEnumerator c = s . GetEnumerator ( ) ; while ( c . MoveNext ( ) ) { Transition < T > transition = new Transition < T > ( currentState , c . Current ) ; currentState = GetMatchingState ( transition , printTransitions ) ; if ( currentState == null ) break ; } if ( currentState == null ) continue ; return endStates . Contains ( currentState ) ; } return false ; }
Check if S is accepted in the language
Check if S is accepted in the language
// Try for all startStates // Check all chars // search for matching transition with fromState = currenState && symbol = c.Current // Move to next startState // If the last char in given string is a final state -> true else -> false // if there was no match found string is invalid
None
s
string
None
printTransitions
bool