How to define whitespace for certain rules but else ignore it I am trying to make a programming language for the first time and wonder how it handles whitespace. I can see CFG by default seem to just ignore whitespaces, but what if I want it to use it sometimes? Like when you declare an int people usually write "int b", and the whitespace separate these two items, but if I write something like "5 + 5" it should ignore the whitespace. Is that simply done by implementing in the rule for declarations like this:

Dcl --> int" " Id

Expr --> "int+int".

This should force a user to write a whitespace between the int and Id, but don't care whether there is a whitespace in the Expr rule. Is this correctly understood?
I think you're approaching this the wrong way. Writing spaces is better handled as a problem of parsing, not of defining your grammar. That is, your grammar should only concern itself with lists of 'tokens' and your parser is concerned with transforming text into 'tokens' properly.

In a sense, whitespace is something the grammar should be completely unaware of. Whitespace can be useful for your parser to determine whether something is one or two tokens, but I doubt that you want to consider whitespace as a token by itself.