Q on CC
Printed From: One Stop GATE
Category: GATE Technical Discussions
Forum Name: GATE CS
Forum Discription: General Technical Discussions, Queries, doubts etc. for GATE in CS.
URL: http://forum.onestopgate.com/forum_posts.asp?TID=531
Printed Date: 25Feb2025 at 7:36pm
Topic: Q on CC
Posted By: balu
Subject: Q on CC
Date Posted: 22Feb2007 at 2:21pm
CS 1992 Q 2 xii. For a context-free grammar, FOLLOW(A) is the set of terminals that can appear immediately to the right of non-terminal A in some "sentential" form. We define two sets LFOLLOW(A) and RFOLLOW(A) by replacing the word "sentential" by "left sentential" and "right most sentential" respectively in the definition of FOLLOW(A).
Which of the following statements is/are true?
(a) FOLLOW(A) and FOLLOW (A) maybe different. (b) FOLLOW(A) and FOLLOW (A) are always the same. (c) Al the three sets are identical. (d) Al the three sets are different.
please explain !
|
Replies:
Posted By: manju
Date Posted: 22Feb2007 at 2:24pm
Consider G as E -> +ET / T T -> *TF / F F -> (E) / id
When we find FOLLOW (E) We apply rules: 1. If it is start smbl, add $ 2. If A -> (alpha) B (beta), add (FIRST of beta) - epsilon 3. If A -> (alpha) OR (alpha) B (beta) with epsilon, add FOLLOW (A)
So, FOLLOW (T) = FIRST (F) = (, id......... rule 2 FOLLOW (T) = FOLLOW (E) = $ .... rule 3
Does rule 2 implies RFOLLOW, while rule 3 implies LFOLLOW?? Coz considering parse tree, rules seem to apply for Left and right sentensial. i.e. in string, like * id id..... , rule 2 gives RFOLLOW set while in strings like + id id, rule 3 gives end of string i.e. LFOLLOW set...
seems confusing... still i think, whtever i wrote is somewhr related... though m nt so sure..
|
|