Question
C++ langugae only The first phase of compilation is called scanning or lexical analysis. This phase interprets the input program as a sequence of characters
C++ langugae only
The first phase of compilation is called scanning or lexical analysis. This phase interprets the input program as a sequence of characters and produces a sequence of tokens, which will be used by the parser.
Your job is to write (in C++) a simple scanner for source code that obeys the language described below. You may assume that the input is syntactically correct.
Your program simply needs to read each token and then print out what type it is, based on the following language rules:
keyword -> if | then | else | begin | end | function | return identifier -> character | character identifier integer -> digit | digit integer real -> integer.integer
special -> + | - | = | < | > digit -> 0|1|2|3|4|5|6|7|8|9 character -> a|b|c ... |z|A|B|C ... |Z
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