compiler/analysis.m:
compiler/analysis.file.m:
Instead of throwing an exception when we find an unexpected version
number or an unrecognized item in a file, construct an error_spec
describing the problem, add it to the list, and continue processing,
if this is possible.
In some places, pass around the information needed for the construction
of meaningful error messages.
Note a limitation of the new approach to error handling (that it inherits
from the old approach).
Instead of reading in each item in analysis request/result files
separately, read in their whole files all at once, and just parse it
item by item.
Stop marking module_cmds as an unwanted dependency; it defines
undate_interface_return_changed, which is required for this module's job.
Give some predicates more meaningful names.
compiler/error_spec.m:
Fix some documentation rot.
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
Act on the error_specs that the analysis package can now return.
compiler/generate_dep_d_files.m:
When the new code to handle the new --trans-opt-deps-spec option
found an error, it printed out an error message and then stopped.
Replace this with code that
- continues processing after each error, to allow more than one error
to be reported by a single compiler invocation, and
- does not any print error messages, but instead returns
an error_spec for each error.
In addition, add code to look for and report
- any references in the trans_opt_deps_spec to module names
that do not occur in the deps graph that the trans_opt_deps_spec
is intended to apply to; and
- any duplicate entries in module name lists.
To make the above possible, modify the representation of
trans_opt_deps_specs to include information that is needed
only for the generation of meaningful error messages.
Note some potential problems with the code that outputs the deps graph
as a .dot file.
compiler/error_spec.m:
Add a mechanism to gather all the contexts in error_specs, for use
by new code in generate_dep_d_files.
compiler/mercury_compile_main.m:
Write out the error_specs (if any) returned by generate_dep_d_files.m.
The compiler's diagnostic outputs often contain terms, representing
either terms in the program, or other entities such as types or modes.
These can be printed either as
f(a, b)
or as
f(
a,
b
)
We usually want the former if the term fits on one line, but the latter
if it is too big to fit on one line. The problem is that the code
generating the diagnostic often does not know what fits on one line.
compiler/error_spec.m:
This diff adds two new format pieces that respectively stand for
each half of a matched pair of left and right parentheses.
The idea is that these can be printed
- either with a newline, and an indent increment, after the left paren,
and an indent decrement, and a newline, before the right paren,
and with all newlines being honored between them,
- or with no newline after the left paren or before the right paren,
and all newlines between them being replaced by spaces.
compiler/write_error_spec.m:
Implement the new format pieces, using the one-line format above
if the term fits in the space available, or the multi-line format
if it does not.
compiler/error_type_util.m:
Use the new mechanism to represent the structure of types.
Delete an old piece of code that had the same objective,
but was much cruder and less effective.
tests/invalid/actual_expected.err_exp:
tests/invalid/ext_type_bug.err_exp:
tests/invalid/fbnf.err_exp:
tests/invalid/ho_type_arity_bug.err_exp:
tests/invalid/overloading.err_exp:
tests/invalid/type_diff.err_exp:
Expect more compact representations of the structure of types.
tests/invalid/type_error_ambiguous.err_exp:
Expect a different ordering of the same information.
The difference is due to the changed internal representation
(in terms of format_pieces) of a type.
compiler/error_spec.m:
This new module contains the part of the old error_util.m that defines
the error_spec type, and some functions that can help construct pieces
of error_specs. Most modules of the compiler that deal with errors
will need to import only this part of the old error_util.m.
This change also renames the format_component type to format_piece,
which matches our long-standing naming convention for variables containing
(lists of) values of this type.
compiler/write_error_spec.m:
This new module contains the part of the old error_util.m that
writes out error specs, and converts them to strings.
This diff marks as obsolete the versions of predicates that
write out error specs to the current output stream, without
*explicitly* specifying the intended stream.
compiler/error_sort.m:
This new module contains the part of the old error_util.m that
sorts lists of error specs and error msgs.
compiler/error_type_util.m:
This new module contains the part of the old error_util.m that
convert types to format_pieces that generate readable output.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new modules.
compiler/error_util.m:
The code remaining in the original error_util.m consists of
general utility predicates and functions that don't fit into
any of the modules above.
Delete an unneeded pair of I/O states from the argument list
of a predicate.
compiler/file_util.m:
Move the unable_to_open_file predicate here from error_util.m,
since it belongs here. Mark another predicate that writes
to the current output stream as obsolete.
compiler/hlds_error_util.m:
Mark two predicates that wrote out error_spec to the current output
stream as obsolete, and add versions that take an explicit output stream.
compiler/Mercury.options:
Compile the modules that call the newly obsoleted predicates
with --no-warn-obsolete, for the time being.
compiler/*.m:
Conform to the changes above, mostly by updating import_module
declarations, and renaming format_component to format_piece.