Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with a lexical analyzer (written in Java). The keywords are only if , int , void , return , else , and
I need help with a lexical analyzer (written in Java). The keywords are only if, int ,void, return, else, and while.
Write a lexical analyzer which reads a C- program, strips off comments (denoted by/* comments */), and generates four symbol tablets 1. The KEYWORD table includes all keywords defined in Louden, pp.491). Each keyword is associated with an index. You may combine the special symbols into the KexWord table. You may hardcode them Kevword Else If ndex 2. The INDENTIFIER table includes all the user-defined identifiers. The table is similar to the keyword table except that it contains identifiers. Each identifier has its unique index The NUMBER table includes all integers and floats used in the program. 3. Num 60 3.75 index attribute integer float 4. The TOKEN table includes all the tokens in the order that they are generated. The table should include the following information Token Int Gcd 3.75 For the Regular Grammar for the tokens, refer to the Lexical Conventions of C- (Loudenl). The input to your program is the example in Figure 15 in the handout class index id num 5. including the comments. Your program should strip off the comments 6. The output from the program should include the program with comments stripped off. And all the tables mentioned above 7. Please do file Vo, i.e. read the data from a file and send output to a file Write a lexical analyzer which reads a C- program, strips off comments (denoted by/* comments */), and generates four symbol tablets 1. The KEYWORD table includes all keywords defined in Louden, pp.491). Each keyword is associated with an index. You may combine the special symbols into the KexWord table. You may hardcode them Kevword Else If ndex 2. The INDENTIFIER table includes all the user-defined identifiers. The table is similar to the keyword table except that it contains identifiers. Each identifier has its unique index The NUMBER table includes all integers and floats used in the program. 3. Num 60 3.75 index attribute integer float 4. The TOKEN table includes all the tokens in the order that they are generated. The table should include the following information Token Int Gcd 3.75 For the Regular Grammar for the tokens, refer to the Lexical Conventions of C- (Loudenl). The input to your program is the example in Figure 15 in the handout class index id num 5. including the comments. Your program should strip off the comments 6. The output from the program should include the program with comments stripped off. And all the tables mentioned above 7. Please do file Vo, i.e. read the data from a file and send output to a fileStep 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