
6. (5 points) Consider the context free grammar G = (V, E, R, S) where V...
Consider the context-free grammar G = (V, T, S, P) where V = {S}, T = {0, 1, 2, +, *} and with productions S -> S + S | S * S | 0 | 1 | 2 a) Show that the grammar is ambiguous b) Give an equivalent unambiguous grammar.
3 points) Question Three Consider the context-free grammar S >SS+1 SS 1a and the string aa Give a leftmost derivation for the string. 3 points) (4 poiots) (5 points) (3 points) sECTION IWOLAttcmpt.any 3.(or 2) questions from this.scction Suppose we have two tokens: (1) the keyword if, and (2) id-entifiers, which are strings of letters other than if. Show the DFA for these tokens. Give a nightmost derivation for the string. Give a parse tree for the string i) Is...
Ambiguous Grammars Question 3 [10 points be an ambiguous context-free grammar. We know that the length of S Mwis not always the same as the length of S → M w. 15/10] Consider the string abba. Create a context-free grammar that proves this point, and show the 2 different derivations of different length. ·15/10 If a context-free grammar is not LL(1) can it then be LR(1) without changing anything? Explain and/or give an example.
Ambiguous Grammars Question 3 [10 points...
TRUE OR FALSE? (Note: E = belongs to) 1. A context-free grammar G is in Chomsky normal form. Then G is not recursive. 2. Let G be an arbitrary context-free grammar. uAv =>* u'A'v' , where u, v, u' and v' E V* and A E (V - Eps), then L(G) is infinite. 3. {ww : w E {a, b}*} is accepted by some NDPDA with exactly two states
Consider a grammar : S --> a | aS | bSS | SSb | SbS, Where
T={a,b} V={S }.
a. Show that the grammar is ambiguous.
b. What is the language generated by this grammar?
2. (20 points) Consider a grammar: S -->a | aS | SS | Ssb | Sbs, Where T={a,b} V={S}. a. Show that the grammar is ambiguous. b. What is the language generated by this grammar?
6. (20) Let G = (V, ∑, R, S) be a grammar with V = {Q, R, T};
∑ = {q, r,ts}; and the set of rules:
S→Q
Q→q | RqT
R→r | rT | QQr
T→t | S| tT
a. (5) Convert G to a PDA using the method we described.
b. (15) Convert G to Chomsky normal form.
6. (20) Let G = (V, , R, S) be a grammar with V = {Q, R, T}; { =...
Consider the following context-free grammar: E + E +T|T T + TxFF F + (E) | a How many production rules does this grammar have?
Write a python parser program that uses the following context free grammar <S> → ‘a’ <S> ‘b’ <S> → ‘c’ Test your parser with c, acb, aacbb, λ, ca, ab,acbb, aacb, and bca(λ represents a null string)
For the grammar G = (∑, NT, R, S), where ∑ = {a, b, S, A}, NT = {a, b} and R = {s → AA, A → a, A → bA, A→ Ab} Questions 1. Give two (2) different derivations of the string babbab. 2. Is G an ambiguous grammar? Explain your answer.
Consider the grammar G = (V,Σ,R,E) with V = {E,T,F} and Σ = {a,+,∗,(,)}, having the rules E → E+T | T T → T∗F | F F → (E) | a Give leftmost derivations for each of the following: (a) a∗a+a∗a (b) a∗(a+a)∗a