CPS710

Assignment 6

Toronto Metropolitan University University

Error Management

Due: Dec 14


UNDER CONSTRUCTION

Objectives

In this assignment you will add a small amount of error handling to HL, using different strategies..

With this assignment you should become much more familiar with error management in interpreters. The learning objectives covered in this assignment are:

The learning objectives are identified in this description of this assignment.

Solutions to the previous assignments, assignment 4 and 5, will not be provided. You will therefore need to complete the B level objectives of these assignments in order to work on this assignment. You do not, however, need to complete the A level objectives of assignments 4 and 5 to work on the A level objective of this assignment.

Preparation

Assignment

This assignment contains two parts. The runtime errors for 8Ba are implemented in the HLeval visitor and HLObject class and subclasses. The syntax errors for 8Ab are implemented in HL.jjt. In both cases, you will need to also make a few changes to TestHL.java.

These two parts are mostly independent: You can work on 8Ab (and submit it) without doing 8Ba!

8Ba: Runtime errors

Add code to your interpreter to detect and report three run-time errors, each one tested by a different test file. You only need to handle one error in each of the three files that you select.

When you detect a run-time error, you should throw an EvaluationException with a good error message. The error messages that you print should be as specific as possible about the location in the code and problem encountered at that point. In particular any identifier involved in the error should be named.

You will also need to modify the ASTfn_call evaluation visitor to catch and handle EvaluationExceptions in order to reset your activation stack to the global level. You may also need to modify EvaluationException.java. This file was handed out in the assignment 5 to be subclassed to handle return statements, but its main purpose is for this assignment.

The types of errors that can be detected are specified in the test files in the Tests directory. You will notice that the .expected files do not necessarily report any errors for everything, and some report errors that were thrown by JavaCC or by Java. This is how we will know what error handling you have chosen to implement: Unlike in the previous assignments where tests were passed when your program's output was the same as in the test, in this assignment we will run the tests to look for differences in three files each of which should contain at least one appropriate error message.

The test result files were generated from our assignment 5 solution running with the two new files handed out, TestHL.java and ParseAbort.java, before any error handling functionality was introduced into the code. Depending on how you've implemented assignments 4 and 5, your code may generate slightly different outputs. We are aware of that, and this is not an issue: we'll be looking for differences with good run-time error reporting.

It is likely that your error handling code will end up catching more than one error in each of the three types of errors that you choose to handle, but we are only looking for one error for each file.

8Ab: Syntax errors

For this learning objective, you will be implementing a few instances of error recovery for syntax errors.

  1. Read the document: JavaCC: Error Handling.

  2. At the end of HL.jjt, add three new error recovery productions. These productions only match the null string. They also simply print an appropriate error message and increment the ParseError counter.

  3. Now use the productions you have just defined:

    Don't forget to catch all exceptions in the start production to make sure that only ParseAbortExceptions escape the parser.

  4. If you have implemented static scoping, you will also need to modify TestHL to reset your scope stack to the global level before each call to the parser in case parsing was aborted.

  5. You will be asked to submit test files to demonstrate your error recovery strategies. This will be described in the assignment submission section.

References

How to submit assignment 6

If you are submitting only the B level learning objective:

If you are submitting the A level learning objective: (We will test for the B level objectives to see whether you have worked on these as well.)

Assessment Process

Here are the steps we will take to test and assess your assignment:


This page is maintained by Sophie Quigley (cps710@cs.torontomu.ca)
Last modified Saturday, 30-Nov-2024 11:03:42 EST