1. Given grammar: E -> E*E | E + E | num and input string num + num *num.
1a.Write 2 possible leftmost derivations from E to the input string.
1b.Draw parse tree for the two leftmost derivation that you wrote above.
1a.
First leftmost derivation :
E -> E * E -> E + E * E -> num + E * E -> num + num * E -> num + num * num
Second Leftmost derivation
E -> E + E -> num + E -> num + E * E -> num + num * E -> num + num * num
1b. Two parse trees for the input string num + num * num are :
Taking E * E production first

Taking E + E production first:
For the grammar <A> ::= <A><A> '+' | <A><A> '*' | 'a' and the string aa + a* Give the leftmost derivation Give the rightmost derivation Give a parse tree Is the grammar ambiguous or unambiguous? (Justify your answer) Describe the language generated by this grammar
Question Set 2 1. Given the following grammar dactor>-> ( <expr> ) a) What is the associativity of each of the operators? What is precedence of the operators? Show a leftmost derivation and parse tree for the following sentence: b) c) A-A(B(C A)) d) Rewrite the BNF grammar above to give precedence over and force to be right associative.
Question Set 2 1. Given the following grammar dactor>-> ( <expr> ) a) What is the associativity of each of the operators? What is precedence of the operators? Show a leftmost derivation and parse tree for the following sentence: b) c) A-A(B(C A)) d) Rewrite the BNF grammar above to give precedence over and force to be right associative.
1. Which of the following statements is true? A. When an input string is being applied with a set of grammar rules, there is one of derivation. B. Based on a different parse tree, an input string may end up with several different derivations if no precedence or associativity rules are applied. C. Parse tree is done in the lexical analysis stage. D. Grammar design is very forgiving. You may write in whatever style you wish. 2. Modern computers are...
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 questions in this section are based on the grammar given as the following: prog -> assign | expr assign -> id = expr expr -> expr + term | expr - term | term term -> factor | factor * term factor -> ( expr ) | id | num id -> A | B | C num -> 0 | 1 | 2 | 3 (2a) What is the associativity of the * operator? (5 points) (2b) What...
Please actually answer it
For both of the following languages, provide a grammar that generates it, an intuitive explanation why this grammar generates this language, and a graphical representation of a push-down automaton that recognizes this language. (a) The language of properly nested sets of parentheses over the alphabet G)). Note that the string (COO))) belongs to this language, while the string (O) () does not because the third closing parenthesis does not have a matching opening parenthesis. Provide a...
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...
Please help me with the coding for LL(1)!!
The given grammar was:
P → PL | L
L → N; | M; | C
N → print E
M → print "W"
W → TW | ε
C → if E {P} | if E {P} else {P}
E → (EOE) | V (note: this has a variable O)
O → + | - | * V → 0 | 1 | 2 | 3 (note: this has a terminal...
The questions in this section are based on the grammar given as the following: prog -> assign | expr assign -> id = expr expr -> expr + term | expr - term | term term -> factor | factor * term factor -> ( expr ) | id | num id -> A | B | C num -> 0 | 1 | 2 | 3 (2a) What is the associativity of the * operator? (5 points) (2b) What...