Question: Exercise 9 (Multiple Choice) . Consider the grammar G (note that stands for the empty string): ::= a S | T ::= b T |
Exercise 9 (Multiple Choice). Consider the grammar G (note that stands for the empty string):
- ::= aS | T
- ::= bT | U
- ::= cU |
- Which of the following strings is generated by the grammar G?
- aba
- bab
- (c) ca
(d) ccc
- Which of the following is a derivation of bbc in the grammar G?
- S T U bU bbU bbU bbc
- S bT bbT bbU bbcU bbc
- S T bT bbT bbU bbcU bbc
- S T bT bTbT bbT bbU bbcU bbc
Exercise 10 (Multiple Choice). Which of the following grammars describes the same language as 0m1n where m n?
- S ::= 0S1 |
- S ::= 0S1 | S1 |
- S ::= 0S1 | 0S |
- S ::= SS | 0 | 1 |
Exercise 11. Consider the following grammar for abstract syntax of arithmetic expressions:
E ::= E+E | EE | EE | E/E | 1 | 2 | 3 | 4
with the usual associativity and precedence for the arithmetic operators (all operators are left-associative, and / have a higher precedence than + and ).
(1) Draw an abstract syntax tree for each of the following strings:
- 1 2 + 3
- 1 2 + 3
- 1 2 3/4
(2) (Multiple Choice & Short Answer) Which of the following pairs of strings with different parentheses represent the same abstract syntax tree according to the above precedence and associativity? Draw that abstract syntax tree.
- 2 4 3 versus 2 (4 3)
- 1 + 2 + 3 + 4 versus 1 + (2 + (3 + 4))
- 2 + 3 4/2 versus 2 + ((3 4)/2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
