Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program to read from the user a single line ( up to 2 5 5 characters ) at a time and splits the
Write a program to read from the user a single line up to characters at a time and splits the line into lexemes, if possible. The program will determine whether each lexeme is a reserved word, an arithmetic operator, a special symbol, a number, or an identifier. The following arrays are already given:
char reservedWordcinforintwhile;
char operator
char specialSymbol;;
A number is an unsigned integer or a signed integer.
An identifier starts with a letter or followed by any number of letters, and digits, and excludes any reserved word.
For each lexeme check whether it is a reserved word. If not, check whether it is a special symbol. If not, check whether it is a number. If not, check whether it is an operator. If not, check whether it is an identifier. If none of these, display invalid The program must be case insensitive. Save it as ProgSample IO:
Enter a statement:
Enter a statement: int ; while cin myTime ;;
int reserved word
identifier
special symbol
number
; special symbol
while reserved word
special symbol
identifier
invalid
number
special symbol
special symbol
cin reserved word
myTime identifier
; special symbol
identifier
operator
; special symbol
special symbol
CONTINUE
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