Date Assigned: Wednesday, June 25, in class
Content last revised: Wednesday, June 25
Due date extended: June 30
In this assignment you use your scanner to implement a recursive-descent parser that parses input conforming to the Toy Grammar.
Following the code outline given in the class notes, design, write, and thoroughly test the four Boolean C Language functions needed to parse the Toy Grammar with panic-mode error recovery.
Each of the four Boolean functions returns TRUE/FALSE according to whether parsing succeeds. If the topmost, root function returns FALSE, panic-mode recovery is used to move the input stream forward until after the next semi-colon, then parsing resumes (until end-of-file is found). The course notes give examples of how to code Boolean functions and panic-mode error recovery.
The four Boolean parsing functions are not part of the lexical analyser; they should be kept in a separate file (the Parser) or bundled into the file that contains main(). No new global variables or data structures are needed for this assignment.
You must enhance your scanner to recognize T_RPAR and T_LPAR left and right parentheses.
Parsing is a silent process. Without debugging statements to tell you what is happening, your Parser would produce no output except error messages.
For this assignment, add a debugging statement to the start of each of the four Boolean recursive-descent parsing functions. The debugging statement indicates the name of the function and the number of times it has been called so far. For the root non-terminal parsing function, also print the lexeme and line number of the first identifier found (the identifier to the left of the '=').
Example: The program output should look something like this, only nicer:
Name: Ian Allen Input file: Assignment Four Data-1.txt Function Calls Line# Identifier ------------------------------------- assignment 1 15 foo expression 1 term 1 factor 1 term 2 factor 2 assignment 2 16 bar expression 2 term 3 factor 3 term 4 factor 4
At the beginning of each Lab period on the dates given above, I will give each Lab section the URL of a different large test input file. You must run the input file against your program and print and hand in one sheet of paper at the end of your Lab time with the following information cut-and-pasted on it:
If you don't know how to cut and paste output from your program into a single file to be printed, please learn how to do this before your Lab starts.
Keep your source code for this assignment (and all assignments this term). I will show you how to deposit your assignment source code into a directory on the Algonquin server when the server is ready. All assignment source code will be collected for analysis later in the term.