Question 0-1

Give a BNF grammar describing the set of all strings of brackets for which each left bracket can be matched to a corresponding right bracket to its right. For example, the string ``[[][]]'' should be in this language, but ``][]['' and ``[[]'' would not.

Solution

S -> [ S ] S | empty

Back to Exam 0