Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Preferred C++ Develop the following code by your prefered language. 1)Write a program to list the lexemes of the following assign statement ; index =
Preferred C++
Develop the following code by your prefered language. 1)Write a program to list the lexemes of the following assign statement ; index = 8 *count - 10; (assign this statement to a string) Lexemes index 8 count 10 : i n t 0 : 8. cnt++ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ndex 1 The statement will be in a string (str), assume that there is 1 blank between each lexemes. The algorithm; 1. Find the length of the str (In-24) 2. x 0 3. cnt 0 4. loop until the end of the string 5. yestr(x,In-x+1).find("") 6. lex_array(ent] str(x,y-x) 7. Xy+1 9. goto loop 10. display lex_array 2) List the tokens, the output of the program will be as follows Lexemes Tokens index variable equal sign literal math op Count variable math op 10 literal semicolon Use switch-case, control = sign, math signs and ; in separate case, control literal by using a function and any info other than these will be labeled as variable 8 1 3) List the lexemes and tokens of the statement by assuming that there is nospace between eachlexemes. Find the ""sign Label the left side of the equal sign is as variable Find the mathematical signs Between each mathematical sign, the lexeme is a variable or a literal, label them Label the last character asStep 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