Show that each of the following languages is context-free by giving either a context-free grammar or a stack machine for it. Include an explanation of each grammar or machine. (What is each symbol for? etc)
(a) Balanced sets of matching parentheses and curly braces. Each "(" must match a ")" that comes later and each "{" must match a "}" that comes later.
(b) Words of 0s, 1s, and 2s such that exactly half the characters are 2s and all of them are in the last half of the word. (So all words in the language have even length.)
(c) Invocations of printf with integer variables where the number of format specifications (the %d groups) equals the number of variables passed as arguments. Assume that â—¦ is a terminal denoting a variable, ? is a terminal representing a character not part of an input specification, and that no sizes are given for any of the input specifications (i.e. each input specification is exactly "%d"). For example, the following is a valid word: printf("%d%d? ? ? ? ? ? ?%d??", â—¦, â—¦, â—¦);