词法分析部分总结.ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
词法分析部分总结 田 聪 构造词法分析器的一般方法和步骤 描述:用正规式对模式进行描述; 构造NFA:为每个正规式构造一个NFA; 确定化:将NFA转换成等价的DFA; 最小化:优化DFA,使其状态数最少; 构造词法分析器:由DFA构造词法分析器(表驱动,直接编码,LEX)。 涉及到的形式化概念 正则表达式(正规式) NFA DFA 正则语言 正则语言 正则语言 正则表达式 有限状态自动机 上下文无关语言 上下文无关文法 非确定的下推自动机 上下文有关语言 上下文有关文法 线性有界自动机(特殊的图灵机) 递归可枚举语言 短语结构 图灵机 Algebraic Laws for RE’s Union and concatenation behave like addition and multiplication. + is commutative (可交换的) and associative (可结合的) a+b=b+a, a+b+c= a+(b+c) concatenation is associative (可结合的) a.b.c=a.(b.c) Concatenation distributes over +(可分配的) a.(b+c)=a.b+a.c Exception: Concatenation is not commutative (可交换的) a.b ≠b.a Identities and Annihilators ? is the identity (单位元) for +. R + ? = R. ε is the identity (单位元) for concatenation. εR = Rε = R. ? is the annihilator (零元) for concatenation. ?R = R? = ?. 正则语言相关内容 如何证明正则表达式和NFA的等价性? (1)We need to show that for every RE, there is an automaton that accepts the same language. (2)And for every automaton, there is a RE defining its language. RE to ε-NFA: Basis Symbol a: ε: RE to ε-NFA: Induction 1 – Union RE to ε-NFA: Induction 2 – Concatenation RE to ε-NFA: Induction 3 – Closure 正则语言相关内容 如何证明正则表达式和NFA的等价性? (1)We need to show that for every RE, there is an automaton that accepts the same language. (2)And for every automaton, there is a RE defining its language. From Automata to RE Arden’s rule For any sets of strings S and T, the equation X=SX+T has X=S*T as a solution. Moreover, this solution is unique if ε not in S. From Automata to RE Given an automaton A A has states {q0, …, qn} with q0 being the start state Let Xi denote the set of strings accepted by A starting in state qi Thus, L(A)=X0 We can write an equation for each Xi, defining it in terms of the sets corresponding to its successor states. From Automata to RE From Automata to RE DFA-to-RE Another approach Page 93, theorem 3.4. (形式语言与自动机) Induction on k-path. Decision Properties of Regular Languages Properties of Language Classes A language class is a set of languages. We have on

文档评论(0)

wuhuaiyu002 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档