{"id":31074457,"url":"https://github.com/cs-astronaut/regex-to-automata","last_synced_at":"2026-03-06T02:47:59.496Z","repository":{"id":296107827,"uuid":"977822684","full_name":"CS-Astronaut/Regex-To-Automata","owner":"CS-Astronaut","description":"A Tool for Drawing the DFA/NFA of a Regex for a Regular Language","archived":false,"fork":false,"pushed_at":"2025-05-29T00:59:58.000Z","size":547,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-16T03:01:48.270Z","etag":null,"topics":["automata-theory","dfa","dfa-minimization","finite-automata","formal-languages","nfa","nfa-to-dfa-conversion","powerset-construction","regex-to-automata","regular-expression","thompson-construction"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CS-Astronaut.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-05T02:50:59.000Z","updated_at":"2025-08-07T14:49:33.000Z","dependencies_parsed_at":"2025-05-29T01:59:05.358Z","dependency_job_id":"fd2b95bb-0dee-43da-8ebd-5adeaa5cc642","html_url":"https://github.com/CS-Astronaut/Regex-To-Automata","commit_stats":null,"previous_names":["cs-astronaut/regex-to-automata"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CS-Astronaut/Regex-To-Automata","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CS-Astronaut%2FRegex-To-Automata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CS-Astronaut%2FRegex-To-Automata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CS-Astronaut%2FRegex-To-Automata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CS-Astronaut%2FRegex-To-Automata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CS-Astronaut","download_url":"https://codeload.github.com/CS-Astronaut/Regex-To-Automata/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CS-Astronaut%2FRegex-To-Automata/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30159969,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T22:39:40.138Z","status":"online","status_checked_at":"2026-03-06T02:00:08.268Z","response_time":250,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automata-theory","dfa","dfa-minimization","finite-automata","formal-languages","nfa","nfa-to-dfa-conversion","powerset-construction","regex-to-automata","regular-expression","thompson-construction"],"created_at":"2025-09-16T02:52:37.475Z","updated_at":"2026-03-06T02:47:59.489Z","avatar_url":"https://github.com/CS-Astronaut.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Regular Expression to DFA Converter\n\nThis project implements a tool that converts regular expressions to Finite Automata (DFA \u0026 NFA) with visualization capabilities. It provides a step-by-step conversion process from regular expressions to NFA (Non-deterministic Finite Automaton) and then to DFA, including minimization of the resulting DFA.\n\n## Features\n\n- Regular expression parsing and AST construction\n- Thompson's construction algorithm for converting regex to NFA\n- Subset construction algorithm for converting NFA to DFA\n- Hopcroft's algorithm for DFA minimization\n- Visualization of both NFA and DFA using Graphviz\n- Support for basic regular expression operators:\n  - Concatenation (implicit)\n  - Union (`U`)\n  - Kleene star (`*`)\n  - Parentheses for grouping\n  - Epsilon transitions (`ε`)\n  - Binary alphabet (`0` and `1`)\n\n---\n\n## Requirements\n\n- Python 3.x\n- Graphviz (for visualization)\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/CS-Astronaut/Regex-To-Automata\ncd Regex-To-Automata\n```\n\n2. Install the required Python package:\n```bash\npip install graphviz\n```\n---\n\n## Usage\n\nRun the program:\n```bash\npython main.py\n```\n\nWhen prompted, enter a regular expression using the following syntax:\n- Use `U` for union (e.g., `0U1` for \"0 or 1\")\n- Use `*` for Kleene star (e.g., `0*` for \"zero or more 0s\")\n- Use `ε` for epsilon transitions\n- Use parentheses for grouping (e.g., `(0U1)*`)\n\nThe program will generate two visualization files:\n- `output_nfa.png`: Visual representation of the NFA\n- `output_dfa.png`: Visual representation of the minimized DFA\n\n## Example\n\nInput regular expression: `(0U1)*`\n\nThis will generate:\n1. An NFA using Thompson's construction\n2. A DFA using subset construction\n3. A minimized DFA using Hopcroft's algorithm\n4. Visual representations of both the NFA and DFA\n\n---\n\n## Implementation Details\n\nThe project consists of several key components:\n\n1. **Parser**: Converts regular expressions into an Abstract Syntax Tree (AST)\n2. **Thompson Construction**: Converts AST to NFA\n3. **Subset Construction**: Converts NFA to DFA\n4. **Hopcroft Minimization**: Minimizes the DFA\n5. **Visualization**: Generates visual representations using Graphviz\n\n\n---\n\n## ScreenShots\n\n### Ex1\n`(0U1)*(0(0U1)*0)(0U1)*` = Representing A Language That Contains The Strings With **At least two 0s**\n\n\n\n![DFA for (0U1)*(0(0U1)*0)(0U1)*](/examples/(0U1)*(0(0U1)*0)(0U1)*/output_dfa.png)\n![NFA for (0U1)*(0(0U1)*0)(0U1)*](/examples/(0U1)*(0(0U1)*0)(0U1)*/output_nfa.png)\n\n\n### Ex2\n`(0U1)*1011(0U1)*` = Representing A Language That Contains The Strings With **Substring of 1011**\n\n![DFA for (0U1)*1011(0U1)*](/examples/(0U1)*1011(0U1)*/output_dfa.png)\n![NFA for (0U1)*1011(0U1)*](/examples/(0U1)*1011(0U1)*/output_nfa.png)\n\n### Ex3\n`1*01*01*` = Representing A Language That Contains The Strings With **Exactly two 0s**\n\n![DFA for 1*01*01*](/examples/1*01*01*/output_dfa.png)\n![NFA for 1*01*01*](/examples/1*01*01*/output_nfa.png)\n\n### Ex3 Union Ex2 !\n\n*Also Can Draw The Machine That Accepts The Union Of Two Languages*\n \n`(1*01*01*)U((0U1)*1011(0U1)*)` = Representing A Language That Contains The Strings With **Substring of 1011** or **Exactly two 0s**\n\n\n![DFA for (1*01*01*)U((0U1)*1011(0U1)*)](/examples/(1*01*01*)U((0U1)*1011(0U1)*)/output_dfa.png)\n![NFA for (1*01*01*)U((0U1)*1011(0U1)*)](/examples/(1*01*01*)U((0U1)*1011(0U1)*)/output_nfa.png)\n\n\n---\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcs-astronaut%2Fregex-to-automata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcs-astronaut%2Fregex-to-automata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcs-astronaut%2Fregex-to-automata/lists"}