Consider the Grammar as follows S → aSAb | bSBc A → +AB | εB → *BC | εC → aC | d What is in FOLLOW(S) {b, c, +, *, $}{a, c, +, *, $}{a, b, d, *, $}{a, b, c, +, $}
Question
Consider the Grammar as follows S → aSAb | bSBc A → +AB | εB → *BC | εC → aC | d What is in FOLLOW(S) {b, c, +, *, }{a, c, +, *, }{a, b, d, *, }{a, b, c, +, }
Solution
The FOLLOW set of a non-terminal symbol in a context-free grammar is the set of terminals that can appear immediately to the right of that non-terminal in some sentential form.
Given the grammar:
S → aSAb | bSBc A → +AB | ε B → *BC | ε C → aC | d
We can calculate FOLLOW(S) as follows:
-
Start with FOLLOW(S) = {$} because S is the start symbol.
-
Look at the production rules.
For S → aSAb, the FOLLOW(S) includes everything in FIRST(Ab) except ε. FIRST(Ab) = {+, ε}, so we add '+' to FOLLOW(S).
For S → bSBc, the FOLLOW(S) includes everything in FIRST(Bc) except ε. FIRST(Bc) = {, ε}, so we add '' to FOLLOW(S).
-
Look at the other production rules where S appears on the right side.
There are no such rules in this grammar, so we don't add anything else to FOLLOW(S).
So, FOLLOW(S) = {$, +, *}.
Similar Questions
Q: 08 of 15Choose the right set of terminals from the given production rules of grammar as:S->(S) | aA | epsilonA-> A+B | aB-> B *C | bC -> cOptions :T= ( ,a,b,),+,*T= ( ,a,b,),+,*,cT= a,b,cNone of the above mentioned
Which representation of grammar corresponds to the a(aUb)*b expression?a)(1) S →→ bMa (2) M →→ eb (3) M →→ abM (4) M →→ baMb)(1) S →→ aMb(2) M →→ e(3) M →→ aMb(4) M →→ bMac)(1) S →→ aMb (2) M →→ e (3) M →→ aM (4) M →→ bMd)(1) S →→ baMab (2) M →→ ea (3) M →→ abM (4) M →→ baMe)(1) S →→ aMb(2) M →→ Mab(3) M →→ aM(4) M →→ bM
Which regular grammar generates the language consisting of strings containing "aba" or "abb"?Options :S -> a | b | aS | bSS -> abS | abbS | εS -> abaS | abbS | εnone
You have a context-free grammar (CFG) defined as follows:S → aSbS → εWhich of the following strings is generated by this CFG?1 point"aabbb""aaabb""ab""bbb"
Consider the Grammar, G, with the production rule: S-> aS | bS | ε Which of the following is generated by G? Options :{a n b m | m,n >=0}{w ∈ {a, b}*, w has equal number of a’s and b’s}{a, b}*{an |n >=0} ∪ {bn |n >=0} ∪ {anbn |n >=0}
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.