Use a file-based I/O interface to the compiler
Make the top-level interface to the compiler accept the names of input file(s) on the command line, including a way to specify stdin, and an optional output file instead of stdout. (See comment in #319.) Probably depends on #248 and #354.
Amongst other things, the .file directive in our .S file template should reflect the actual name of the output file.
The most annoying issue is that command-line arguments are dealt with in two places:
- In the main function in compiler64ProgScript.sml, and
- In the pure compiler function in compilerScript.sml.
I suggest moving all options parsing to the main function in compiler64ProgScript.sml, remove the command-line and file-system model arguments from compile_{32,64} and pass the compiler configuration records created from options parsing instead.
Alternatively, one can:
- Do it the other way around. This seems like more of a hassle, since the main function needs to decide whether to compile at all, or just print a help message, among other things.
- Keep it the way it is, and keep writing command-line options parsers in two places. I suspect this is one reason why the compiler binary so seldomly receives any updates.
Finally, I don't think #248 is required anymore: it's probably easier to extend the existing ad-hoc options parsing code.