用于上下文无关文法的FIRST和FOLLOW集的计算算法 [英] Algorithm for computing FIRST and FOLLOW sets for context-free grammars

查看:164
本文介绍了用于上下文无关文法的FIRST和FOLLOW集的计算算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种算法来为语法计算FIRST和FOLLOW集.

是否有用于计算这些的简单算法或简单代码?

解决方案

大多数编译器教科书和有关解析算法的书中都讨论了用于计算FIRST和FOLLOW集的标准算法.如果您上的课程涵盖了这一主题,并且没有指定的阅读材料或与此主题相关的材料,我会感到惊讶.

我教了一个有关编译器构造的课程,并提供了一些讲座幻灯片,在这里可能会有用.您可能想查看幻灯片303-这些幻灯片中有304张关于LL解析,用于计算FIRST集和 解决方案

The standard algorithm for computing FIRST and FOLLOW sets is discussed in most compiler textbooks and books on parsing algorithms. I would be surprised if you were taking a course where this was covered and had no assigned reading or materials provided on this topic.

I taught a class on compiler construction and have some lecture slides that might be useful here. You might want to check out slides 303-304 of these slides on LL parsing for an algorithm that computes FIRST sets and slide 32 of these slides on LL parsing for an algorithm that computes FOLLOW sets.

Hope this helps!

这篇关于用于上下文无关文法的FIRST和FOLLOW集的计算算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆