简体   繁体   English

计算FOLLOW()还是传播?

[英]Calculating FOLLOW() or propagate?

I am a little confused regarding the lookaheads computation for LALR(1) parsers. 对于LALR(1)解析器的超前计算,我有些困惑。

In the book "Parsing Techniques - A Practical Guide" they state that propagating lookaheads (+ spontaneous generated lookaheads) is equivalent to calculating the FOLLOW() for variables. 在《解析技术-实践指南》一书中,他们指出传播先行(+自发生成的先行)等同于计算变量的FOLLOW()。 So why LALR(1) parser (according to the Dragon book) uses the propagate/spontaneous technique at all, if it could do with FIRST() and FOLLOW(), which are simple and straightforward to compute? 那么,为什么LALR(1)解析器(根据《龙书》)完全使用传播/自发技术,如果它可以与FIRST()和FOLLOW()一起使用的话,它们就很容易计算了呢?

If this is not the case, what is the difference between the two techniques? 如果不是这种情况,两种技术之间有什么区别?

Found a very good explanation at Design and Construction of Compilers 编译器的设计和构建中找到了很好的解释
In a nutshell, the lookahead set in LALR(1) is only a subset of FOLLOW(). 简而言之,在LALR(1)中设置的超前行为只是FOLLOW()的子集。 And it is computed by the propagate technique. 它是通过传播技术计算的。

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

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