flex-lexer - 有人可以在 flex-lexer 中解释 NFA 到 DFA 的转换吗?
问题描述
我有一个非常简单的 test.l 文件,如下所示:
...
%%
[aeiou]+ {printf("aeiou");}
^r {printf("^r");}
%%
...
我使用 flex-2.6.0 从中创建了 lex.yy.c。我跟踪了 flex-2.6.0 的源代码,一切都很好,直到 ntod 函数(在 dfa.c 中)。它主要将NFA状态转换为DFA状态。让我困惑的是:
- sympartition 函数是做什么用的?(根据我的理解,.l 规范创建了三个等价类:aeiou、r、and . for any other. ccltbl 已转换为它们的等价类编号。那么为什么它使用 mkeccl 函数来获取 duplist,以及duplist 用于什么?和 cclng ?你能解释一下 sympartition 的细节吗?)
- 为什么 duplist[sym] == NIL 意味着符号具有唯一的输出过渡?至于symfollowset,我想如果我完全了解sympartition,我就会理解它。
NFA状态如下图:
********** beginning dump of nfa with start state 11
state # 1 257: 0, 0
state # 2 257: 0, 0
state # 3 -1: 4, 0
state # 4 257: 3, 0 [1]
state # 5 257: 1, 3
state # 6 114: 7, 0
state # 7 257: 0, 0 [2]
state # 8 257: 2, 6
state # 9 -2: 10, 0
state # 10 257: 0, 0 [3]
state # 11 257: 5, 9
********** end of dump
解决方案
推荐阅读
- c++ - Lockfree 队列示例泄漏内存
- c# - 运行代码时 ASP.NET 数据无法输出,但在调试模式下显示值
- python - list += 'string' 和 list +=['string'] 的区别
- c++ - CMake 添加 Github 仅标头依赖项作为子模块
- javascript - 在ios中使div不可选择
- javascript - Math.sqrt 和 Math.pow 与 JavaScript 中的 Math.abs 之间的性能差异?
- asp.net-core - 使用 Microsoft Graph SDK 对用户进行身份验证
- next.js - How to use Tailwind CSS with Next.js Image
- c# - 如何在 C# .NET CORE 中使用特定条件自动映射?
- git - 将 repo(不是存储库,android repo)克隆到您自己的帐户