Assignment 3

CS 152
due November 1, 2000
100 points, plus 10 points EXTRA CREDIT

Redo Assignments 1 and 2, using Ada. You should complete the package specification in the file a3.ads, construct your own package body (preferably using the file name a3.adb), and be able to link both of these to the test procedure in the file a3test.adb. The first and third of these are available from the class web site. You should not need to make changes to the third file. You may define as many other functions, packages, etc., as you want.

You may assume that the input file is all on one line. More precisely, you may assume that there are no end-of-page markers, and no two lexemes are separated solely by an end-of-line marker.

If you cannot get the parse function to read text from a file, you may pass the text itself, as a string, to this function. Expect a deduction if you do this. You should not have to qualify the given file names with path information.

Your output should go to the standard output and not to a file. In the GWU version of Ada, an executable is created whose output can be redirected to a file in the usual way, if necessary.

You may assume a reasonable upper bound on the lengths of terminals and nonterminals.

As in the previous assignments, a parse tree is passed to the traversal functions even if the parse fails, so your parser should construct a dummy tree when the parse fails. You needn't reclaim storage or use exceptions. However, for 10 points extra credit, you may use exceptions to handle a "file not found" error, and to propagate errors in parsing. The former error is signaled in Ada by the raising of a NAME_ERROR exception. If you choose not to handle this exception, then you may simply let the test program crash on the last file without penalty (but without extra credit).