Scanner Specifications (Abbreviated)

The specifications for writing the scanner are outlined below.

Background

The background of the specifications is the theory of formal languages and automata that form the foundation of scanning.

Regular Expressions

Teams are given a general description of μPascal and an understanding of what tokens are. They are then required to identify all tokens in μPascal. Next, they are to write a regular expression for each token. Finally, they are given formal specifications for the tokens of μPascal as regular expressions for comparison with the regular expressions they derived. Thus, after making their own attempts, all teams begin coding of the scanner with a standard set of regular expressions for the tokens of μPascal.

Finite State Automata

Teams then review the theory and practice of finite state automata so that they can implement the regular expressions that stand of the tokens of μPascal as finite state automata.

Implementing the Scanner

The Dispatcher

A dispatcher (itself a finite state automaton) is to do the following:

precondition: the source file pointer is either pointing at the first character of the file (when the file is first opened) or is pointing to the first character in the file after the most recently scanned lexeme that matched a token.

The Finite State Automata for Each Token

The specifications for each implemented FSA are the same:

In addition: