/// <summary> /// Creates a new FA that will match a repetition of one or more of the specified FA expression /// </summary> /// <param name="expr">The expression to repeat</param> /// <param name="accept">The symbol to accept</param> /// <returns>A new FA that matches the specified FA one or more times</returns> public static FA Repeat(FA expr, string accept = "") { var result = expr.Clone(); result.FirstAcceptingState.EpsilonTransitions.Add(result); result.FirstAcceptingState.AcceptingSymbol = accept; return(result); }
/// <summary> /// Creates a new FA that matches the specified FA expression or empty /// </summary> /// <param name="expr">The expression to make optional</param> /// <param name="accept">The symbol to accept</param> /// <returns>A new FA that will match the specified expression or empty</returns> public static FA Optional(FA expr, string accept = "") { var result = expr.Clone(); var f = result.FirstAcceptingState; f.AcceptingSymbol = accept; result.EpsilonTransitions.Add(f); return(result); }