Consider the following context-free grammar with terminals {a, b, c, d} and start symbol S.
S → W | X | Y | Z
W → AW D | X | Y | Z
X → BXD | Z
Y → AY C | Z
Z → BZC | ε
A → a
B → b
C → c
D → d
(a) Give a derivation tree with input string: aaaabccddd
(b) What language does this CFG recognize? Give a precise, mathematical definition
Please up vote.
Consider the following context-free grammar with terminals {a, b, c, d} and start symbol S. S...
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)-
2. Consider the following context free grammar with terminals (), +, id, num, and starting symbol S. S (ST) F-id Fnum a. Compute the first and follow set of all non-terminals (use recursion or iteration, show all the steps) Show step-by-step (the parsing tree) how the following program is parsed: (num+num+id)) b.
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...
Given the following grammar with start symbol : ?: ? → b? | a? ? → a? | ε a) Give two strings derived from this grammar and their corresponding derivations. (Please mention the derivation as well).
The following context-free grammar (CFG) generates palindromes. This CFG has the following rules: S → ε, S → a, S → b, ..., S → z, S → aSa, S → bSb, ..., S → zSz. On an example of a palindrome cattac, show, step-by-step, how this palindrome will be generated by this grammar.
2. The following context-free grammar (CFG) has A-productions. S + XY | XYZ X + YXYZ | a | A Y + XZ | ZY | 6 | A Z YZ | XY | X | C Using the algorithm in Chapter 13, find another CFG that generates the same language except for the empty word, and that does not have any A-productions.
Give a Context Free Grammar (CFG) for the following language: L = { w | the number of a’s and the number of b’s in w are equal, ∑= {a, b} }
10 pt) Consider the following grammar where S is the start variable » terminals: x, y, z,t,,* non-terminals: El T, F, V * start symbol: E production rules (a) (4 pt) What is the associativity of the operators+,, * and/ explain why. (b) (3 pt) What is the precedence of , and / explain why (c) (3 pt) Given a parse tree F * T 2 2 Explain how the value of the string is generated
Write a context-free grammar that generates the same language as regular expression which is ab*|c+ (Describe the four components of context-free grammar which are start symbol(S), non-terminals(NT), terminals(T), and set of production rules(P))
1. Consider the following grammar A - aB B-Sb (a) Show a derivation tree for the string aabbbb using the grammar. (b) Give an English description of the language generated by the grammar 2. Let G be the grammar below: S-ASB ab | SS (a) Show that G is ambiguous. (b) Construct an unambiguous grammar equivalent to G. 3. Find a context free grammar for the language L3- fa"b"c+m :n,m21) 4. Find a context free grammar for the language L4...