Write a lexical analyzer which reads a c- program

Assignment Help C/C++ Programming
Reference no: EM13944937

Program Assignment

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 KeyWord table. You may hardcode them.

Keyword

Index

Else

1

If

2

int

3

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.

3. The NUMBER table includes all integers and floats used in the program.

Num

index

attribute

60

1

integer

3.75

2

float

4. The TOKEN table includes all the tokens in the order that they are generated. The table should include the following information:

Token

class

index

Int

kw

3

Gcd

id

1

3.75

num

2

5. For the Regular Grammar for the tokens, refer to the Lexical Conventions of C- (Louden1). The input to your program is the example in Louden3 including the comments. Your program should strips 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 i/o, i.e. read the data from a file and send output to a file.

Reference no: EM13944937

Questions Cloud

Which car will she buy in order to maximize her utility : The BMW that she wants sells for $37,220, while the Mitsubishi sells for $28,200. She can afford either car. Which car will she buy in order to maximize her utility?
About the retirement goal : Your retirement goal is to save $400,000 by the time you are 65 years old. You have been saving $926.65 per year for the last 30 years, and you will retire in 5 years (at age 65). The interest rate has just changed from 12% (which has been the level ..
What is the cost of equity for the corporation : The expected return on the market is 12%. The risk-free rate is 3.5%. The corporation has a current stock price of $65. There are 15 million shares outstanding. The beta for the stock is 1.6. What is the cost of equity for the corporation? What is bo..
What is the stock value : A company has an issue of preferred stock outstanding that pays an annual dividend of $6.20. If the discount rate for the stock is 11%, what is the stock's value
Write a lexical analyzer which reads a c- program : Write a lexical analyzer which reads a C- program, strips off comments (denoted by /* comments */), and generates four symbol tablets.
Download a shareware version of some commercial software. : Download a shareware version of some commercial software. Design a plan for converting the shareware version to a full version without paying one cent.
Perform a two-sided hypothesis test : Is the sample evidence sufficient to conclude which suburb spends more? To answer this question,perform a two-sided hypothesis test at  = .05. State the alternative and null hypotheses, computethe observed significance level (p-value), and state t..
What is the company cost of new equity : Riverhawk Store (RS) dividends have been growing at 3 percent annually and are expected to continue this growth rate indefinitely. The company recently paid a dividend of $1.25 per share. Next year, it expects to add $3 million to retained earnings. ..
Determine the break-even point : A company has estimated fixed costs of $150,000 and estimated variable costs of $25 per unit. It is projected that 4,000 units will be sold at a selling price of $50 per unit. Determine the break-even point

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Calculate the cube of a number

Write a program that will calculate the cube of a number. Do this by writing a user defined function that returns the cube of the value passed to it. Print out the results from main.

  How do you generate arrays, random numbers

How do you generate arrays, random numbers and multiply and add rows, columns and diagonals in C

  Create a funcion called max

Create a funcion called max().

  Calculates the sum of the cube roots of two integers.

Wrtie a program that calculates the sum of the cube roots of two integers. The program should use the following functions as well as a main funcion. 1) enter one positive value 2) compute the cube root of one integer 3) report the value of two intege..

  Implementation of the recursive algorithm

Develop an iterative method having the same functionality as the recursive nextPermutation method - Create a class SortingFunctions.

  Write a class volumeofbox that calculate the volume

write a class VolumeOfBox that calculate the volume by this formula : length * breadth *

  To deal with deadlocks we can either use prevention or

to deal with deadlocks we can either use prevention or avoidance or detection followed by recovery. but which is a

  The program will read integers values

Write a C++ program to do the following. The program will read integers values one at a time from standard input (cin) until you read the value 150. assume that the number of values read in is at least 1 and less than or equal to 100

  Deal two cards at a time

Deal two cards at a time, print them out.- Check if they are identical, have just the same rank or just same suit or are completely.different. Print out a message indicating the result of your comparison.

  Program that calculates how much a person earns in a month

Write a program that calculates how much a person earns in a month if the salary is one penny the first day, two pennies the second day, four pennies the third day,

  Person class that includes fields for last name

Create a Person class that includes fields for last name, first name, and zip code. Include a default constructor that initializes last name, first name, and zip code to "X" if no arguments are supplied. Also include a display function. Write a ma..

  Determine the letter grade associated with the average

Create a loop structure to display and calculate the factorial of the larger number provided by the user - What if these were test scores? Calculate the average of the two numbers provided.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd