doc/reference_manual.texi:
Do not compare tokens and terms in Mercury to those in ISO Prolog.
Unless the reader has a copy of the standard to hand doing so isn't all
that helpful -- it doesn't really add anything in any case. (The
transition guide already points out the differences for those coming
to Mercury from Prolog.)
library/parser.m:
Delete some irrelevant comments, viz. the parser is intended to
follow ISO Prolog, where Fergus was in relation to his copy of
the ISO draft and some stuff about NU-Prolog compatibility hacks
that were removed years ago.
Utilise the available space better.
When doing "mmc --make-short-interface *.m" in the compiler, this diff
reduces the overall amount of memory allocated by almost half, with
the amount allocated by the scanner going from 76 Mb to 13.5 Mb.
The speedup when doing that is around 12%, though it is closer to 0.5%
on tools/speedtest. (With --make-short-interface, scanning and parsing
take a much bigger fraction of the compiler's time than with other tasks.)
library/lexer.m:
We used to have two implementations of everything in this module.
One read in characters from a stream on demand, the other processed
a string containing the already-fully-read-in contents of a file.
The latter used a data structure named posn that contained not just
the current offset into the file, but the current line number and
the offset of the start of the current line.
Add a third predicate for every existing pair of predicates.
This one also processes fully-read-in files as string, but this one
passes around the current offset as a notag wrapper around an integer,
which eliminates the need to allocate memory when stepping over *every*
character. The current line number and the offset of the start of the
current line are in another structure, so we do still allocate memory
when stepping over a newline. Storing these two items in separate
arguments would allow us to reduce memory allocations even further,
but
- the increase in the cost of parameter passing would probably the same
when going from passing around 2 variable to passing around 3
as there was in going from passing around 1 variable to passing around 2,
while
- the reduction in memory allocation would be much smaller.
Thus the cost/benefit ration is likely to be much worse.
Try to compute the output arguments in their order in the arg list.
Delete an obsolete comment.
library/parser.m:
The parser could use either set of predicates in lexer.m. Add another
set that uses the new third set.
compiler/parse_module.m:
Switch to using the new predicates in parser.m, thus switching
to using the new code in lexer.m.
compiler/simplify_goal_call.m:
If the --warn-suspicious-recursion option is set, and if the warning
isn't disabled, generate warnings for two different kinds of suspicious
recursion. They are both related to, but separate from, the warning
we have long generated for infinite recursion, which occurs when
the input args of a recursive call are the same as the corresponding
args in the clause head.
Both kinds suspicious recursion look at the input args of a recursive call
that are NOT the same as the corresponding args in the clause head.
Both require these args to have non-unique modes. (If they have unique
modes, then the depth of the recursion may be controlled by state outside
the view of the Mercury compiler, which means that a warning would be
likely to be misleading.)
The first kind is when all these args use state variable notation.
Most of the time, we use state var notation to denote the data structures
updated by the recursive code; having variables using such notation
*controlling* the recursion is much less common, and much more likely
to be unintended. The motivation for the new option was this infinitely
looping code, which resulted from neglecting to s/[X | Xs]/Xs/ after
cutting-and-pasting the clause head to the recursive call.
p([X | Xs], !S) :-
...,
p([X | Xs], !S).
The other kind of suspicious recursive call we warn about involve
input arguments where the base names of the input arguments (the part
before any numeric suffixes) seem be switched between the clause head
and the recursive call, as here:
q(As0, Bs0, ...) :-
...,
q(Bs1, As, ...).
compiler/mercury_compile_main.m:
Disable style warnings when invoked with --make-optimization-interface
or its transitive variant. Without this, warnings about suspicious
recursion would get reported in such invocations.
Move a test from a callee to a caller to allow the callee to be
less indented.
compiler/options.m:
Export functionality to mercury_compile_main.m to make the above possible.
library/string.m:
Add a predicate to convert a string to *reverse* char list directly.
Note a discrepancy between the documentation and the implementation
of the old predicate the new one is based on (which converts a string
to a forward char list).
NEWS:
Note the new predicate in string.m.
compiler/cse_detection.m:
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/distance_granularity.m:
compiler/frameopt.m:
compiler/inst_util.m:
compiler/lp_rational.m:
compiler/matching.m:
compiler/modes.m:
compiler/old_type_constraints.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.region_arguments.m:
compiler/recompilation.usage.m:
compiler/stratify.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.indirect.m:
compiler/typeclasses.m:
compiler/use_local_vars.m:
deep_profiler/callgraph.m:
deep_profiler/canonical.m:
library/bit_buffer.read.m:
library/bit_buffer.write.m:
library/calendar.m:
library/diet.m:
library/lexer.m:
library/parser.m:
library/parsing_utils.m:
library/ranges.m:
library/set_ctree234.m:
library/set_tree234.m:
library/string.parse_util.m:
library/tree234.m:
library/varset.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
profiler/demangle.m:
Avoid warnings for suspicious recursion. In most cases, do this by
wrapping disable_warning scopes around the affected recursive calls;
in a few cases, do this by changing the code.
tests/warnings/suspicious_recursion.{m,exp}:
A test case for the new warnings.
tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
Enable the new test case.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
Extend the lexer to recognise uint literals, optional signedness suffixes on
ints and the literals for all of the proposed fixed size integer types.
Fix XXX UINTs in the library and compiler.
library/lexer.m:
Uncomment the other alternatives in the integer_size/0 type.
Handle signedness and size suffixes in integer literals.
library/parser.m
library/term.m:
Conform to the above changes.
library/stream.string_writer.m:
Fix an XXX UINT: make write handle uints properly.
library/term_io.m:
Fix an XXX UINT: output integer signedness and size suffixes for
integers when appropriate.
compiler/superhomogeneous.m:
Print an error message if we encounter a fixed size integer literal
as the rest of the compiler does not yet support them.
compiler/hlds_out_util.m:
compiler/parse_tree_out_info.m:
Output the 'u' suffix on uint values.
test/hard_coded/lexer_zero.{m,inp,exp*}:
Extend this test to cover zeros of varying signedness and size.
Prefix each line of the output with the input line number of the
token -- this makes it easier to relate the output back to the
input.
tests/hard_coded/Mmakefile:
Add the new test case.
tests/hard_coded/lexer_ints.{m,inp,exp}:
Test the lexer on non-zero integer literals.
library/lexer.m:
Merge the 'integer' and 'big_integer' tokens and extend them to include
signedness and size information. This conforms to recent changes to
the rest of the system and is another step towards supporting additional
types of integer literal.
library/parser.m:
mdbcomp/trace_counts.m:
Conform to the above change.
tests/hard_coded/impl_def_lex.exp:
tests/hard_coded/impl_def_lex_string.exp:
tests/hard_coded/lexer_bigint.exp:
tests/hard_coded/lexer_zero.exp*:
tests/hard_coded/parse_number_from_string.exp*:
Update these expected outputs.
In preparation for supporting uint literals and literals for the fixed size
integer types, generalise the representation of integers in the term module, so
that for every integer literal we record its base, value (as an arbitrary
precision integer), signedness and size (the latter two based on the literal's
suffix or lack thereof).
Have the lexer attach information about the integer base to machine sized ints;
we already did this for the 'big_integer' alternative but not the normal one.
In conjunction with the first change, this fixes a problem where the compiler
was accepting non-decimal integers in like arity specifications. (The
resulting error messages could be improved, but that's a separate change.)
Support uints in more places; mark other places which require further work with
XXX UINT.
library/term.m:
Generalise the representation of integer terms so that we can store
the base, signedness and size of a integer along with its value.
In the new design the value is always stored as an arbitrary precision
integer so we no longer require the big_integer/2 alternative; delete it.
Add some utility predicates that make it easier to work with integer terms.
library/term_conversion.m:
library/term_io.m:
Conform to the above changes,
Add missing handling for uints in some spots; add XXX UINT comments
in others -- these will be addressed later.
library/lexer.m:
Record the base of word sized integer literals.
library/parser.m:
compiler/analysis_file.m:
compiler/fact_table.m:
compiler/get_dependencies.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_util.m:
compiler/intermod.m:
compiler/make.module_dep_file.m:
compiler/parse_class.m:
compiler/parse_inst_mode_name.m:
compiler/parse_item.m:
compiler/parse_pragma.m:
compiler/parse_sym_name.m:
compiler/parse_tree_out_term.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_defn.m:
compiler/parse_util.m:
compiler/prog_ctgc.m:
compiler/prog_util.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/superhomogeneous.m:
mdbcomp/trace_counts.m:
samples/calculator2.m:
extras/moose/moose.m:
Conform to the above changes.
tests/hard_coded/impl_def_lex.exp:
tests/hard_coded/impl_def_lex_string.exp:
tests/hard_coded/lexer_bigint.exp*:
tests/hard_coded/lexer_zero.exp*:
tests/hard_coded/parse_number_from_string.exp*:
tests/hard_coded/term_to_unit_test.exp:
Update these expected outputs.
library/backjump.m:
library/exception.m:
library/getopt_io.m:
library/psqueue.m:
library/set_ctree234.m:
library/set_tree234.m:
library/tree234.m:
Avoid using implicit streams.
library/io.m:
Add a version of the write_cc predicate that allows callers
to specify an explicit stream.
Fix what seems like an old bug in read_binary_file_as_bitmap: it was not
reading from the file at all.
Use explicit module qualification in some places to make the code more
readable.
library/table_statistics.m:
Add a version of the write_table_stats predicate that allows callers
to specify an explicit stream.
Avoid using implicit streams inside the module as well.
library/term_io.m:
Add versions of the predicates that read terms that allow callers
to specify an explicit stream.
Avoid using implicit streams inside the module as well.
library/parser.m:
Add module qualifications that are needed after the new addition of new
predicates to term_io.m.
library/stream.m:
library/stream.string_writer.m:
Fix style.
library/lexer.m:
library/parser.m:
Add versions of the existing scanning and parsing predicates that
read from an explicitly specified stream, not the current input stream.
NEWS:
Announce the new predicates.
One speedup is from inlining parse_simple_term_2 into parse_simple_term,
which allows us to avoid a redundant test, and the overhead of passing
around a success flag.
Another speedup is from the fact that we can now discover that a term
is not followed by curried arguments *without* the need for a call.
Give some predicates and variables more meaningful names.
library/parser.m:
The code that handled prefix ops used to be structured as an if-then-else
chain with four test, each checking for a different kind of prefix op.
Since most functors in terms are NOT prefix ops, all four tests usually
failed. To add insult to injury, two of those tests looked up the same
entry entry in the op table, so the second lookup was redundant.
Restructure this code so that
(a) we get to the usual case after only ONE failed test
(the functor is not an op), and
(b) we look up the functor in the op table just once.
The result is a slight speedup.
library/parser.m:
The parser state used to have five fields. One of these, the list
of tokens remaining to be parsed, was read and updated *much* more often
than all the other fields combined. All the updates lead to lots of
memory allocations, and much garbage collection.
This diff takes the list of remaining tokens out of the parser state,
and passes it round separately. This requires a bit more argument passing,
but it also eliminates lots of memory allocations, as well as some calls,
since some access predicates, their bodies having become trivial, are
no longer needed.
Put the operations on the parser state type next to each other.
Rename some types and predicates to avoid ambiguities.
library/lexer.m:
Fix whitespace.
Make base_string_to_int check for overflow and underflow when converting
from strings in all bases, not only base 10. Fixes bug #376.
Previously it was stated that "numbers not in base 10 are assumed to
denote bit patterns and are not checked for overflow." Though not a
safe assumption in general, in Mercury source files it is useful to be
able to write values with the high bit set, e.g. 0x80000000 on 32-bit
machines, that would be greater than max_int if interpreted as a
positive integer.
The changed behaviour of base_string_to_int would reject such literals
from Mercury sources, so additional changes are required to maintain
that usage. However, unlike before, the compiler will report an
error if some non-zero bits of the literal would be discarded.
library/string.m:
Enable overflow/underflow checking for base_string_to_int for
any base.
Update documentation.
library/lexer.m:
Allow `big_integer' token functor to represent non-base 10
literals as well.
Add `integer_base' type.
library/term.m:
Add `big_integer' term functor.
Add `integer_base' type.
library/term_io.m:
Add private helper functions `integer_base_int' and
`integer_base_prefix'.
Conform to changes.
library/parser.m:
Pass through `big_integer' tokens as `big_integer' terms.
Conform to changes.
compiler/prog_util.m:
Add predicate to convert integer terms to ints with the
aforementioned concession for bit patterns.
`make_functor_cons_id' can now fail due to integer tokens
exceeding the range of `int'.
compiler/superhomogeneous.m:
Make `unravel_var_functor_unification' convert `big_integer'
tokens on the RHS to a simple `int' with the aforementioned
concession for bit patterns, or add an error message if any
significant bits would be discarded.
compiler/fact_table.m:
compiler/mercury_to_mercury.m:
compiler/module_imports.m:
compiler/prog_io_util.m:
Conform to changes.
compiler/make.util.m:
Delete unused predicate.
tests/general/test_string_to_int_overflow.m:
tests/general/test_string_to_int_overflow.exp:
tests/general/test_string_to_int_overflow.exp2:
tests/general/test_string_to_int_overflow.exp3:
Rewrite test case.
tests/hard_coded/lexer_bigint.exp:
tests/hard_coded/lexer_bigint.exp2:
tests/hard_coded/read_min_int.exp:
tests/hard_coded/read_min_int.exp2:
Update expected outputs due to the lexer and term module changes.
tests/invalid/Mmakefile:
tests/invalid/invalid_int.err_exp:
tests/invalid/invalid_int.err_exp2:
tests/invalid/invalid_int.m:
Add new test case.
NEWS:
Announce the changes.
Branches: main
lexer.m tokenises "-INTEGER" as two tokens, a minus sign and a positive
integer. This fails when the overall negative value is min_int, i.e. the
absolute value is max_int+1 -- too big to store in an int.
One less obvious consequence of the bug is that io.read could not parse some
plain Mercury terms written out by io.write.
library/lexer.m:
Add a `token.big_integer' constructor to hold big integer literals in
their string representation. Currently this is only done for base 10
literals which cannot fit in an int.
library/parser.m:
Parse the token sequence, minus sign followed by big_integer max_int+1,
as the integer term with value min_int.
tests/hard_coded/Mmakefile:
tests/hard_coded/lexer_bigint.exp:
tests/hard_coded/lexer_bigint.exp2:
tests/hard_coded/lexer_bigint.inp:
tests/hard_coded/lexer_bigint.m:
tests/hard_coded/read_min_int.exp:
tests/hard_coded/read_min_int.exp2:
tests/hard_coded/read_min_int.inp:
tests/hard_coded/read_min_int.m:
Add test cases.
Branches: main
Change the argument order of predicates in the varset module to make
them more conducive to the use of state variable notation.
library/varset.m:
As above.
library/parser.m:
library/term_io.m:
library/svvarset.m:
compiler/*.m:
samples/interpreter.m:
tests/debugger/interpreter.m:
tests/general/interpreter.m:
tests/hard_coded/bigtest.m:
tests/hard_coded/deep_copy_bug.m:
tests/hard_coded/lp.m:
tests/hard_coded/pprint_test.m:
tests/hard_coded/type_spec_ho_term.m:
Conform to the above change and remove dependencies on the svvarset
module.
Branches: main
Change the argument order of many of the predicates in the map, bimap, and
multi_map modules so they are more conducive to the use of state variable
notation, i.e. make the order the same as in the sv* modules.
Prepare for the deprecation of the sv{bimap,map,multi_map} modules by
removing their use throughout the system.
library/bimap.m:
library/map.m:
library/multi_map.m:
As above.
NEWS:
Announce the change.
Separate out the "highlights" from the "detailed listing" for
the post-11.01 NEWS.
Reorganise the announcement of the Unicode support.
benchmarks/*/*.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
extras/*/*.m:
mdbcomp/*.m:
profiler/*.m:
tests/*/*.m:
ssdb/*.m:
samples/*/*.m
slice/*.m:
Conform to the above change.
Remove any dependencies on the sv{bimap,map,multi_map} modules.
Estimated hours taken: 40
Branches: main
Switch to using error_util to generate error message during the process of
converting terms to prog_items.
In many predicates, we used to return error messages as a string/term pair,
with the string being the error message and a term, which both provided
the context and was printed after the message. We now return error indications
as lists of error_specs. These include a printout of the relevant term only
if this helps users understand the nature or the location of the error.
To make the printouts easier to understand we print variable names in them
using the applicable varsets. (The old version of the compiler used to print
each error term long after it lost track of the right varset, and thus used
a dummy varset that yielded error messages referring to _1, _2 etc instead
of the variable names used by the programmer.)
Sometimes the callers of some parse predicates prepended other strings
indicating the context of the error in front of the error string.
This diff changes things so that now the caller instead passes a list
of format components describing the context to the predicates that construct
the error_specs.
In some places, simplify the code, e.g. by factoring out common code, and by
inlining some auxiliary predicates (we used to need these auxiliary predicates
for indexing when we executed the compiler using Prolog, but those days are
long past).
Mark with XXXs places where I think the error messages or their contexts
could be improved, and places where the structure of the code could be
improved.
compiler/prog_io_util.m:
Change the representation of the maybeN types to use error_spec lists.
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
Change the way we generate error messages along the lines described
at the top.
In several cases, this required adding extra arguments (varsets,
context descriptions) to predicates for use in error messages.
Some of these predicates were also used in contexts where the caller
was interested only in success, and would ignore any error messages.
In these cases, add a version of the predicate that does not require
the extra arguments, and which is semidet (to allow the caller to
avoid a test for ok).
compiler/error_util.m:
Add a mechanism for changing the case of the next format_component,
to allow an error message to be appended to a list of format_components
providing the context that generates good-looking output whether or not
that context is empty.
Replace some bools with purpose-specific types.
Make sort_error_specs internal to the module, since outside modules
should never need to use it.
Use cords instead of reversed lists to simplify some parts of the
internal implementation.
compiler/mercury_to_mercury.m:
Provide a mechanism to print out terms only if they aren't too big,
for use in our error messages.
compiler/prog_item.m:
Delete the message_list type, and note a future improvement.
compiler/prog_out.m:
Delete the predicates for printing message_lists.
compiler/intermod.m:
compiler/modules.m:
Change the way we print out error messages along the lines described
at the top.
compiler/add_clause.m:
compiler/field_access.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/superhomogeneous.m:
Conform to the changes above by modifying how we generate error
messages.
compiler/add_class.m:
compiler/add_pragma.m:
compiler/check_typeclass.m:
compiler/common.m:
compiler/make.module_dep_file.m:
compiler/make_hlds_error.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/mode_errors.m:
compiler/modes.m:
compiler/options_file.m:
compiler/prog_ctgc.m:
compiler/prog_event.m:
compiler/purity.m:
compiler/trans_opt.m:
compiler/typecheck.m:
Trivial updates to conform to the changes above.
compiler/prog_data.m:
Add some field names and access functions for use in the modules above.
library/list.m:
Add list.contains, which is list.member with the arguments reversed
to make it possibly to partially apply it.
tests/invalid/bad_finalise_decl.err_exp:
tests/invalid/bad_initialise_decl.err_exp:
tests/invalid/bad_mutable.err_exp:
tests/invalid/bigtest.err_exp:
tests/invalid/conflicting_fs.err_exp:
tests/invalid/constrained_poly_insts.err_exp:
tests/invalid/errors.err_exp:
tests/invalid/func_errors.err_exp:
tests/invalid/fundeps_unbound_in_ctor.err_exp:
tests/invalid/fundeps_vars.err_exp:
tests/invalid/impl_def_literal_syntax.err_exp:
tests/invalid/inst_list_dup.err_exp:
tests/invalid/invalid_typeclass.err_exp:
tests/invalid/kind.err_exp:
tests/invalid/null_char.err_exp:
tests/invalid/pragma_source_file.err_exp:
tests/invalid/predmode.err_exp:
tests/invalid/reserve_tag.err_exp:
tests/invalid/some.err_exp:
tests/invalid/specified.err_exp:
tests/invalid/trace_goal_env.err_exp:
tests/invalid/type_vars.err_exp:
tests/invalid/typeclass_test_1.err_exp:
tests/invalid/typeclass_test_11.err_exp:
tests/invalid/typeclass_test_2.err_exp:
tests/invalid/unbound_type_vars.err_exp:
tests/invalid/unicode1.err_exp:
tests/invalid/unicode2.err_exp:
tests/invalid/uu_type.err_exp:
tests/invalid/vars_in_wrong_places.err_exp:
tests/invalid/with_type.err_exp:
tests/invalid/purity/purity_nonsense2.err_exp:
Update the expected error messages.
Branches: main
A small optimisation for the parser.
library/parser.m:
Add a mode declaration for `parser_get_token' that takes the expected
token as input, so that the expected and actual tokens can be unified
within the procedure. If they don't match, it avoids creating a new
parser state that would be discarded by the caller. The call in
`check_for_higher_order_term' is very likely to fail.
Estimated hours taken: 0.5
Branches: main
Avoid running out of stack space when parsing big terms.
library/Mercury.options:
Enable last-call-modulo-cons optimisation to make
`lexer.get_token_list_2' tail recursive.
library/parser.m:
Make `check_for_bad_token' tail recursive. Change the behaviour to
what should be the intended behaviour in the first place.
Write out a switch in full.
Estimated hours taken: 16
Branches: main
Add support for "implementation-defined literals" $file, $line, $module,
$pred, $grade which are replaced constants by the compiler.
library/lexer.m:
Add a new type of token.
Read "$foo" as a `implementation_defined' token instead of two name
tokens.
library/term.m:
library/term_io.m:
Add a new type of constant, `implementation_defined'.
library/parser.m:
Handle `implementation_defined' tokens from the lexer.
compiler/check_hlds.m:
compiler/implementation_defined_literals.m:
compiler/mercury_compile.m:
Add a new pass to replace implementation-defined literals in program
clauses.
Call the new pass.
compiler/notes/compiler_design.html:
Document the new module.
compiler/prog_data.m:
Add a new option to `cons_id', namely `implementation_defined_const'.
compiler/typecheck.m:
Tell the typechecker the types of the supported implementation-defined
literals.
compiler/prog_io_util.m:
Make `convert_bound_inst' fail if implementation-defined literals
appear in inst definitions so that an error will be issued.
compiler/bytecode_gen.m:
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/dependency_graph.m:
compiler/erl_unify_gen.m:
compiler/fact_table.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_out.m:
compiler/inst_check.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/module_qual.m:
compiler/prog_rep.m:
compiler/prog_type.m:
compiler/prog_util.m:
compiler/rbmm.execution_path.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
Conform to addition of `implementation_defined_const'.
doc/reference_manual.texi:
Document implementation-defined literals.
NEWS:
Announce the new feature.
tests/hard_coded/Mmakefile:
tests/hard_coded/impl_def_lex.exp:
tests/hard_coded/impl_def_lex.m:
tests/hard_coded/impl_def_lex_string.exp:
tests/hard_coded/impl_def_lex_string.m:
tests/hard_coded/impl_def_literal.exp:
tests/hard_coded/impl_def_literal.m:
tests/invalid/Mmakefile:
tests/invalid/impl_def_literal_syntax.err_exp:
tests/invalid/impl_def_literal_syntax.m:
tests/invalid/undef_impl_def_literal.err_exp:
tests/invalid/undef_impl_def_literal.m:
Add test cases.
Estimated hours taken: 20
Branches: main
Add a new compiler option. --inform-ite-instead-of-switch. If this is enabled,
the compiler will generate informational messages about if-then-elses that
it thinks should be converted to switches for the sake of program reliability.
Act on the output generated by this option.
compiler/simplify.m:
Implement the new option.
Fix an old bug that could cause us to generate warnings about code
that was OK in one duplicated copy but not in another (where a switch
arm's code is duplicated due to the case being selected for more than
one cons_id).
compiler/options.m:
Add the new option.
Add a way to test for the bug fix in simplify.
doc/user_guide.texi:
Document the new option.
NEWS:
Mention the new option.
library/*.m:
mdbcomp/*.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
Convert if-then-elses to switches at most of the sites suggested by the
new option. At the remaining sites, switching to switches would have
nontrivial downsides. This typically happens with the switched-on type
has many functors, and we treat one or two specially (e.g. cons/2 in
the cons_id type).
Perform misc cleanups in the vicinity of the if-then-else to switch
conversions.
In a few cases, improve the error messages generated.
compiler/accumulator.m:
compiler/hlds_goal.m:
(Rename and) move insts for particular kinds of goal from
accumulator.m to hlds_goal.m, to allow them to be used in other
modules. Using these insts allowed us to eliminate some if-then-elses
entirely.
compiler/exprn_aux.m:
Instead of fixing some if-then-elses, delete the predicates containing
them, since they aren't used, and (as pointed out by the new option)
would need considerable other fixing if they were ever needed again.
compiler/lp_rational.m:
Add prefixes to the names of the function symbols on some types,
since without those prefixes, it was hard to figure out what type
the switch corresponding to an old if-then-else was switching on.
tests/invalid/reserve_tag.err_exp:
Expect a new, improved error message.
Estimated hours taken: 24
Branches: main
Generate an XML representation of the du types in the current module.
The XML representation contains all the information about the type,
as well as associating with each type, data constructor and data field
any comments located near the comment.
The current strategy associates the comment starting on the same line
as the type declaration, and if there is none then the comment directly
above. At a later date, this strategy needs to be made more flexible.
This required two main changes to the compiler.
Change one was to associate with a term.variable the context
of that variable.
Then the constructor and constructor_arg types had to have their
context recorded.
compiler/xml_documentation.m:
Add a pass that generates an XML documentation
for the du types in the current module.
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/options.m:
Call the xml_documentation phase and stop afterwards.
compiler/error_utils.m:
Add a utitily predicate for reporting errors where
a file is unable to be opened.
library/term.m:
Add the term.context to term.variables.
Remove the backwards mode of var_list_to_term_list as it
no longer works.
Make the predicate version of term_list_to_var_list
semidet as we can no longer use the backwards version
var_list_to_term_list.
NEWS:
Mention the changes to the term module.
library/parser.m:
Fill in the term.context of term.variables while parsing.
compiler/prog_data.m:
Add the context to the constructor and constructor_arg types.
compiler/prog_io.m:
Fill in the context fields in the constructor and constructor_arg
types.
compiler/add_clause.m:
compiler/prog_io.m:
compiler/prog_io_typeclass.m:
compiler/typecheck.m:
Call the correct version of term_list_to_var_list,
to deal with the fact that we removed the reverse
mode of var_list_to_term_list.
compiler/notes/compiler_design.html:
doc/user_guide.texi:
Document the new module.
compiler/add_clause.m:
compiler/det_util.m:
compiler/fact_table.m:
compiler/hlds_out.m:
compiler/inst_graph.m:
compiler/intermod.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/prog_ctgc.m:
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
compiler/prog_io_util.m:
compiler/prog_util.m:
compiler/state_var.m:
compiler/superhomogeneous.m:
compiler/switch_detection.m:
compiler/typecheck_errors.m:
library/term_io.m:
library/varset.m:
Handle the context in the term.variable structure.
compiler/add_type.m:
compiler/check_typeclass.m:
compiler/equiv_type.m:
compiler/hhf.m:
compiler/hlds_out.m:
compiler/inst_check.m:
compiler/make_tags.m:
compiler/mercury_to_mercury.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mode_util.m:
compiler/module_qual.m:
compiler/post_typecheck.m:
compiler/prog_io.m:
compiler/prog_mode.m:
compiler/prog_type.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/special_pred.m:
compiler/term_constr_build.m:
compiler/term_norm.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_proc.m:
compiler/untupling.m:
compiler/unused_imports.m:
Handle the context field in the constructor and constructor_arg
types.
compiler/check_hlds.m:
Add the xml_documentation module.
Estimated hours taken: 0.1
Branches: main
library/eqvclass.m:
library/graph.m:
library/bool.m:
library/parser.m:
library/relation.m:
library/robdd.m:
Delete imports that are duplicated between the interface and
implementation sections.
Estimated hours taken: 1
Branches: main
Various minor cleanups and syntax updates for the standard library.
There are no changes to any algorithms.
library/injection.m:
library/set.m:
library/sparse_bitset.m:
Use promise_equivalent_clauses where appropriate.
library/set_ordlist.m:
library/set_unordlist.m:
Convert these module to 4-space indentation:
Convert these module to 4-space indentation
library/*.m:
Convert some if-then-elses into switches.
Remove unnecessary module qualification - this is related
mainly to the breakup of std_util and the fact that on
the 0.13 branche we had two versions of the all-solutions
predicates.
Various other style cleanups.
vim/syntax/mercury.vim:
Highlight promise_equivalent_clauses appropriately.
Estimated hours taken: 8
Branches: main
Get rid of a bunch more ambiguities by renaming predicates, mostly
in polymorphism.m, {abstract,build,ordering}_mode_constraints.m, prog_type.m,
and opt_debug.m in the compiler directory and term_io.m, term.m, parser.m,
and string.m in the library.
In some cases, when the library and the compiler defined the same predicate
with the same code, delete the compiler's copy and give it access to the
library's definition by exporting the relevant predicate (in the undocumented
part of the library module's interface).
NEWS:
Mention that the names of some library functions have changed.
library/*.m:
compiler/*.m:
mdbcomp/*.m:
browser/*.m:
Make the changes mentioned above, and conform to them.
test/general/string_test.m:
test/hard_coded/string_strip.m:
test/hard_coded/string_strip.exp:
Conform to the above changes.
Estimated hours taken: 18
Branches: main
Move the univ, maybe, pair and unit types from std_util into their own
modules. std_util still contains the general purpose higher-order programming
constructs.
library/std_util.m:
Move univ, maybe, pair and unit (plus any other related types
and procedures) into their own modules.
library/maybe.m:
New module. This contains the maybe and maybe_error types and
the associated procedures.
library/pair.m:
New module. This contains the pair type and associated procedures.
library/unit.m:
New module. This contains the types unit/0 and unit/1.
library/univ.m:
New module. This contains the univ type and associated procedures.
library/library.m:
Add the new modules.
library/private_builtin.m:
Update the declaration of the type_ctor_info struct for univ.
runtime/mercury.h:
Update the declaration for the type_ctor_info struct for univ.
runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
Update the definition of MR_Univ.
runtime/mercury_init.h:
Fix a comment: ML_type_name is now exported from type_desc.m.
compiler/mlds_to_il.m:
Update the the name of the module that defines univs (which are
handled specially by the il code generator.)
library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
Conform to the above changes. Import the new modules where they
are needed; don't import std_util where it isn't needed.
Fix formatting in lots of modules. Delete duplicate module
imports.
tests/*:
Update the test suite to confrom to the above changes.
Estimated hours taken: 1
Branches: main
library/*.m:
Replace __ with . as the module qualifier everywhere.
tests/hard_coded/test_injection.exp:
Replace __ with . as the module qualifier in expected exceptions.
Estimated hours taken: 5
Branches: main
Fix a bug reported by Doug Auclair.
library/ops.m:
Change the Mercury arg priority to 999. It was previously set to
1201, which allowed arguments and list elements to be parsed the
way we intended. However, this had the unintended side effect that
valid terms were written out using incorrect syntax.
library/parser.m:
Place the workaround here, where arguments and list elements are
read.
Note that this is still technically buggy, because we effectively
allow syntax which should be illegal according to the operator
precedence table. But the proper fix for this involves moving to
a BNF style parser, so that is left for later work.
tests/hard_coded/Mmakefile:
Run the term_io_test case twice, checking it against the expected
output each time. The first time it is run with the supplied input
file. The second time it is run with the expected output as input --
this ensures that terms are read in the same way that they are
written out.
tests/hard_coded/term_io_test.m:
Read input from stdin rather than a fixed file.
tests/hard_coded/term_io_test.inp:
Add additional input terms.
tests/hard_coded/term_io_test.exp:
tests/invalid/*.err_exp:
Update the expected output for this and other test cases.
Estimated hours taken: 4
Branches: main
library/*.m:
Convert to four-space indentation most of the library modules that
weren't already indented that way. Use predmode syntax where possible.
In some modules, shorten long lines by deleting module name prefixes.
Fix departures from our coding standards.
In some modules, simplify code, mostly using field names and/or state
variables.
There are no changes in algorithms, except for neg_list in integer.m.
Estimated hours taken: 1
Branches: main, release
Add some synonyms for various functions in the string module
and make some more general cleanups to parts of the standard library.
library/array.m:
s/applys/applies/
library/list.m:
Position descriptive comments according to our coding
standard.
Fix a cut and paste error. list.foldl6 has six accumulators
not five.
library/parser.m:
library/pqueue.m:
library/set_bbbtree.m:
library/set_ctree234.m:
Fix minor formatting problems and spelling mistakes.
library/string.m:
Add functions string.from_int/1, string.from_char/1
and string.from_float/1 as synonyms for string.int_to_string/1
etc.
library/version_types.m:
s/incurrs/incurs/
Estimated hours taken: 3
Branches: main, version-0_12-branch
library/array.m:
library/array2d.m:
library/assoc_list.m:
library/bag.m:
library/benchmarking.m:
library/bimap.m:
library/bintree_set.m:
library/bitmap.m:
library/bool.m:
library/builtin.m:
library/cord.m:
library/float.m:
library/graph.m:
library/group.m:
library/hash_table.m:
library/int.m:
library/lexer.m:
library/list.m:
library/map.m:
library/math.m:
library/multi_map.m:
library/ops.m:
library/parser.m:
library/rbtree.m:
library/set.m:
library/stack.m:
library/store.m:
library/string.m:
library/time.m:
Minor reformatting; added some renamed preds and funcs to improve
consistency of naming in the library; removed some preds and types that
have been marked obsolete since 0.11.
Estimated hours taken: 10
Branches: main
library/*.m:
Bring these modules up to date with our current style guidelines.
Use predmode declarations where appropriate. Use state variable syntax
where appropriate. Reorder arguments where this makes it possible to
to use state variable syntax.
library/io.m:
Export some predicates that are duplicated in term_io.m and/or
parser.m, and give them more expressive names.
library/parser.m:
library/term_io.m:
Delete the now unnecessary copies of those predicates in these modules.
Estimated hours taken: 1
library/parser.m:
Extended parser__parse_rest//5 to handle backquoted operators with
module qualifiers so that e.g. (A `set.union` B) will
parse successfully.
doc/reference_manual.texi:
Documented the new syntax.
tests/hard_coded/backquoted_qualified_ops.m:
tests/hard_coded/backquoted_qualified_ops.exp:
tests/hard_coded/Mmakefile:
Test case added.
Estimated hours taken: 1
Branches: main
library/parser.m:
Consistently use get and set functions to access the components
of the parser state. This allows deep profiling to count how many
times each component is accessed. However, make all these functions
inlined by default, for performance.
Estimated hours taken: 1
Branches: main
library/lexer.m:
Fix a bug where it was relying on being able to push back two
characters in a row, which is more than io__putback_char guarantees.
This bug broke things in grade `il', which only supports exactly
one byte of pushback.
Unfortunately the fix required adding a new kind of token to the
token type, changing the interface. The new token is only used
internally within lexer.m -- it gets expanded before being returned.
So hopefully this won't cause too much in the way of backwards
compatibility problems.
library/parser.m:
Update to handle the new token.
Estimated hours taken: 3 (including 2 hours developing a less efficient and less
elegant solution first :-( )
Branches: main
library/parser.m:
Allow `|' to be treated as an infix operator unless we are parsing a
list element (where it will still be treated as the head-tail
separator).
Estimated hours taken: 4
Allow user-defined operator precedence tables for parser__read_term
and term_io__write_term.
library/ops.m:
Define a typeclass `op_table' with methods for accessing
operator precedence tables.
Define a type `ops__mercury_op_table', representing the
standard Mercury operator table.
Make `ops__mercury_op_table' an instance of `op_table'.
Define `ops__table' as equivalent to `ops__mercury_op_table'
(it's obsolete, but we can't mark types as obsolete).
Rename `ops__init_op_table' as `ops__init_mercury_op_table',
mark ops__init_op_table as obsolete
library/parser.m:
library/term_io.m:
Add variants of `parser__read_term' and `term_io__write_term'
which take an operator precedence table.
Don't hard-code the maximum priority and argument priority.
Use the `op_table' methods to find those.
Make the priority of operator terms (X `op` Y) 1, not 100.
The reference manual states that operator terms have
the highest precedence possible.
This change slows down a program which does nothing but
parse terms by a bit under 5%, less for writing.
library/hash_table.m:
Fix a few places where parentheses are required because
operator terms now have the lowest possible priority.
`rem' is an operator -- it doesn't need backquotes.
compiler/mercury_to_mercury.m:
library/io.m:
Rename `ops__init_op_table' to `ops__init_mercury_op_table'.
Pass the `op_table' to `ops__max_priority'.
NEWS:
doc/reference_manual.texi:
Document the changes.
Add operator terms to the operator table.
In the "Terms" section of the reference manual, use the same
terminology to describe operator terms as is used in the
"Builtin Operators" section.
samples/Mmakefile:
samples/README:
samples/calculator2.m:
An example program.
tests/hard_coded/term_io_test.exp:
tests/invalid/func_errors.err_exp:
tests/invalid/inst_list_dup.err_exp:
tests/invalid/predmode.err_exp:
tests/invalid/some_err.exp:
`term_io__write_term' now has the same argument priority
behaviour as `parser__read_term', so remove some unnecessary
parentheses from the output.
Estimated hours taken: 3
Branches: main
Change the list constructor from `./2' to `[|]/2'. `./2' will
eventually become the module qualification operator.
library/parser.m:
library/io.m:
library/sparse_bitset.m:
library/std_util.m:
library/term_io.m:
compiler/mercury_to_mercury.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
browser/interactive_query.m:
extras/moose/grammar.m:
extras/moose/moose.m:
extras/morphine/source/generate_call_site_cov.m:
extras/xml/xml.encoding.m:
samples/muz/higher_order.m:
tests/debugger/declarative/app.m:
tests/dppd/transpose_impl.m:
tests/hard_coded/ground_dd.m:
tests/hard_coded/split_c_files.m:
Change all references to `./2' to use `[|]/2' instead.
compiler/typecheck.m:
Handle `./2' as a special case in `report_error_undef_cons'.
Warn about module list not being imported if `[|]/2' is undefined.
compiler/llds_out.m:
util/mdemangle.c:
profiler/demangle.m:
Add name conversions for `[|]' (f_cons) and `[]' (f_nil).
NEWS:
doc/reference_manual.texi:
w3/tutorial/lists-n-things.m4:
Document the changes.
tests/debugger/{,declarative}/*.exp*:
Update test case results. For some tests the output changed
because they output lists in the non-pretty format. For others,
the output changed because the alphabetical ordering of the
constructors of type `list/1' changed, so the numbering of
the switch branches in the goal paths changed.
Estimated hours taken: 30
Implement builtin tuple types, similar to those in Haskell.
Tuples are constructed and deconstructed using
the syntax X = {Arg1, Arg2, ...}.
Tuples have type `{Arg1, Arg2, ...}'.
Unary tuples (X = {Arg}) do work, unlike in Haskell. The rationale
for this is that it is useful to be able to construct unary tuples
to be passed to a polymorphic predicate which uses std_util__deconstruct
to deal with a tuple of any arity. Since this is probably the only
use for unary tuples, it's not really worth the effort of treating
them as no_tag types, so we don't.
The type-infos for tuples have the same structure as for higher-order
types. There is a single type_ctor_info for tuples, and the arity
is placed before the argument type_infos.
library/parser.m:
Change the way '{}/N' terms are parsed, so that the parsed
representation is consistent with the way other functors
are represented (previously the arguments were left as
unparsed ','/2 terms). This avoids special case code
in prog_io__parse_qualified_term, term__term_to_type
and term__type_to_term.
compiler/prog_io_dcg.m:
compiler/prog_io_util.m:
Handle the new structure of '{}/N' terms when parsing DCG escapes
by converting the argument list back into a single ','/2 term.
compiler/module_qual.m:
Treat tuples as a builtin type.
compiler/typecheck.m:
Typecheck tuple constructors.
compiler/mode_util.m:
Propagate types into tuple bound insts.
compiler/type_util.m:
Add type_is_tuple/2 and type_id_is_tuple/1 to identify tuple types.
Add tuples to the list of types which are not atomic types.
Handle tuple types in `type_constructors' and
`get_cons_id_arg_types' and `switch_type_num_functors'.
compiler/tabling.m:
Handle tabling of tuples.
compiler/term_util.m:
Handle tuples in the code to compute functor norms.
compiler/magic_util.m:
compiler/rl.m:
compiler/rl_key.m:
Handle tuple types in the Aditi back end.
compiler/mercury_to_mercury.m:
library/io.m:
library/term_io.m:
Handle output of '{}/N' terms.
compiler/higher_order.m:
compiler/simplify.m:
Don't specialize complicated unifications of tuple
types into calls to a specific unification procedure --
even if the procedure were implemented, it probably
wouldn't be that much more efficient.
compiler/unify_proc.m:
Generate unification procedures for complicated unifications
of tuples (other than in-in unifications). These are generated
lazily as required.
compiler/make_hlds.m:
Export add_special_pred for use by unify_proc.m.
compiler/polymorphism.m:
Export polymorphism__process_pred for use by unify_proc.m.
compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/ml_code_util.m:
Handle unify procedure names and tags for tuple types.
compiler/mlds_to_c.m:
Output tuple types as MR_Tuple.
compiler/ml_unify_gen.m:
Compute the field types for tuples.
compiler/polymorphism.m:
compiler/pseudo_type_info.m:
Treat tuple type_infos in a similar way to higher-order type_infos.
compiler/hlds_data.m:
Document how cons_ids for tuple types are represented.
compiler/switch_gen.m:
compiler/table_gen.m:
Add tuple types to switches on type_util__builtin_type.
compiler/llds_out.m:
util/mdemangle.c:
profiler/demangle.m:
Transform items named "{}" to "f_tuple" when mangling symbols.
library/builtin.m:
Define the type_ctor_info used for tuples.
library/private_builtin.m:
Add `builtin_unify_tuple/2' and `builtin_compare_tuple/3',
both of which abort. All comparisons and in-in unifications
of tuples are performed by the generic unification functions
in runtime/mercury_ho_call.c and runtime/mercury.c.
library/std_util.m:
Implement the various RTTI functions for tuples.
Encode tuple `TypeCtorDesc's in a similar way to that
used for higher-order types. This has the consequence that the limit
on the arity of higher-order types is now MAX_VIRTUAL_REG,
rather than 2*MAX_VIRTUAL_REG.
Avoid calling MR_GC_free for the type-info vector returned
from ML_expand() for tuples because unlike the vectors
for du types, it is not copied.
runtime/mercury_type_info.h:
Add macros for extracting fields from tuple type-infos.
These just call the macros for extracting fields from higher-order
type-infos.
Add a macro MR_type_ctor_rep_is_variable_arity(), which
returns TRUE for tuples and higher-order types.
The distinction between higher-order and first-order types
is now misnamed -- the distinction is really between fixed arity
types and builtin variable arity types. I'm not sure whether
it's worth renaming everything.
runtime/mercury.h:
runtime/mercury.c:
Define unification and comparison of tuples in
high-level code grades.
runtime/mercury_deep_copy_body.h:
runtime/mercury_make_type_info_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
Handle tuple types in code which traverses data using RTTI.
tests/hard_coded/construct.{m,exp}:
tests/hard_coded/expand.{m,exp}:
Test RTTI functions from std_util.m applied to tuples.
tests/hard_coded/tuple_test.{m,exp}:
Test unification, comparison, term_to_type etc. applied to tuples.
tests/hard_coded/deep_copy.{m,exp}:
Test deep copy of tuples.
tests/hard_coded/typeclasses/tuple_instance.{m,exp}:
Test instance declarations for tuples.
tests/tabling/expand_tuple.{m,exp}:
Test tabling of tuples.
tests/hard_coded/write.m:
Add some module qualifications for code which uses
`{}/1' constructors which are not tuples.
tests/invalid/errors2.{m,err_exp,err_exp2}:
Test handling of tuples in type errors messages.
NEWS:
doc/reference_manual.texi:
w3/news/newsdb.inc:
Document tuples.
doc/transition_guide.texi:
Document the change to the parsing of '{}/N' terms.