Scanner I, Stubbed Token Routines

Posted January 22
Due at the beginning of your lab period on January 30


Objective

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.

To Do

A Partial, Stubbed Scanner

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. 

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 stream 
  begin
    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.

Notes

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.

Make and CVS

You will be required to use make files (or the equivalent) and cvs as you work on your project.

A Standard Header

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 Program Name

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."

To Turn In

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.