<groupId>org.eu.autogex</groupId> <artifactId>autogex</artifactId> <version>1.4.0</version> </dependency>
For a complete overview of all classes and methods, see the Official API documentation.
The easiest way to use Autogex is through the Regex facade. It automatically parses the string, builds the AST, converts to a DFA, and minimizes it.
import org.eu.autogex.regex.Regex;
// Compiles the regex into a theoretical Minimal DFA under the hood
Regex regex = new Regex("(a|b)*abb");
System.out.println(regex.matches("abaabb")); // Output: true
// Export the internal Minimal DFA to Graphviz DOT format for rendering!
String dotGraph = regex.toDotGraph();
System.out.println(dotGraph);
// Export the internal Minimal DFA to Mermaid format for native GitHub Markdown rendering!
String mermaidGraph = regex.toMermaidGraph();
System.out.println(mermaidGraph);
(You can copy the generated dotGraph string and paste it into WebGraphviz to see your state machine!)
For educational purposes or custom needs, you can still manually build and convert models using the Builder pattern.
import org.eu.autogex.models.ENFA;
import org.eu.autogex.algorithms.Converter;
import org.eu.autogex.algorithms.Minimizer;
import org.eu.autogex.models.DFA;
// Building an ENFA that accepts the language: a*b*
ENFA enfa = new ENFA.Builder()
.addState("q0", true)
.addState("q1", true)
.setInitialState("q0")
.addTransition("q0", 'a', "q0")
.addEpsilonTransition("q0", "q1") // Silent transition
.addTransition("q1", 'b', "q1")
.build();
// Convert the ENFA into a minimal DFA
DFA minimalDfa = Minimizer.minimize(Converter.enfaToDfa(enfa));
System.out.println(minimalDfa.accepts("aaabbb")); // Output: true
Autogex is an open-source project maintained with passion. If you find this library useful for your work, studies, or projects, consider supporting its development!
This project is licensed under the MIT License. Feel free to use, study, modify, and distribute this code, even in commercial projects. See the LICENSE for full details.