The objective of this assignment to to ensure that you have identified all of the tokens of mPascal and that you have a stubbed routine for each token. These routines will eventually implement the finite state automata that scan for the tokens.
Each team member is to write the stubbed routines as assigned by the team leader.
The team leader is to write a driver that tests that each routine is reachable as well as implement the tokens assigned to him/herself. In this case, the driver will call method get_token, and the routine executed at this point for get_token in the scanner will consist of a simple, single line for each token of mPascal that calls the private routine for that token (no menus, loops, etc. are required).
The various contributed pieces are to be incorporated into a single unit and then compiled and tested.
The source program and the executable program are to be available on esus by the beginning of your next lab. The TA may call upon you to present both your code and execution results at that time.
This stubbed program and driver are to be placed as the first entries in the cvs file associated with your project.
The scanner will be a separate module (i.e., class) in your compiler. As such, it will have a an interface (methods, procedures, and/or functions) to the outside world and an internal structure (perhaps consisting of other classes and objects instantiated from those classes).
The internal structure will include methods for identifying a token from a string of ascii characters. In particular, there is to be a routine for each different token of mPascal.
In preparation for this part of the scanner, your team is to write a stub for each token of mPascal. Each team member is to contribute a certain number of stubs.
A stub is simply a method that can be called, but which does no useful work at this point. For example, for the token identifier, there should be a stub in your programming language similar to
procedure Identifier; -- The token Identifier is matched in the input streambegin Output("Made it to token Identifier"); end;
As the project progresses, the body of the stub will be replaced with the actual routine needed to get the job done. In the scanner, the body will be replaced by a finite state automaton that scans for the identifier, for example.
You should treat identifiers and reserved words (keywords) the same at this point. That is, you need only one stub for identifier that will eventually handle both identifiers and keywords. We will be discussing keyword resolution later.
Please note carefully that there are many different ways to do any programming task. We will often require that you do a task a particular way, even if there may be a better way that you uncover in some instances. There are two reasons for this.
So, be sure to follow the directions carefully.
You will be required to use make files (or the equivalent) and cvs as you work on your project.
The first page of your source code is to have a standard header comment that will be given to you by your TA. Be sure that every program you submit has this standard header comment on the first page.
Your final executable program is to be called mp (for microPascal). One must be able to invoke your compiler with a command line parameter which is the name of the file to be compiled. For example,
mp testfile
should invoke your program and run it on the file "testfile."
Turn in a printed copy of your source code and a page that shows the output of a run of your program. Your source and executable files must also be available on esus.