Programming Assignment #4

Due: March 26

Description:

Write a recursive decent parser in Java for the following grammar:

expr -> term + expr | term - expr | term * expr | term / expr | term
term -> number | (expr)
number -> digit | digit number
digit -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

The name of the .java file with the main method must be P04. The lexical analyzer must read from the command line. For instance, the program will be tested by executing against text files like the following:

c:\>java P04 < in.txt

where in.txt is a text file that contains legal or illegal sentances in the grammar.


Deliverables:

The commented .java files.

Grading: (80 points possible)

Bonus 20 points if it works with the following error messages: