Find First and Follow of a Grammar C Program

C Program To Find First and Follow of a Grammar

Learn How To Find First and Follow of a Grammar in C Programming. There are two different C programs to find first and follow of Non Terminals in a given Grammar.

The first of a grammar can be written using structures as well. Here, we have used Array data structure to calculate first and follow in C programming.

Must Read: List of C Programs For Interviews

What is First and Follow?

The First and Follow Sets are used in compiler designing process. The First set is used in LL parsers which are top – down parsers that read or interpret from Left to Right. The Follow set is used in LR parsers which are bottom – up parsers that read or interpret from Left to Right.

The LL parsers use leftmost derivations whereas the LR parsers use rightmost derivations. A predictive parser is constructed using first and follow sets that are associated with Grammar G.

Must Read: C Program For Recursive Descent Parsing


C Program To Find First of a Given Grammar using Array

Output

C Program To Find First and Follow of a Grammar using Array

C Program To Find Follow of a Grammar using Array

Output

C Program To Find Follow of a Grammar using Array

If you have any compilation error or doubts in this First and Follow program in C Language, let us know about it in the comment section below.


Tushar Soni

I am Tushar Soni, Co - Founder of CodingAlpha. I am a computer science student from India and passionate about Web Development and Programming. Connect with me on Facebook | LinkedIn | Google Plus

4 thoughts on “Find First and Follow of a Grammar C Program

  • October 9, 2016 at 4:41 pm
    Permalink

    Bottom-Up and To-Down Parsers uses follow and first functions to make a parsing tree from a given grammar G.

    Reply
  • October 9, 2016 at 5:29 pm
    Permalink

    This code finally works for computation of follow and first for designing my compiler.

    Reply
  • October 9, 2016 at 5:33 pm
    Permalink

    A switch case or a while loop would be much easier to understand. Do while confuses a lot.

    Reply
  • October 9, 2016 at 8:57 pm
    Permalink

    You can also use Extended Backus Naur Form to automatically calculate Follow and First of a Grammar.

    Reply

Join The Discussion