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?
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
Given the following ambiguous context free grammar (3x20) 1. (a) Explain why the grammar is ambiguous (b) Find an equivalent unambiguous context-free grammar. (c) Give the unique leftmost derivation and derivation tree for the string s generated from the unambiguous grammar above. 2. Construct non-deterministic pushdown automata to accept the following language (20) 3. Convert the following CFG into an cquivalent CFG in Chomsky Normal Form (CNF) (20)-
The following shows a context-free Tammar on {0, 1}. Show that the grammar is ambiguous by generating 2 derivation sequences for word 00111. S > AS5 A → Al|0A101 The following is a context-free grammar on alphabet {a}. Use the string a +a- a to verify whether or not the grammar is ambiguous. AA+AA-AA The following is a gamar equivalent to the one shown above in problem (5). Is it ambiguous? Use a +a- a to verify it. A →...