static void _BuildArticleImages() { // this generates the figures used in the code project article // at https://www.codeproject.com/Articles/5251476/How-to-Build-a-Regex-Engine-in-Csharp var litA = CharFA <string> .Literal("ABC", "Accept"); litA.RenderToFile(@"..\..\..\literal.jpg"); var litAa = CharFA <string> .CaseInsensitive(litA, "Accept"); litAa.RenderToFile(@"..\..\..\literal_ci.jpg"); var opt = CharFA <string> .Optional(litA, "Accept"); opt.RenderToFile(@"..\..\..\optional.jpg"); var litB = CharFA <string> .Literal("DEF"); var or = CharFA <string> .Or(new CharFA <string>[] { litA, litB }, "Accept"); or.RenderToFile(@"..\..\..\or.jpg"); var set = CharFA <string> .Set("ABC", "Accept"); set.RenderToFile(@"..\..\..\set.jpg"); var loop = CharFA <string> .Repeat(litA, 1, -1, "Accept"); loop.RenderToFile(@"..\..\..\repeat.jpg"); var concat = CharFA <string> .Concat(new CharFA <string>[] { litA, litB }, "Accept"); concat.RenderToFile(@"..\..\..\concat.jpg"); var foobar = CharFA <string> .Or(new CharFA <string>[] { CharFA <string> .Literal("foo"), CharFA <string> .Literal("bar") }, "Accept"); foobar.RenderToFile(@"..\..\..\foobar_nfa.jpg"); var rfoobar = foobar.Reduce(); rfoobar.RenderToFile(@"..\..\..\foobar.jpg"); var lfoobar = CharFA <string> .Repeat(foobar, 1, -1, "Accept"); lfoobar.RenderToFile(@"..\..\..\foobar_loop_nfa.jpg"); var rlfoobar = lfoobar.Reduce(); rlfoobar.RenderToFile(@"..\..\..\foobar_loop.jpg"); var digits = CharFA <string> .Repeat( CharFA <string> .Set("0123456789"), 1, -1 , "Digits"); var word = CharFA <string> .Repeat( CharFA <string> .Set(new CharRange[] { new CharRange('A', 'Z'), new CharRange('a', 'z') }), 1, -1 , "Word"); var whitespace = CharFA <string> .Repeat( CharFA <string> .Set(" \t\r\n\v\f"), 1, -1 , "Whitespace"); var lexer = CharFA <string> .ToLexer(digits, word, whitespace); lexer.RenderToFile(@"..\..\..\lexer.jpg"); var dopt = new CharFA <string> .DotGraphOptions(); dopt.DebugSourceNfa = lexer; var dlexer = lexer.ToDfa(); dlexer.RenderToFile(@"..\..\..\dlexer.jpg", dopt ); dlexer.RenderToFile(@"..\..\..\dlexer2.jpg"); var dom = RegexExpression.Parse("(ABC|DEF)+"); var fa = dom.ToFA("Accept"); fa.RenderToFile(@"..\..\..\ABCorDEFloop.jpg"); }