Program - Implements a calculator of C integer expressions

Assignment Help Programming Languages
Reference no: EM131710931

Project - Topic: Cexpr Programming Assignment

Your assignment is to write a program using yacc (bison) and lex (flex) that implements a calculator of C integer expressions. The calculator will process expressions until it encounters EOF or invalid syntax. Each calculation is terminated by a semicolon. Tokens can be separated by whitespace (but no comments). After each calculation, the calculator prints its result. Tokens include integer numbers and 26 predefined integer variables. There will be one variable corresponding to each of the lowercase letters in the alphabet. The table below defines the C operators you need to implement. The operators are listed in order of decreasing precedence.

Yacc (bison) does provide mechanisms for specifying the associativity and precedence of operators in an unambiguous grammar. However, you are not allowed to use these mechanisms. Instead you should define extra non-terminals and productions to enforce the specified associativity and precedence for this assignment.

Rather than having a default value of zero for each of the predefined variables, you will treat the default variable as having an unknown value. If a variable's value is referenced without ever having been assigned a value, then the value of the expression should be designated as unknown. A variable's value becomes unknown when it is assigned an unknown value.

In addition to calculating an expression, two other commands are supported. The first is to dump the values of the different variables when the keyword dump is detected. The second is to reset all of the values of the different variables to unknown when the keyword reset is encountered.

You need to create files called cexpr.y, scan.l and makefile that will contain the parser, scanner and makefile. The makefile should make an executable called cexpr.exe. You should submit a single zip (tar) file that includes these three files, to Canvas project link.

The reference executable (cexpr.exe) is placed in ~uh/cop4020/proj4/cexpr.exe for your info.

Attachment:- Assignment File.rar

Reference no: EM131710931

Questions Cloud

Explain in perfect competitive environment : Define short run. Explain in perfect competitive environment Try to use mathematical expressions Fixed cost for perfect competitive firms is straight
Dominant players in respective industries : Both Walmart and Apple are dominant players in their respective industries. What are the implications of this for their supply chains?
Describe the difference between power and influence : Describe the difference between power and influence. Describe the different types of power.
Write an essay about something you believe after reading : Write your own 2-3 page essay, about something you believe after reading 3 of the essays.
Program - Implements a calculator of C integer expressions : COP4020 Project - Topic: Cexpr Programming Assignment. Your assignment is to write a program using yacc (bison) and lex (flex) that implements a calculator
Context and competencies of the team effectively : How do high-performing teams manage context and competencies of the team effectively? Break down and explain each.
Discuss how could a speaker prepare for questions : instructor told them they had to ask a question to get a full grade for the assignment. How could a speaker prepare for questions
Discuss about the international bill of human rights : And do we need to adopt an "International Bill of Human Rights," as Coleman also suggests, in response to global challenges posed by workplace monitoring?
Name four interoperability issues : Name four interoperability issues where the patient's orders and their processing in the hospital was not managed well by healthcare

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a program for a furniture company

Write a program for a furniture company that determines the price of a table. Ask the user to choose 1 for pine, 2 for oak, or 3 for mahogany. The output is the name of the wood chosen as well as the price of the table

  Program to compute unit price of items sold

Manager of a Supermarket would like to be able to calculate the unit price of items sold there. To do this the program should input the name and the price of the item.

  Set fs script before processing records

Set FS script before processing records. This is also a good place to set up an array of month names in chronological order - you want to try sorting the catagory section.

  Implement a program that processes an input file

Implement a program that processes an input file by changing every occurrence of an old string into a new string. (e.g., the usage is: chstr.pl file oldstring newstring, chstr.pl is your program name, file, oldstring and newstring are parameters ..

  What is the standard terminal symbol for a flowchart

What might be considered the seventh step of the programming process?

  Create program that allow user to input a list of first name

Create a program that allows the user to input a list of first names into one array and last names into a parallel array. Input should be terminated when the user enters a sentinel character.

  Generate code for the given three address statements

Generate code for the following three-address statements assuming stack allocation where register SP points to the top of the stack.

  Create program to randomly access data on stocks

A small mutual company wishes you to create program to randomly access data on stocks it holds. Presently, data are stored in a text file, each line of which contains following: a stock code.

  Create a java application named distancecalculator1

Create a Java application named DistanceCalculator1.java to solve the following problem. An application is needed to allow a user to enter two cities and display the distances between them.

  Program to calculate integer part of quotient

Calculate the integer part of the quotient when integer a is divided by integer. Calculate the integer remainder when integer a is divided by integer b

  Output of the given program

Output of the given program - using namespace std - g^x = h mod p, find x. ex: 7^x = 15 mod 41, x = 3

  Create logic for program-continously prompts for numeric

Create the logic for a program that continously prompts the user for two numeric values that represent the sides of a rectangle.

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