mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 01:13:30 +00:00
And add tests for how the compiler handles both valid and invalid
options files.
compiler/options_file.m:
This diff rewrites options_file.m in a straightforward, direct style that
returns indications of errors as error_specs rather than as exceptions.
A recent diff started on this task; this diff finishes it.
The new approach has several advantages.
- The control flow is much simpler, and therefore more understandable.
Correctness arguments for propositions such as "this code closes
all the file streams that it opens" are now much simpler to make.
- We now report errors using error_specs, which contain context
information, while previously, each error was described only
by a string, without context info.
- Once we detect and report one error, we can continue to read the
rest of the input. This allows a single compiler invocation to find
and report several errors, not just the first.
- Since we now return the gathered set of error_specs instead of printing
them, the predicates of this file don't have to take globals structures
as arguments, which allows our callers to avoid constructing those
structures.
- Deep profiling, which cannot handle exceptions, now works on
the code of this module.
Change over to using trace goals for debugging prints, since continuing
to use debug_make_msg would require a globals structure.
Add an XXX on a likely bug.
Add a mechanism for writing out a database of variable names and values.
compiler/mercury_compile_main.m:
Conform to the changes in options_file.m. Document where exactly
we could avoid constructing a globals just for options_file.m.
If the right option is given, get options_file to write out the database
of variable names and values it has just read in, to enable the
functionality of this module to be tested.
compiler/options.m:
doc/user_guide.texi:
Add a new developer option, --dump-options-file, to control the above.
compiler/make.build.m:
compiler/make.m:
compiler/make.program_target.m:
Conform to the changes in options_file.m.
compiler/file_util.m:
Fix an error message.
tests/Mmakefile:
tools/bootcheck:
List options_file and invalid_options_file as two new test directories.
Fix a command in bootcheck.
tests/options_file/Mmakefile:
Add a mechanism for testing whether options_file.m builds mapping
from make variable names to values that we expect.
tests/Mmake.common:
Provide a mechanism for comparing dumped options_files against
their expected contents, for use by tests/invalid_options_file/Mmakefile.
Fix a comment.
tests/options_file/basic_test.m:
tests/options_file/basic_test.optfile_exp:
tests/options_file/basic_test.options_file:
tests/options_file/basic_test.options_file.sub0:
tests/options_file/basic_test.options_file.sub1:
A simple test case for exercising all the usual options_file constructs.
tests/invalid_options_file/Mmakefile:
Add a mechanism for testing whether options_file.m generates
the error messages we expect for various kinds of errors in options files.
tests/invalid_options_file/no_assign.{m,options_file,err_exp}:
tests/invalid_options_file/no_var.{m,options_file,err_exp}:
tests/invalid_options_file/nonexistent_file.{m,options_file,err_exp}:
tests/invalid_options_file/undefined_var.{m,options_file,err_exp}:
tests/invalid_options_file/unterminated_string.{m,options_file,err_exp}:
tests/invalid_options_file/unterminated_var.{m,options_file,err_exp}:
Six test cases to test six different kinds of errors that can be
detected by options_file.m.
3 lines
57 B
Plaintext
3 lines
57 B
Plaintext
# Include a nonexistent file.
|
|
include /nonexistent.xyzzy
|