Design state transition diagram (finite automata) for the following
1. Key words (else, while, begin, main, switch, struct)
2. Identifiers
3. Integers
4. White spaces
5. Phone number
6. Email address
7. Unsigned numbers
The idea is fairly simple for all of these DFA. We need to know the constraints for each of these.
1. Keywords should be exactly the same. If they are lowercase it should be lowercase in the checking of the DFA as well.
2. Identifiers are variable names. We can start an identifier name with underscore or letter but not a number. we can then include a number though.
3. Integers are whole numbers that do not contain a decimal point , If any decimal is represented it goes into the trap state.
4. White spaces are easy to identify it should just be plain whitespace, anything else and it goes into trap state.
5. Phone number of 10 digit has been represented. Each should be a digit between 0-9 anything else is an invalid phone number.
6. Email id's should be of the format [email protected] numbers,letters underscores can be included.
7. Unsinged numbers are those that are not negative .Unsigned integer number has been represented if a decimal number needs to be represented we can add a dot and loop over the rest part again.
Get Answers For Free
Most questions answered within 1 hours.