"Context-sensitive" has a precise formal definition, and it does not appear to match your intuition. The grammar
S -> P | E
P -> '(' T '.' ')'
E -> '[' T '!' ']'
T -> <any context-free grammar fragment>
is context free (even regular, if T
is regular), despite the fact that what comes after T
(dot/exclamation mark) depends on the first character: There are no "context non-terminals" on the left hand side. Even arbitrary nesting isn't a problem:
S -> A | B
A -> '(' S ')'
B -> '[' S ']'
The parser has to remember which unmatched opening braces it has seen so far, but it does not need context in the sense of context-free/-sensitive grammars. These particular grammars aren't even ambiguous (again a formal term, also used in the Wiki user page you link to). Context free does not mean "parser needs no working memory", or equivalently "parser can be restricted to look at every single token in complete isolation".