What does the term context mean in context-free and context-sensitive languages? Can a variable have multiple contexts? If I need to store a particular value in a particular memory address how does does affect the context of the memory address? And if I want to update a variable how does the context of the variable change?
A context-sensitive grammar, productions have the general form
aBc -> ab'c
where upper-case symbols are non-terminals and lower-case symbols are sequences of terminals and non-terminals.
In the above example, a
and b
would be the context of the non-terminal B
and indicate that B
may "expand" to b'
only when surrounded by a
and c
.
In a context free grammar, the production might look like
B -> b'
i.e. B
"expands" to b'
regardless of whatever is around it, in other words, regardless of context.