6. (5 marks) Variables should have names in a program. During the lexical analysis, variable names are converted into identifiers (tokens). The lexical analyzer checks each variable name to see if it follows the rules set up by the language designer. Suppose that a new language designer wants to design variable names according to the following idea.
A variable name can start with only one letter from [a-z,A-Z] or the special character. After that, it should have only one letter from [a-z,A-Z]. After that, it can have any number of letters from [a-z,A-Z] and/or digits from [0-9]. No other special characters should be present.
It is easy to check that the following names are valid: ab2, a,b4,b32, etc., but the following names are not: Z (too short), a%5 (contains another special character %), 3wl (starts with a digit, while the second one is not a letter), 2the (starts with a digit, while the second one is not a letter), etc.
Using the BNF method, describe the rules similar to those discussed in class to implement this idea. One of your rules should be like this:
<Identifier> - ...
For your convenience, you can use the following rules in BNF in your answer:
<Letters> - a|b|...|z|A|B|...|Z
<Digits> - 0|1|...|9