Algorithm for computing FIRST and FOLLOW sets for context-free grammars [closed]
Asked Answered
S

2

8

I need an algorithm to computing FIRST and FOLLOW sets for a grammar.

Is there a simple algorithm or simple code for computing these?

Simoniac answered 8/11, 2013 at 21:51 Comment(0)
K
18

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!

Keniakenilworth answered 8/11, 2013 at 21:55 Comment(0)
S
2

This can be solved with Graphical calculation of first and follow sets of a grammar by ASR Murty.

A graphical method has been given to calculate the First and Follow sets of a grammar which is easier to apply for a learner or a student...

This graphical method is applied to the Expression Grammar to find the First and Follow sets and we also check its correctness with the help of derivations.

Stine answered 17/5, 2018 at 15:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.