Modify the program to detect and report

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

The statements of that expression language consist of an arithmetic expression followed by a list of assignments. Assignments are separated from the expression and each other by commas. A semicolon terminates the expression. The arithmetic expressions are fully parenthesized infix expressions containing integer literals and variables. The valid operators are +, -, *, /. Tokens can be separated by any number of spaces. Variable names begin with an alphabetic character, followed by any number of alphanumeric characters. Variable names are case sensitive. This syntax is described by BNF and regular expressions in the case study.

The program reads in the arithmetic expression and encodes the expression as a binary tree. After the expression has been read in, the variable assignments are read in and the variables and their values of the variables are placed into the symbol table. Finally the expression is evaluated recursively.

Your first task is to complete the program provided by providing the three missing classes,Minus,TimesandDivide.

Next, you should modify the program to detect and report the following error conditions:

Division by zero should be reported as a division error and the program should proceed to the next expression.

Input containing uninitialized variables should be reported as an initialization error and the program should proceed to the next expression.

Variables initialized but never used should be reported as a warning.

Syntax errors including mismatched parentheses, invalid operator, missing comma, semicolon or assignment operator should be reported as a syntax error and the program should proceed to the next expression.

Your final task is to make the following two modifications to the program:

The program should accept input from a file, allowing for multiple expressions arranged one per line.

The Symbol Table class should be modified so that if a variable is assigned multiple values, the last assignment applies.

Reference no: EM13330842

Questions Cloud

In the manufactoring of computer chips cylinders of silicon : In the manufactoring of computer chips, cylinders of silicon are cut into thin wafers that are 3.00 inches in diameter and have a mass of 1.50g of silicon. How thick, in milimeters( mm) is each wafer if silicon has a density of 2.33 g/cm3. The..
Calculate the final velocity of the cars : Two cars collide at an icy intersection and stick together afterward. The first car has a mass of 1600 kg and was approaching at 7.00 m/s due south. Calculate the final velocity of the cars
3 physical chemistry questions : 3 Physical Chemistry Questions
How much farther from this point will the object move : You are watching an object that is moving in SHM. How much farther from this point will the object move before it stops momentarily and then starts to move back to the left
Modify the program to detect and report : Syntax errors including mismatched parentheses, invalid operator, missing comma, semicolon or assignment operator should be reported as a syntax error and the program should proceed to the next expression.
Calculate the concentration of dissolved oxygen at 20 degree : Calculate the concentration of dissolved oxygen at 20 degree Celsius if the amount of dissolved O2 is 9.07 mg/L
Find the stored charge in the capacitor in coulombs : A capacitor of 652. microfarad is charged to 21. volts. Find the stored charge in the capacitor in coulombs
What additional resistance should be added in series : A power supply has an open-circuit voltage of 43.0 V and an internal resistance of 2.00 ?. What additional resistance should be added in series
Why is the temperature 60 instead of 328k : Why is the temperature 60 instead of 328K?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  The two-dimensional array

1. Given the two-dimensional array declared by the following statement int myArray[4][3] = {{2,4,6},{1,8,10},{3,5,7},[9,11,13}}; what is the value of myArray[1][2]

  Write c program which has parent process and child process

Write a C program that has a parent process, a child process, and a grandchild process. The parent process should print its id and the square or 5.

  Contacts class that contains an array

Create a Friend class that contains a first name, last name, a birthday, and a telephone number. Create a Contacts class that contains an array of Friend as well as the owner's name and cell phone Number.

  Longest increasing subsequence problem

Write a computer program to solve the Longest Increasing Subsequence problem.Your program should read input from a text file (one value per line

  Calculates the student * averages and quiz averages based

Calculates the student * averages and quiz averages based upon input from the user. Modify this program to read in the following grade text file, * with a maximum number of students set to 35 and having five quiz scores for each student. The output s..

  A class is derived from another one

In C++, when a class is derived from another one, you can specify the inheritance relationship as public, private or even protected. What are the main differences a between these types of inheritance in C++? How does a public inheritance differ from ..

  Struct complex

A complex number can be represented by two parts, real and image. A series complex data can be organized as a group of elements by linked list, which is shown as below: struct Complex

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Atm system code two classes with related attributes

Related to ATM system code two classes with realted attributes and operations!in C++

  Hypothetical method lock over an object lock

Imagine a hypothetical version of Java where the object lock is replaced by a method lock. Under this system a call to a synchronised method would assign a lock for that method to the calling thread.

  Write an application that reads the user''s weight

Write an application (BMICalc) that reads the user's weight in poinds and height in inches, then calculates the Body Mass Index.

  How nested if-statements replace with one if-statement

Describe how following nested If-statements could be replaced with one if-statement using logical operator (And/Or/Not). Write down the C++ code example.

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