The objective of this week's assignment is to ensure that all of the nonterminal routines in your parser are completely fleshed out. The only exception is that you are not expected to have all of the lookahead tokens for the case statements correctly figured out. Many of them will come easy, but some may take a bit more effort. You can include as many lookahead tokens as you want, but expect that some changes might need to be made.
Using the context free grammar available for mPascal on the resources page, flesh out your nonterminal stubs following the routine demonstrated in class.
There should be a case statement that switches on a global lookahead variable.
The case statement should have case clauses for each rule in the grammar that has the nonterminal of this routine on the left, plus one (the "others" clause) for the error condition.
Each routine should have pre- and post-conditions.
Each case clause should be commented with the rule it expands.
In each case clause, the right hand side of the appropriate rule should be expanded: Wherever a token appears, a call to a new routine, Match, must be made with the token as an argument; wherever a nonterminal appears, a call to that nonterminal's routine must be inserted.
In the "others" clause, a call to a new routine, Error, must be made.
You will need to provide stubs for Match and Error as well.
The case selectors must, of course, be of your proper Token_Type, and you will need to insert dummy tokens for now in order to make it possible to compile the stubs. In some cases you may know the proper tokens to make the correct selection. You may insert them at this point. You can change them later if you are wrong.
Without knowing the proper tokens to insert, your nonterminal routines will not actually be able to call other nonterminal routines, so make sure your stubs to not try to execute such calls. One way to do this is to ensure that the dummy value you insert for the lookahead always takes the "others" route, where you can print your message from last time, as in
Expression has not yet been implemented
You will be removing these messages one at a time as you later completely implement these stubs.
Finally, you will need to insert temporarily a series of calls in your parser that calls each of the nonterminal routines, the Match routine, and the Error routine, just to see that the program works to the extent that each routine can be called.
Do not turn in any printed output this time. Have your source and executable files ready to examine on esus, but keep the permissions restricted to your group until you are given directions otherwise.