Assignment 2: A Table Driven Scanner (Due: Th, April 10)
Write a program which is a table-driven scanner for programs written in the L756
language. The scanner should use the following methods.
NXTLN() – reads a line from the input stream and prints it out.
NXTCHAR() – returns the next character in the current line.
ERROR() – prints the string ”ERROR”.
SCANTOKEN() – returns (TYPE,VALUE). That is, the internal
representation of the next token in the input stream and its associated
information, respectively. When encountering an improper character,
SCANTOKEN should call ERROR and then continue while disregarding
the improper character.
LOOKID(STR) – returns through an index to where in the symbol table
the identifier STR is contained (if the identifier is not in the table, it is
inserted there).
LOOKINT(STR) – returns a pointer to where in the integer table the
integer STR is contained (if the integer is not in the table, it is inserted
there.)
The main program should:
Repeatedly call SCANTOKEN until the token END is encountered.
For each call to SCANTOKEN, print the returned values.
The input to your scanner can be any L756 program that provides a good testing
data for the scanner.