In addition to the assignment specifications listed on
the
homepage, you are expected to implement some
syntax error recovery technique. Depending on
your skill level and confidence, you have two choices.
Option 1: Panic Mode
These are safe symbols ];})
Upon encountering a syntax error, your program
should find the next safe symbol and continue
processing as if no error occurred. Print the line
in which the error occurs in red.
Also you should print the message
"Syntax Error -- Line %d" to stderr whenever you
encounter a syntax erro. This
recovery technique is required at the very least.
Example:
1 if (x < y) {
2 out.println(x * x * y 2 );
3 }
Your program should print to stderr
Sytax Error -- Line 2
Line 2 should be printed in red
Option 2: Phase Level Recovery
Augment the safe symbol set above to consider
contexts in which the parse error is found.
By knowing where the error occured, it is
possible to recover from errors quicker and
more efficiently. This is extra credit. If
you implement this technique, include a seperate
file in your turnin called "PHASE_OPTION.TXT." In
that file, describe what you implemented and give
a list of test cases in which your implementation
improves performance. Extra credit points will be
assigned based on depth and usefuleness to parser
as determined by the TA. Generally speaking, adding
different safe symbols to many different contexts is
desired.
Using the previous example, one may note that expression
sometimes contain typos, and safe points in expressions
may be operators.
Refer to Programming Language Pragmatics(57-60)
for further information.