FormeleMethode/ThompsonConstruction.cs
/// <summary>
/// Ones the specified reg exp.
/// </summary>
/// <param name="regExp">The reg exp.</param>
/// <param name="automaat">The automaat.</param>
/// <param name="stateCounter">The state counter.</param>
/// <param name="leftState">State of the left.</param>
/// <param name="rightState">State of the right.</param>
Ones the specified reg exp.
Ones the specified reg exp .
public static void One(RegExpression regExp, ref Automata<string> automaat, ref int stateCounter, int leftState, int rightState)
		{
			char[] characters = regExp.terminals.ToCharArray();
			if (characters.Length == 1)
			{
				automaat.AddTransition(
					new Transition<string>(leftState.ToString(), characters[0], rightState.ToString()));
			}
			else
			{
				automaat.AddTransition(
					new Transition<string>(leftState.ToString(), characters[0], stateCounter.ToString()));
				int i = 1;
				while (i < characters.Length - 1)
				{
					automaat.AddTransition(new Transition<string>(stateCounter.ToString(), characters[i],
						(stateCounter + 1).ToString()));
					stateCounter++;
					i++;
				}
				automaat.AddTransition(
					new Transition<string>(stateCounter.ToString(), characters[i], rightState.ToString()));
				stateCounter++;
			}
		}
public static void One ( RegExpression regExp , ref Automata < string > automaat , ref int stateCounter , int leftState , int rightState ) { char [ ] characters = regExp . terminals . ToCharArray ( ) ; if ( characters . Length == 1 ) { automaat . AddTransition ( new Transition < string > ( leftState . ToString ( ) , characters [ 0 ] , rightState . ToString ( ) ) ) ; } else { automaat . AddTransition ( new Transition < string > ( leftState . ToString ( ) , characters [ 0 ] , stateCounter . ToString ( ) ) ) ; int i = 1 ; while ( i < characters . Length - 1 ) { automaat . AddTransition ( new Transition < string > ( stateCounter . ToString ( ) , characters [ i ] , ( stateCounter + 1 ) . ToString ( ) ) ) ; stateCounter ++ ; i ++ ; } automaat . AddTransition ( new Transition < string > ( stateCounter . ToString ( ) , characters [ i ] , rightState . ToString ( ) ) ) ; stateCounter ++ ; } }
Ones the specified reg exp.
Ones the specified reg exp .
// Create 1 letter transition // Create transition for multiple letters
regExp
RegExpression
The reg exp.
The reg exp .
Automata<string>
ref
int
ref
leftState
int
State of the left.
State of the left .
rightState
int
State of the right.
State of the right .
automaat
None
stateCounter
The state counter.
The state counter .