简体   繁体   English

在语法定向定义中检测循环。

[英]Detecting cycles in Syntax Directed Definitions.. Exponential?

I was studying Syntax Directed Definition from the "Compilers: Principles, Techniques and Tools by Aho, Ullman, Sethi and Lam" when I came across the following line in context of circular dependencies of attributes in parse tree: 当我在解析树中属性的循环依存关系的上下文中遇到以下一行时,我正在从“ Aho,Ullman,Sethi和Lam的编译器:原理,技术和工具”中研究语法定向定义:

It is computationally difficult to determine whether or not there exist any circularities in any of the parse trees that a given SDD could have to translate. 在计算上很难确定给定SDD可能必须转换的任何解析树中是否存在任何圆度。 (section: 5.1.2) (第5.1.2节)

Also in http://cs.nyu.edu/courses/fall12/CSCI-GA.2130-001/lecture8.pdf it is mentioned that 同样在http://cs.nyu.edu/courses/fall12/CSCI-GA.2130-001/lecture8.pdf中提到

Detecting cycles has exponential time complexity 检测周期具有指数级的时间复杂度

But there is Tarjan's strongly connected components algorithm that can find cycles in O(E+V). 但是,有Tarjan的强连接组件算法可以在O(E + V)中找到循环。 So why are the above sources contradicting this? 那么,以上来源为何与此矛盾?

Can anyone tell me what I am missing? 谁能告诉我我想念的东西吗?

It's O(E+V) to find a cycle in some parse tree. 在某个解析树中找到一个循环是O(E+V) But that's not the problem. 但这不是问题。 The problem is to 问题是

determine whether or not there exist any circularities in any of the parse trees that a given SDD could have to translate. 确定给定SDD可能必须转换的任何分析树中是否存在任何圆度。 (Emphasis added). (添加了强调)。

That's a rather more difficult problem. 那是一个相当困难的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM