Question
The scanners identify keywords as identifiers because they fit the definition of an identifier and because it is simpler to first categorize them as identifiers
The scanners identify keywords as identifiers because they fit the definition of an identifier and because it is simpler to first categorize them as identifiers and then look them up to see whether in fact they are keywords. Draw a deterministic finite automaton that recognizes the keywords directly, that is, each keyword will be identified in a separate accepting state, which is different from any state recognizing identifiers. Label each accepting state accordingly. Identifiers and keywords are defined as follows: identif ier (_ | letter)(_ | letter | digit) letter a | b | z digit 0 | 1 | 9 keyword if | in | int That means, 0a is an invalid token whereas int1 and i are identifiers. For simplicity, when labelling transitions, you are allowed to use a notation for ranges and complements, e.g., a..d for a,b,c,d and 6=7 for any character (in our alphabet) different from 7.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started