TITLE: Is this variant of the balanced bracket language context free?
QUESTION [7 upvotes]: Consider the language generated by the following context free grammar: 
$$
S \to SS \quad S \to () \quad S \to (S) \quad S \to [] \quad S \to [S]
$$
There is a one-to-one correspondence between this language and rooted planar trees where each edge is either dashed or solid ([] corresponds to a dashed edge and () corresponds to a solid edge). Call a tree $T$ good if when you remove all the solid edges, the remaining dashed forest is a connected tree where all the vertices have valence $ \leq 2 $ (i.e a path). Let $L$ be the sublanguage consisting of all good trees. 

 Question:  is $L$ context free?

It is easy to check that $L$ satisfies the pumping lemma for context free languages. My instincts tell me that it shouldn't be context free because you can only add square brackets (which correspond to dashed edges) in certain contexts, but I don't know if this intuition can be turned into a proof.

REPLY [4 votes]: As Bjørn says, it is context-free, but I don't think his solution is quite right.  Here's a set of rules I think does work, where $S$ is start and $e$ is the empty word:
$S\to TST$
$T\to(T)$
$T\to TT$
$T\to e$
$S\to(S)$
$S\to U$
$U\to TUT$
$U\to [U]$
$U\to e$
Here, $S$ is the start, and represents any word in $L$.  $T$ represents a tree with only solid lines.  $U$ represents a tree in $L$ whose dashed path begins at the root (the dashed path may be empty).
The part with the $T$'s and the $U$'s is essentially identical to Bjørn's solution; the additional trickery with the $S$'s is to allow the dashed path to begin below the root.