In the event that there are no lexical, syntactic, or semantic errors in the inputted
MINI-L program, your code generator should produce a single output file containing
the generated MIL intermediate code. This output file should be named XXXX.mil
, where
XXXX
is the name of the MINI-L program specified in the program declaration
statement within the MINI-L source code. Refer to the
specification of the MIL intermediate code representation for more details about
MIL code.
There are six types of semantic errors that should be captured by your code generator if they are present in an inputted MINI-L program.
Note that some of the above semantic errors may actually cause syntax errors during parsing. For example, if you try to declare a variable with a keyword name, then that will most likely cause a syntax error during parsing. That is fine. What is important is that some type of error message is emitted if any of the above errors are present.
If there are multiple occurrences of the above errors, your code generator should output an error message for each encountered error. You are free to choose the particular format of each error message. At a minimum, each error message should include the source code line number at which the error is encountered. If at least one error is encountered, then no intermediate code should be generated.
As an example, consider the following MINI-L program.
1. program test; 2. n : integer; 3. r : array (10) of integer; 4. n : array (10) of integer; 5. beginprogram 6. read n; 7. n := z + 1; 8. n := n + r; 9. write n; 10. endprogram
In the above program, there are three semantic errors occurring at lines 4, 7, and 8. The corresponding error messages that might be emitted by your code generator are shown below.
Error line 4: symbol "n" is multiply-defined. Error line 7: used variable "z" was not previously declared. Error line 8: used array variable "r" is missing a specified index.