Question

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

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

Was it helpful?

Solution

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!

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top