Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use python and do not use regular expression libraries Write a program to read from the user a single line ( up to 2 5

Use python and do not use regular expression libraries
Write a program to read from the user a single line (up to 255 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 reservedWords[4][10]={cin>>,for,int,while};
char operator[6][2]={+,-,*,/,++,--}
char special[7][3]={>,=,;,(,),>=,,};
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 identifier. If none of these, display invalid. The program must be case insensitive.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Compute the derivative f(x)=(x-a)(x-b)

Answered: 1 week ago

Question

2. Enrolling employees in courses and programs.

Answered: 1 week ago

Question

1. Communicating courses and programs to employees.

Answered: 1 week ago

Question

6. Testing equipment that will be used in instruction.

Answered: 1 week ago