Compile errors must be reported on the standard error flow with precise error location. Examples include:
$ echo "1 + + 2" | ./tc - error-->standard input:1.4: syntax error, unexpected "+" error-->Parsing Failed
and
$ echo "1 + () + 2" | ./tc -T - error-->standard input:1.0-5: type mismatch error--> right operand type: void error--> expected type: int
Note that the symbol error--> is not part of the actual output. It is only used in this document to highlight that the message is produced on the standard error flow. Do not include it as part of the compiler's messages.
The compiler exit value should reflect faithfully the compilation status. The possible values are:
malloc
or fopen
failed, a file is missing
etc.
Note that an optional option (such as --hir-use-ix) must cause
tc to exit 1 if it does not support it. If you don't, be sure
that your compiler will be exercised on these optional features, and it
will most probably have 0.
EX_USAGE
)argp
.
When several errors have occurred, the least value should be issued, not the earliest. For instance:
(let error in end; %)
should exit 2, not 3, although the parse error was first detected.
In addition to compiler errors, the compiled programs may have to raise a runtime error, for instance when runtime functions received improper arguments. In that case use the exit code 120, and issue a clear diagnostic. Note that because of the basic MIPS model we target which does not provide the standard error output, the message is to be output onto the standard output.