How to generate CFG for this language?
$ L = \{ w \mid w \in \{ (, [, ], ) \}^* \text{ s.t. } $
- In any prefix of $w$, no. of ( is more than no. of ), and
- no. of [ is more than no. of ].
$\}$
Thus, ([(), [()[] etc. are valid.
I have tried,
$ S \to (S \mid (S)S \mid [S \mid [S]S \mid \epsilon $
But, this does not accept, ([)].
It seems possible to do with two stacks, by keeping counts of ( and [. Thus it seems it is not Context Free. Any help in proving it is not CF or a CFG exists?