JavaScript is required

Cho văn phạm S → A hoặc S-> BCD; A → BBA hoặc A->EB; B → bEc hoặc B->BC hoặc B->BDc ; C → c ; D → a hoặc D-> BDb; E → a hoặc E->bE , Follow(C)=?

A.

{ a,b,c, dollar }

B.

{ b, dollar }

C.

{ c, dollar }

D.

{ dollar }

Trả lời:

Đáp án đúng: A


To find Follow(C), we analyze where C appears on the right-hand side of productions. From S → BCD, Follow(C) includes First(D). First(D) = {a, b} because D → a or D → BDb. From B → BC, Follow(C) includes Follow(B). From B → BDc, Follow(B) contains 'c'. Also, since C → c, First(C) is {c}. Therefore, Follow(C) includes {a, b, c, $} where '$' represents the end of input.

Câu hỏi liên quan