UNDER CONSTRUCTION!

Preliminaries

two exceptions that can be used to abort parsing,which are meant to be thrown by the parser and caught by TestHL.

a mechanism to support error recovery up to a certain point using the
constant MAXERRORS and two static methods ResetErrors() and IncreaseErrors().
MAXERRORS describes the maximum number of attempted error recoveries.
You should modify this constant to test your work.

Replace your TestHL.java file by
this one
which will catch exceptions, print them out, and recover from them.
You will need to modify this file to add code to reset your scope and activation stacks.

Description

This bonus part contains two parts that can be done in any order.
The runtime errors are implemented in the eval visitor and the
parsing errors are implemented in HL.jjt.

Runtime errors

Add code to your interpreter to detect and report run-time errors.
The errors that need to be detected will be specified in the
test files.

Parsing errors

// ErrorReplace production called when string was interpreted as string.
void ErrorReplace(String parsed, String expected) throws ParseAbortException
// ErrorMissing production called when the token was missing
void ErrorMissing(String skipped) throws ParseAbortException

and one error recovery method to be used in catch clauses:

// ErrorSkipto called to consume all tokens up to the first one of kind
// The error message in is also printed.
void ErrorSkipto(int stoptoken, Error e) throws ParseAbortException
void ErrorSkipto(int stoptoken, Exception e) throws ParseAbortException

(The 2 separate definitions are needed to handle lexical errors which are errors
and parse errors which are exceptions).

Use ErrorReplace and ErrorMissing at least 3 times each in your parser to perform
some shallow error recovery.

Use ErrorSkipto at least 4 times in your parser to perform some deep error recovery.
Don't forget to catch all errors and exceptions, including scanning errors, in the start
production to make sure that only ParseAbortExceptions escape the parser.

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

You do not have to have exactly the same error messages as in the results
but you should catch the same errors and output approriate messages.

The test files show the worth of each error in a comment.
Altogether these tests add up to 71 marks, but part1 is only worth 50 marks,
so you can get full marks for part 1 without catching all errors in the tests.

For part2, we will

Run the test file you submit and grade it along with your directions on your marking sheet.

Change MAXERRORS to a different smaller value and rerun your file to make sure that
your parser stops when it reaches MAXERRORS.

How to submit the bonus part of assignment 3

Prepare a test file called testerror.hl which contains 2 statements
or expressions (i.e the start production should be called twice).
Each of these 2 statements (or expressions) should contain 5 of the
10 errors for which you have implemented some error recovery.
Altogether this should demonstrate your 10 error recoveries as
described in the Parsing Errors section of this assignment.

Zip up together all your source files and makefile and testerror.hl into A3B.zip.
Be sure to preserve the correct hierarchical structure of files when you
zip everything up. Our makefile uses the default: everything in one directory
except that all jjtree-generated files are in the AST subdirectory.

Fill out, and submit the marking sheet (
word format
or
pdf format
) in the D2l submission "folder called Assignment 3 marking sheets".
Note that this marking sheet asks you to list the error recovery strategies that you
implemented. We cannot grade this assignment without it.