If I have a language with basic things such as
a = expression
if expression then ...
while expression do ...
then I might have a grammar that looks like this: (pseudo code)
assignment: identifier Equals expression ;
if : If expression Then ...
while : While expression Do ...
Now the type of the first expression just needs to be type compatible with 'a' but the other two expressions must be of type boolean.
While it's easy to check the type of an expression everywhere, it seems to me that it would be very convenient to define in the grammar
boolExpression : expression;
and then my other rules would look like this:
assignment: identifier Equals expression ;
if : If boolExpression Then ...
while : While boolExpression Do ...
This would allow me to check that boolExpression returns a BOOL type and so I wouldn't have to add code to test every expression.
But have I turned the context free grammar into a context sensitive grammar by doing this? And if so, does it matter?