如何将 NFA/DFA 转换为 java?
我有一个场景,我设计了 NFA 并使用 JFLAP 将其转换为 DFA。
我需要知道如何用Java编写它?
基本上如何在 Java 中实现这些状态转换。我见过一些使用 switch 和 if 语句执行此操作的示例,但我看不到与 DFA/NFA 设计以及如何使用它在 Java 中实现的任何关系。
I have a scenario where I have designed the NFA and using JFLAP I have converted it to DFA.
I need to know, how to code it in Java?
Basically how to implement those state transitions in Java. I have seen some examples which do this using switch and if statements, but I can't see any relation to DFA/NFA design and how to use it to implement in Java.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想在 while(true)switch(state){...} 上使用更面向对象的设计
,那么循环将是
if you want to use a more object oriented design over while(true)switch(state){...}
and then the loop will be
看一下
dk.brics.automaton
:Take a look at
dk.brics.automaton
:虽然你现在已经实现了它,但是有一个非常好的实现,很容易理解。使用有向图来维护 epsilon 转换并使用堆栈来跟踪表达式。查看来自 RS NFA.java 的链接。
Although you would have implemented it by now but there is very good implementation which is easy to digest. Use Digraph to maintain the epsilon transitions and stack to keep track of expressions. Check out this link from RS NFA.java .