Perform all semantic checks and execute the program

Assignment Help Computer Engineering
Reference no: EM131307260

Program Assignment -

For this assignment we are expanding on assignment 3.  Now that we have parsed input, we will execute the code.

As a reminder, the language has the following rules:

1. An empty string is a semantic error.

2. The language contains only two types: a string and an integer.

3. The language contains only two statements: a print statement, and a set statement.

4. PRINT means evaluate the expression and printing the result on standard out.

5. SET means evaluate the expression and save the value in the variable named ID

6. It is an error to use a variable that has not been set.

7. The addition and multiplication operators associate left-to-right.

8. Addition is defined only between two integers or two strings. String addition is concatenation.

9. Multiplication is defined between two integers or between an integer and a string. Multiplying a string by an integer X repeats the string X times.

10. The language includes a subscripting operator which may have one or two expressions inside the square bracket, separated by a semicolon. Both expressions must evaluate to integers, which are used as indexes into the string (starting, of course, from zero). A single expression results in a string containing the single character at that position. Two expressions results in a substring beginning at the first position and ending at the character before the second position. If either of the expressions would access a character that is not in the string, this will be deemed a runtime error.

11. All other combination of types and operations are undefined.

For this assignment, after parsing you must perform all semantic checks and execute the program. Please note that some of the checks can be performed statically (an empty string constant is an error, and using a variable before setting it is an error), but some can only be performed at run time.

Failing a static check should print an error message and stop execution. Failing a dynamic check should print the string RUNTIME ERROR followed by a description of the error (for example; RUNTIME ERROR types being added are not permitted).

Observe that doing this assignment involves evaluating the parse tree, which is a recursive operation. Defining a virtual eval() function, with different implementations in different classes, is a useful approach. It's also likely that you will need to define some idea of a Type and a Value for this assignment. The eval() function will likely want to return a Value, and will need to test a Type.  

Your program should read the file whose name is passed as a command line argument, or the standard input if no command line argument is provided. You may divide this assignment into as many files as you like. You MUST use p2lex.h from the last assignment, with no changes. You MUST have your lexical analyzer in a separate file.

Attachment:- Assignment.zip

Reference no: EM131307260

Questions Cloud

Find the equation of the line tangent to the curve at : Find the equation of the line tangent to the curve at. Find the equation of the line tangent to the curve at. Let C be the curve given parametrically by. Find an equation for the line tangent to C at the point corresponding to.
Development of a new technology like mobile banking : Work with two other class members in a virtual environment on this exercise. Write a short paper or presentation that summarizes your analysis and opinions of how working virtually helped or hindered your results.
What proportion of total variation in weight can be explain : What proportion of the total variation in the weight can be explained by this model? How about after adjusting for the number of terms in the model.
Calculate number of different combinations for the spheres : There are 3 x 103 spheres in a box. Calculate the number of different combinations for the spheres in order to have 1100 spheres in the front third of the box.
Perform all semantic checks and execute the program : For this assignment, after parsing you must perform all semantic checks and execute the program. Please note that some of the checks can be performed statically (an empty string constant is an error, and using a variable before setting it is an er..
Find the smallest value of k : a linear spring k is to be designed to stop a 20-mg railroad car traveling at 8km/h within 400 mm after impact. Find the smallest value of k that will produce the desired result.
Calculate the delta of the call option : Under which circumstances does the investor make profit? When will the option be exercised? Draw a diagram to show the variation in the investors profit and the share price at the maturity of the option.
Determine the effective moment and vertical shear force : Determine the effective moment and vertical shear force that would be required to replicate the effect of the three bar forces in Problem 1.15.
Review the employee handbook at your place of employment : Review the employee handbook at your place of employment -  Do the company policies articulate a difference in how the company treats workplace injuries as opposed to other disabling injuries (such as non-work related injuries or congenital or inna..

Reviews

len1307260

12/10/2016 3:49:33 AM

I attached 5 files below. DirectionA4.pdf tells you the direction you need to follow. guide.pdf is some information on best way to approach this assignment. p2lex.h and p2lex.cpp are the header and source file for lexical analyzer. These are needed for the assignment. Assignment3code.cpp is the parse tree that was developed in previous project so you can use Assignment3code.cpp as the parse tree to implement this assignment. Please make the code compile, but don't make it look to perfect. This code will be only tested on Linux computer.

Write a Review

Computer Engineering Questions & Answers

  Design a combinational circuit with four input lines

Design a combinational circuit with four input lines that represent a decimal digit in BCD and four output lines that generate the 9's complement of the input digit.

  Do you require leading-edge operating systems

Do you require leading-edge operating systems? Will open-source solutions be acceptable suggestions? Do you require backup software options?

  Explain electrical and computer engineering

Electrical and Computer Engineering, Suppose Xt is a random process which is second-order stationary. Show that it is also stationary of order 1.

  What are three goals of safety in computing?

What are three goals of safety in computing?

  Computer forensics investigation

As a new computer forensics investigator and as a matter of the forensics policy and procedure, you will require to understand the procedures for processing incident scene for the digital and the logical evidence.

  Program to implement the calculations

Write down a program which has a function named presentValue which carry out this calculation. The function must accept future value, annual interest rate, and number of the years as arguments.

  Finding domain name available to company

Use the Internet resources in order to determine which domain name is available to company. Judge if you would use a .com, .org, or .net for the Web address.

  How to write a class template sortablevector

how to Write a class template SortableVector. The class should have a member function that sorts the vector elements in ascending order (your choice of the sorting method).

  Program that convert temperature in fahrenheit

Write a program that will convert a temperature in Fahrenheit to Celsius and Kelvin. The temperature to convert should be captured from user input. The formulas for converting the temperatures are:

  Explain the functions of devices used for data

Explain the functions of devices used for data and signal transform, i.e. how the analog voice is converted to the digital or analog signals.

  Describe virtual and augmented reality

Describe virtual and augmented reality. Suggest a way in which this technology could be used in the future , either to improve a current process / procedure or create a new process / procedure.

  Eurofins scientific is a bioanalytical service provider

Require a Project plan for the project (it doesn't need to be in ms project, word is fine). Including timelines, tasks and constraints. The project is a fictional business and idea that I needed to come up with and make a project plan, please allo..

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