Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. (15pt) The scanners identify keywords as identifiers because they fit the definition of an identifier and because it is simpler to first categorize them
2. (15pt) 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: identifier - letter) - letter digit)* letter ab...2 digit 0|1 ...9 keyword if inint That means, Oa 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 comple ments, e.g., a..d for a,b,c,d and #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