Lab1 – assigned in week 1, due in week 5
Considering a small programming language (a mini-language), you have to write a scanner (lexical analyzer). The assignment contains two parts:
1. The mini-language specification
The mini-language should be a restricted form of a known programming language and should contain the following:
– 2 simple data types and a user-defined type
– statements: assignment, input/output, conditional, loop
– some restrictions will be enforced on the way identifiers and constants can be formed.
2. The scanner implementation
The scanner takes as input a text file containing the source program and produces as output:
– PIF – Program Internal Form
– ST – Symbol Table
In addition, the program should be able to determine the lexical errors, specifying the location, and, if possible, the type of the error.
The scanner assignment is differentiated based on:
1. Identifiers:
a. length at most 8 characters
b. arbitrary length, no more than 250 characters
2. Symbol Table:
a. unique for identifiers and constants
b. separate tables for identifiers and constants
3. Symbol Table organization:
a. lexicographically sorted table
b. lexicographic binary tree
c. hashing table
Documenting the scanner program is compulsory. The documentation should contain the scanner’s: specification (I/O), class diagram, main classes & their main methods description.