Computer Sciences > Gate 2016 Set-2 > CFG
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.
Grammar G1
D → int L;
L → id [E
E → num]
E → num] [E
Grammar G2
D → int L;
L → id E
E → E[num]
E → [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
D → int L;
L → id [E
E → num]
E → num] [E
Grammar G2
D → int L;
L → id E
E → E[num]
E → [num]
Which of the grammars correctly generate the declaration mentioned above?
Correct : CFG
Similar Questions
In the context of abstract-syntax-tree (AST) and control-flow-graph (CFG), which one of the following is True?
For any two languages L1 and L2 such that L1 is context free and L2 is recursively enumerable but not recursive, which of the following is/are necessarily true?...
Consider the following languages:
L1= {anbmcn+m : m, n >= 1}
L2= {anbnc2n : n >= 1}
Which one of the following is TRUE?
Total Unique Visitors
Loading......