Exemplo n.º 1
0
        static void Main(string[] args)
        {
            NFA nfa;

            if (!Console.IsInputRedirected)
            {
                Console.Error.Write("Usage: NFA2DFA.exe < 'inputNFA.txt'");
                return;
            }

            List <String> input = new List <String>();
            string        line;

            while ((line = Console.ReadLine()) != null)
            {
//DEBUG INPUT               Console.Out.Write(line + "\n");
                input.Add(line);
            }
            nfa = new NFA(input);

            nfa.NFAtoDFA();

            //  DEBUG for Breakpoint to hold console open
            if (false)
            {
                Console.Error.Write("Potato");
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            int    counter = 0;
            string line;

            // Read the file and display it line by line.

            string path = "binary2.nfa";
            //System.IO.StreamReader file = new System.IO.StreamReader(args[0]);
            //List<Node> Nodes = fill_nodes(args[0]);
            List <Node> Nodes = fill_nodes(path);

            System.IO.StreamReader file = new System.IO.StreamReader(path);

            while ((line = file.ReadLine()) != null)
            {
                var lines = line.Split(new string[] { "->" }, StringSplitOptions.None);
                if (lines.Count() == 1)
                {
                    continue;
                }
                Edge e = new Edge(lines[1].Split('|').ToList(), Nodes.Find(x => x.Name == (get_text_inside_brackets(lines[2]).StartsWith("_") ? get_text_inside_brackets(lines[2]).Substring(1) : get_text_inside_brackets(lines[2]))));

                string node_name = (lines[0].StartsWith("_") ? lines[0].Substring(1) : get_text_inside_brackets(lines[0]));
                if (Nodes.Find(x => x.Name == node_name).EdgeL == null)
                {
                    Nodes.Find(x => x.Name == node_name).EdgeL = e;
                }
                else
                {
                    Nodes.Find(x => x.Name == node_name).EdgeR = e;
                }

                counter++;
            }

            file.Close();
            System.Console.WriteLine("There were {0} lines.", counter);
            // Suspend the screen.
            System.Console.ReadLine();

            var nfa = new NFA(Nodes[0]);

            nfa.Chars.Add("0");
            nfa.Chars.Add("1");
            nfa.MoveSet();
            Console.ReadKey();
            var dfa = nfa.ToDFA(null);

            nfa.TIKZLatex();
            Console.ReadKey();
        }