(a0Give the derivations and parse trees for the following strings using the grammar given below:
• abba • babab
(b)
Give the derivations and parse trees for the following strings using the grammar given below:
• a cat napped • a cat barked
P={
<sentence> → <article><noun><verb>
<article> → "a"
<article> → "the"
<noun → "dog"
<noun> → "cat"
<verb> → "barked"
<verb> → "napped"
}



(a0Give the derivations and parse trees for the following strings using the grammar given below: •...
IN HASKELL Consider a context-free grammar with nonterminal symbols: sentence (the start symbol), noun-phrase, verb-phrase, article, noun, and verb; terminal symbols: "." (period), "a", "the", "girl", "dog", "sees", and "pets"; and the following rules: sentence = noun-phrase verb-phrase "." . noun-phrase = article noun . article = "a" | "the" . noun = "girl" | "dog" . verb-phrase = verb noun-phrase . verb = "sees" | "pets" . a. Give a left-most derivation of the sentence: a girl pets the...
Given the grammar defined in Figure below, give all the parse
trees of a0 + a1 + b.
Given the grammar defined in Figure below, give all the parse trees of a0 + a1 + b.
3. Using the grammar below, show a parse tree and a leftmost derivation for the statement. A = ( A + (B)) * C assign <idxpr expr>? <expr> <term> term <term factor factor (<expr>) l <term I <factor l <id> 4. Prove that the following grammar is ambiguous (Give sentence that has two parse trees, and show the parse trees):
For the grammar and each of the strings, give the parse
tree.
Exercise 5.1.2: The following grammar generates the language of regulair expression 0'1(0 1): SA1B * а) 00101. Ь) 1001. с) 00011.
Write a grammar for English sentences using the following words (only) time, arrow, banana, flies, like, a, an, the, fruit and the semicolon. Be sure to include all the senses (noun, verb, etc.) of each word, and the basic sentence parts like subject, predicate, etc. Then show that this grammar is ambiguous by exhibiting more than one parse tree for "time flies like an arrow; fruit flies like a banana."
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).
Show that the following grammar is ambiguous. Hint: Show two different leftmost or rightmost derivations for the same string. Equivalently, you can show two different parse trees for the same string. <expr> ::= <expr> + <expr> | <expr> - <expr> | <expr> * <expr> | <expr> / <expr> | int int ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Using this grammar show that ambiguity is not acceptable...
Homework. Section 5.1 #m}. Hint: Think of this language 1. Design a context-free grammar for the language {a" b n as the union of {a"b" | n > m} and {a") n<m}. 2. Consider the context-free grammar G = (N,T, P, S), defined by N = {S}, T = {a,b), and P = {S + Sbs | bSaS | }. Find derivations, and corresponding parse trees, for the following strings: aaabbb, bbbaaa, ababab. What is L(G)?
) Using the following grammar, show a parse tree and a leftmost derivation for the following sentence (make sure you do not omit parentheses in your derivation): Grammar <assign> → <id> = <expr> <id> → A | B | C <expr> → <expr> + <term> | <term> <term> → <term> * <factor> | <factor> <factor> → (<expr>) | <id> Derive C = (A+B)*(C+A)*(C+B)
Consider the following grammar: S → A1B A → 0A |ϵ B → 0B | 1B |ϵ Give parse trees for each of the strings: a. 00101 b. 1001 c. 00011