开发者

Creating FIRST and FOLLOW sets for all non-terminals

If somebody could help me with the rules of FIRST and FOLLOW sets that would be awesome.

The question is calculate the FOLLOW sets for all of the non-terminals in the following grammar

S ::= S b T a E ¦ a T b ¦ c T a c     R ::= E T ¦ a E

T ::= a c E ¦ epsilon                 E ::= R ¦ T a d ¦ epsilon

I have read the rules of creating follow sets and u开发者_高级运维nderstood the basic examples but I am confused at what I should be doing when I write FIRST(S) for this

any help would be greatly appreciated.


Are you talking about the FIRST1 sets? You simply build a set of all nonterminals, that may be at the beginning of a derivation.

Consider the right-hand side of S: every derivation of S starts with the S, a, c, so FIRST1(S) = FIRST1(S) union {a, c} = {a, c}.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜