(#22363) Improve validation of names and variables
The validation of names and variables was too relaxed. The lexer
had stricter rules in some cases and validation rules for numeric
variables were too relaxed.
Patterns used in validation are now stricter.