How can we find out First and follow in compiler design?

1 answer

Answer

1001299

2026-03-26 04:50

+ Follow

first:

1. If first character of production is terminal then becomes first.

eg. first(abAb)={a};

2.If a production of this type A->BCD...

means all are variable or non-terminal then

if first(B) donot contains null then

first(A)=first(B)

stop here.

else

then also check for next non terminal like C here

same as above step

and first(A)=First(B)+first(C).

if we get null stop there.

FOLLOW:

if you know first then you can easily go with follow.

1.if a variable is start symbol then follow=$.

2.if a production is of A->(any string1)B(any string2)

then

follow(B)=first(any string2) -{null}

3.if a production is of A->(any string)B

then

follow(B)=follow(A) .

stop

it is very simple, please try to understand!

really good answer, for more visit:www.cmail.99k.org

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.