飞纯技术
  • 主页
  • 相册
  • 关于我
KEEP IN TOUCH

Posts tagged DFA

how to write lex (6)

四14
2007
4 Comments Written by Filia.Tao

NFA -> DFA
算法是子集构造法.下面是龙书上关于这个算法的描述

initially,ε-closure(s0) is the only state in Dstates and it is unmarked;
while there is an unmarked state T in Dstates do begin
    mark T;
    for each input symbol a do begin
        U := ε-closure(move(T,a));
        if U is not in Dstates then
            add U as an unmarked state to Dstates
        Dtran[T,a] : = U
    end
end

几个很重要的概念:

  • ε-closure  就是当前状态通过ε边可以到达的所有状态的集合
  • 集合的ε-closure  就是集合中所有状态的ε-closure的并集
  • move(T,a) 就是T中所有状态通过a边可以到达的状态的集合

在实现上可以用FIFO队列来模拟Dstates, 那个 marked 不是必须的.
每个状态的ε-closure 可以事先计算好,每次查表即可.
对于转换后的DFA 初态就是ε-closure(s0) , 所有含有NFA终态的DFA状态为终态.
算法中具体操作和使用数据结构有关.

Posted in compiler, lex - Tagged compiler, lex, NFA, ε-closure

授权方式

Creative Commons License
本站作品采用
知识共享署名-非商业性使用-相同方式共享 3.0 许可协议
进行许可。

最近评论

  • carlos 发表在《yacc,ast and graphviz》
  • xiang 发表在《关于我》
  • healthy green tea 发表在《debian 同步系统时间》
  • Filia.Tao 发表在《Kinper – A Kindle Helper Service》
  • pensz 发表在《厦门行简单记录》

My Tweets

RSS My KnowHowSpot

标签

指令 汇编 算法 计算机科学 2008 amazon android ast boto C++ C/C++ compiler Computer design-pattern DFA Django ezengage Firefox github google GSoc http imagedownload iterator javascript jquery kindle kinper lex life Linux locationbar Mix opensource proxy python s3 S5Creator shanghai slide STL vector vista web Web开发

分类

  • ideas (2)
  • job (2)
  • life (2)
  • notes (1)
  • opensource (38)
    • Firefox (17)
    • GSoc (7)
    • Linux (13)
  • project (3)
  • 生活 (3)
  • 编程开发 (67)
    • C/C++ (4)
    • GAE (1)
    • http (2)
    • javascript (24)
    • python (20)
    • Web开发 (12)
    • 端口映射工具的实现 (6)
  • 计算机科学 (23)
    • compiler (17)
      • lex (11)
    • 算法 (5)
  • 随便写写 (67)

文章归档

Blogroll

  • 11′s SKY
  • 86's world
  • Filia’s Summer Of Code
  • limodou的学习记录
  • Loki
  • MyAllBlue
  • perol’s blog
  • Realazy
  • 一个藏袍
  • 人猿星球
  • 冰古Blog
  • 刀枪Blue
  • 懶懶喵日記
  • 桑林志
  • 白菜
  • 车东[Blog^2]
  • 释翼的天空
  • 阿文的自留地

开源网站

  • beagle
  • linuxsir
  • sourceforge
  • 中国Linux 公社
  • 啄木鸟社区

我的项目

  • ezEngage
  • KnowHowSpot

EvoLve theme by Theme4Press  •  Powered by WordPress 飞纯技术