Question 1: (a) Indicate for every sentence listed below whether it can be gener
ID: 3715374 • Letter: Q
Question
Question 1: (a) Indicate for every sentence listed below whether it can be generated by the given BNF grammar, or not. No explanations are needed. (1 mark) abcd Yes No acccbd Yes No acccd Yes No acd : Yes/ No (b) Write BNF rules to define simple assignments in C++, which may cascade Valid examples are: a-1; men=0; b-c; x-y-z. Assume the non-terminals for numeric constants and for variables are defined. (2 marks) (c) Consider the BNF grammar below for (part of) the English language. Draw two parse trees to show that the sentence "I shot an elephant in my pyjamas" has two possible interpretations, and that the grammar is ambiguous. Rephrase the sentence twice (in English) to make each interpretation clear. (4 marks) -> 'a' 'an 'my elephant'pyjamas' ->'s shot >'n' nside' 1/2Explanation / Answer
1) (a)- YES --
(b) NO -- BECAUSE AFTER b ONE c must come
(c)YES
(d)NO- At least 2 c will come 1 b or 1 c comes after a. -- due to <S> c
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.