Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribed

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 file

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

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

6. Give two examples of work sample/simulation tests.

Answered: 1 week ago

Question

Which decisions or plans worked and which ones failed?

Answered: 1 week ago