Question

In: Computer Science

7. Find the FIRST and FOLLOW sets for the grammar S --> ABC A --> a...

7. Find the FIRST and FOLLOW sets for the grammar
S --> ABC
A --> a | Cb | ε
B --> c | dA | ε
C --> e | f

Construct LL(1) parsing table from grammar

Solutions

Expert Solution

Note:

  • First of any character is defined as set of terminals that begin , in the strings derived from that character.
  • Follow of any character is defined as a set of terminals that appear immediately to the right of that character.

--->ANSWER:

1.FIRST:-

  • First(S)={First(A)-} U {First(B)-} U {First(C)} = { a,c,d,e,f }
  • First(A)={a} U {First(C)} U ={ a,e,f,}
  • First(B) = {c} U {d} U {} ={c,d,}
  • First(C)={e,f}

2.FOLLOW:-

  • Follow(S)={ $ }
  • Follow(A) ={First(B)-} U {First(C)}= { c,d,e,f }
  • Follow(B) = {First(C)} ={e,f}
  • Follow(C) ={b}

LL(1) PARSING TABLE:

  • For productions involving non-epsilon First , the production is written in the cells in the column of the first values.
  • For epsilon productions, the production is written in the cells of the columns of follow of the character deriving that production.
a b c d e f $
S S->ABC S->ABC S->ABC S->ABC S->ABC
A A->a A-> A-> A->Cb , A-> A->Cb
B B->c B->dA B-> B->
C C->e C->f

Hope it helps, for any queries feel free to ask...

Thanks!


Related Solutions

Question 7.  Health researchers adhere to different sets of research methods that follow established paradigms.  In this course...
Question 7.  Health researchers adhere to different sets of research methods that follow established paradigms.  In this course you were introduced to two major health research paradigms : (1) the field of epidemiology, and (2) qualitative research methods.   Briefly argue as to which of these two paradigms is best to foster deeper understandings of the causes, consequences and experiences of diseases.  Justify your opinion. (suggested length, 1 single spaced page).
Consider the context-free grammar G = ( {S}, {a, b}, S, P) where P = {...
Consider the context-free grammar G = ( {S}, {a, b}, S, P) where P = { S -> aaSb | aab }. Construct a NPDA M that such that L(M) = L(G). I would like the transition graph for this NPDA please.
For a grammar G with the productions where G = ( {S, A, B}, {a, b},...
For a grammar G with the productions where G = ( {S, A, B}, {a, b}, S, P ) with productions                                              S --> AB | bbbB,              A --> b | Ab,       B --> a.. 1.Show that the grammar G is ambiguous. 2.Give language L that is generated by G, L = L(G), in a formal expression (including a regular expression). 3.Can you construct an unambiguous grammar that is equivalent to G? Otherwise, show that G is inherently ambiguous.
Let G = (AN , AT , S, P) be a context-free grammar in Chomsky normal...
Let G = (AN , AT , S, P) be a context-free grammar in Chomsky normal form. Prove that if there exists a word w ∈ L(G) generated by a derivation that uses more than |P| + |AT | steps, then L(G) is infinite.
Construct a pda that accepts the language defined by the grammar S → aSSSab | λ...
Construct a pda that accepts the language defined by the grammar S → aSSSab | λ . This has already been answered using software with no explanation. I am not interested in the answer so much. I just want an explanation. or at least a step by step formula.
Homework 7 VOLATILITY 1. Find the mean and standard deviation of returns for stock ABC. Year...
Homework 7 VOLATILITY 1. Find the mean and standard deviation of returns for stock ABC. Year % Return (using logs) 2003 3.45 2004 7.81 2005 8.34 2006 6.21 2007 -8.81 2008 -5.30 2009 2.01 2. Find the expected return and standard deviation of a portfolio which holds $300 in asset A and $700 in asset B. There is a correlation of -0.6 between asset A and B. Asset Expected Return Expected Standard Deviation A 8.3% 12.1% B 4.6% 7.3% 3....
Given a grammar G, G = (Ν, Σ, Π, S), where Ν = { ... }...
Given a grammar G, G = (Ν, Σ, Π, S), where Ν = { ... } Σ = { ... } Π = { ... } S is ... For a string ... write (a) A leftmost derivation (b) A rightmost derivation
ABC Inc.’s first dividend of $2.60 per share is expected to be paid six years from...
ABC Inc.’s first dividend of $2.60 per share is expected to be paid six years from today. From then on, dividends will grow by 10 percent per year for five years. After five years, the growth rate will slow to 5 percent per year in perpetuity. Assume that ABC's required rate of return is 13 percent. What is the price of a share of ABC Inc. today?
convert the following grammar to Chomsky Normal Form S -> D0S1 | 1 D -> F0D1...
convert the following grammar to Chomsky Normal Form S -> D0S1 | 1 D -> F0D1 | 0 | e | FG F -> SF | DD | S G -> GK | DG
can you fix the grammar Issue(s) The laws that were Jeanine broken in this case is...
can you fix the grammar Issue(s) The laws that were Jeanine broken in this case is common law and denying her 14th Amendment liberties finding that a competent person has the Constitutional protection in right grounds in a duty to process cause to refuse hydration and nutrition if so chosen. At this time the lower courts were fine common law of Missouri in Missouri's living will. This court was one of them that had to go to the Supreme Court...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT