GATE Computer Science (CS) 2016 Shift 2 Solved Paper
© examsiri.com
Question : 56 of 65
Marks:
+1,
-0
A student wrote two context-free grammars G1 and G2 for generating a single C-like array declaration. The dimension of the array is at least one. For example,
int a[10] [3] ;
The grammars use D as the start symbol, and use six terminal symbols int; id[ ] num
Which of the grammars correctly generate the declaration mentioned above?
int a[10] [3] ;
The grammars use D as the start symbol, and use six terminal symbols int; id[ ] num
|
Grammar G1 |
Grammar G2 |
|
D → int L; |
D → int L; |
|
L → id[E |
L → idE |
|
E → num] |
E → E[num] |
|
E → num][E |
E → [num] |
Which of the grammars correctly generate the declaration mentioned above?
Go to Question: