World's most popular travel blog for travel bloggers.

# clarification about first for cfg

, ,
Problem Detail:

S-->ABCDE

A-->a/ε

B-->b/ε

C-->c

D-->d/ε

E-->e/ε

i have solved first for above question but a little clarification is required

first(S)=

first(A)=a/ε

first(B)=b/ε

first(C)=c

first(D)=d/ε

first(s)=e/ε

the first for C is c (why is it not c/ε like the rest did i miss something) and i am not able to get proper first value for S can i get some help with explanation

###### Answered By : Vishal Kalwapalli

first for your cfg will be as follows

first(S)=a,b,c

first(A)=a,ε

first(B)=b,ε

first(C)=c

first(D)=d,ε

first(E)=e,ε

here as you see in the S production we have ABCDE and we see first terminal for first of any production but in A ,B we also have ε as a result of which we consider C production ,but C has only terminal so we stop there itself hence first of S is a,b,c and (as only terminal is there for C first(C)=c)

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/56441

3200 people like this

#### Post a Comment

Let us know your responses and feedback