library/*.m:
Delete Erlang foreign code and foreign types.
Delete documentation specific to Erlang targets.
library/deconstruct.m:
Add pragma no_determinism_warning to allow functor_number_cc/3
to compile for now.
library/Mercury.options:
Delete workaround only needed when targetting Erlang.
browser/listing.m:
mdbcomp/rtti_access.m:
Delete Erlang foreign code and foreign types.
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.
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
library/*.m:
mdbcomp/*.m:
ssdb/*.m:
Specify the type constructor for every inst definition that lists
the functors that values of that type may be bound to.
In library/maybe.m, delete the inst maybe_errors/1, because
(a) its name is misleading, since it is for the maybe_error/1 type (no s),
and (b) there is already an inst with the non-misleading name maybe_error
which had an identical definition.
In compiler/dep_par_conj.m, delete two insts that were duplicates
of insts defined in hlds_goal.m, and replace references to them
accordingly.
library/string.m:
Implement to_upper(in, uo) and to_lower(in, uo) with foreign
code, not creating intermediate character lists.
Implement to_upper(in, in) and to_lower(in, in) modes without
allocating memory.
Be more specific in documentation about which characters are
affected by some functions/predicates.
library/parsing_utils.m:
Be more specific in documentation for ikeyword/6.
(1) The behaviour of digit_to_int/2 was inconsistent with that of is_digit/2.
The former succeeds for all of 0-9, a-z and A-Z while the latter succeeds only
for 0-9 (i.e. it was possible for digit_to_int/2 to succeed for non-decimal
characters, which is not what was intended in many of it uses).
(2) Predicates involving hexadecimal digits were inconsistently named, they
were "hex digits" in one predicate name, "hex chars" in another.
This change ensures that the following operations are supported for binary,
octal, decimal and hexadecimal digits and that we use a consistent naming
scheme for the predicates that implement them:
- testing if a character is a digit of the given base
- conversion to an int
- conversion from an int
In addition, we also add predicates for supporting these operations for user
defined bases, ranging from 2-36.
library/char.m:
Add the predicate is_decimal_digit/1, which is a synonym for is_digit/1.
Add the predicate is_base_digit/2.
Add the predicates int_to_{binary,octal,decimal,hex}_digit/2 and
base_int_to_digit/3.
Add the predicates {binary,octal,decimal,hex}_digit_to_int/2 and
base_digit_to_int/3.
Add det function versions of the above.
Delete the function det_digit_to_int/1 that I added the other day.
Mark the following as obsolete:
- is_hex_digit/2
- int_to_hex_char/2
- int_to_digit/2
- det_int_to_digit/1
- det_int_to_digit/2
Avoid redundant module qualification in the implementation.
Mark some C foreign_procs as not modifying the trail.
Re-order some declarations according to how the coding standard says they
should be ordered.
library/bitmap.m:
library/integer.m:
library/parsing_utils.m:
library/string.m:
compiler/prog_rep_tables.m:
Replace calls to obsolete predicates or functions.
NEWS:
Announce the above changes.
Add note advising users of digit_to_int/2 to check their code for the
problem described above.
tests/hard_coded/Mmakefile:
tests/hard_coded/test_char_digits.m:
tests/hard_coded/test_char_digits.exp:
Add a systematic test for the above predicates.
Branches: main, 11.07
library/parsing_utils.m:
Let float_literal, float_literal_as_string accept an optional plus sign
in the exponent. This matches the syntax for Mercury and many other
languages.
tests/general/test_parsing_utils.m:
tests/general/test_parsing_utils.exp:
tests/general/test_parsing_utils.exp2:
Update test case.
Branches: main
Some simple additions to parsing_utils.
library/parsing_utils.m:
Add `input_string' and `get_skip_whitespace_pred'
so external parsers can also get access to these.
Add `next_char_no_progress'.
Clarify what is the default whitespace parser.
Branches: main, 11.07
In parsing_utils, don't use a wrapper over the provided skip whitespace
predicate. This incurred an additional higher-order call, and the use of the
`maybe' type incurred an extra memory allocation per successful call.
library/parsing_utils.m:
As above.
Branches: main, 11.07
parsing_utils.src_to_line_numbers crashed if given an input string
containing multi-code-unit characters, i.e. non-ASCII.
library/parsing_utils.m:
Rewrite src_to_line_numbers.
tests/general/test_parsing_utils.exp:
tests/general/test_parsing_utils.m:
Add test case.
tests/general/test_parsing_utils.exp2:
Add expected output for grades using UTF-16 string encoding.
Branches: main
Deprecate string.substring, string.foldl_substring, etc. in favour of
new procedures named string.between, string.foldl_between, etc.
The "between" procedures take a pair of [Start, End) endpoints instead
of Start, Count arguments. The reasons for this change are:
- the "between" procedures are more convenient
- "between" should be unambiguous. You can guess that it takes an End
argument instead of a Count argument without looking up the manual.
- Count arguments necessarily counted code units, but when working with
non-ASCII strings, almost the only way that the values would be arrived at
is by substracting one end point from another.
- it paves the way for a potential change to replace string offsets with an
abstract type. We cannot do that if users regularly have to perform a
subtraction between two offsets.
library/string.m:
Add string.foldl_between, string.foldl2_between,
string.foldr_between, string.between.
Deprecate the old substring names.
Replace string.substring_by_codepoint by string.between_codepoints.
compiler/elds_to_erlang.m:
compiler/error_util.m:
compiler/rbmm.live_variable_analysis.m:
compiler/timestamp.m:
extras/posix/samples/mdprof_cgid.m:
library/bitmap.m:
library/integer.m:
library/lexer.m:
library/parsing_utils.m:
mdbcomp/trace_counts.m:
profiler/demangle.m:
Conform to changes.
tests/general/Mercury.options:
tests/general/string_foldl_substring.exp:
tests/general/string_foldl_substring.m:
tests/general/string_foldr_substring.exp:
tests/general/string_foldr_substring.m:
tests/hard_coded/Mercury.options:
tests/hard_coded/string_substring.m:
Test both between and substring procedures.
tests/hard_coded/string_codepoint.exp:
tests/hard_coded/string_codepoint.exp2:
tests/hard_coded/string_codepoint.m:
Update names in test outputs.
NEWS:
Announce the change.
Branches: main
Fix some problems with non-ASCII strings.
compiler/error_util.m:
Make string formatting routines count code points instead of code
units.
Iterate over non-ASCII strings correctly.
compiler/llds_out_data.m:
compiler/stack_layout.m:
Explicitly count UTF-8 code units when counting the length of strings
that will be written to C source files, in case the compiler is built
in a grade which uses some other encoding. (The length argument to
the `MR_string_const' macro isn't actually used, so that change won't
have any practical effect.)
compiler/inst_check.m:
compiler/mercury_to_mercury.m:
compiler/structure_reuse.direct.choose_reuse.m:
Fix some code unit counts which should be code point counts.
compiler/make.m:
Iterate over non-ASCII characters correctly.
compiler/passes_aux.m:
Simplify the implementation of `stage_num_str'.
compiler/timestamp.m:
Make `string_to_timestamp' handle non-ASCII strings cleanly,
although they should never occur.
compiler/x86_64_out.m:
Split long comments at code point boundaries.
compiler/elds_to_erlang.m:
compiler/erl_code_gen.m:
compiler/mlds_to_cs.m:
compiler/pickle.m:
compiler/switch_util.m:
Add some comments relating to non-ASCII characters.
library/parsing_utils.m:
Fix the string and keyword parsers to work on non-ASCII characters.
library/pprint.m:
library/pretty_printer.m:
Fix code unit counts which should be code point counts.
library/string.m:
Add `count_utf8_code_units'.
Fix the portable implementation of `string.to_char_list' (not
actually used) to work on non-ASCII strings.
Make string formatting routines count code points instead of code
units.
library/term_io.m:
Use a direct string comparison to check string is non-empty.
tests/general/test_parsing_utils.exp:
tests/general/test_parsing_utils.m:
tests/hard_coded/test_pretty_printer.exp:
tests/hard_coded/test_pretty_printer.m:
Test non-ASCII strings.
Branches: main
Change the behaviour of parsing_utils.separated_list to return an
empty list instead of failing if its ho argument doesn't match
any input, as documented in the comments.
library/parsing_utils.m:
As above.
tests/general/test_parsing_utils.exp:
tests/general/test_parsing_utils.m:
Expect empty lists from separated_list and comma_separated_list.
Estimated hours taken: 2
Branches: main
Turn the whitespace skipping function into a semidet
predicate with the same signature as all the other parsing
predicates.
Sometimes you want whitespace skipping to fail, for example
if there is no matching '*/' in a C style comment.
library/parsing_utils.m:
Make the whitespace skipping function a predicate.
tests/general/test_parsing_utils.m:
tests/general/test_parsing_utils.exp:
Test failure of whitespace skipping predicate.
Estimated hours taken: 2
Branches: main, release
Make the system compiler with --warn-unused-imports.
browser/*.m:
library/*.m:
compiler/*.m:
Remove unnecesary imports as flagged by --warn-unused-imports.
In some files, do some minor cleanup along the way.
library/parsing_utils.m:
Fix a mismatch between the order of the arguments in the
documentation of predicate identifier/6 and the actual arguments.
Minor formatting changes intended to maintain consistency
in the library reference guide.
Fix a spelling error.
useful error messages by recording the progress of the parser
in a mutable and adding a parse/4 predicate that will return the
furthest the parser got if it failed (often this is sufficient to
see where the problem is).
Introduce a fail_with_message predicate that can be used in
conjunction with the new parse/4 predicate to return custom errors.
Add a case-insensitive version of the keyword predicate.
Fix a bug in whitespace/4.
library/parsing_utils.m:
As above.
Fix a bug in whitespace/4 where it was using char.is_whitespace
for the first character, but then calling the user defined whilespace
function.
tests/general/test_parsing_utils.exp:
tests/general/test_parsing_utils.m:
Test the new features.
Estimated hours taken: 4
Branches: main
Fix bugs in parsing_utils when converting offsets to line numbers and
positions. One problem was that it was trying to index a zero length array
when there was only one line in the source string. Another bug was that it was
using the wrong offset to compute the position.
library/parsing_utils.m:
Add a comment explaining what the line_numbers array is meant to
contain.
Include the last line in the line_numbers array, so we never end
up with an empty array.
Fix the calculation of the position by computing the offset of
the beginning of the line containing the offset in question and
using that to work out the position (instead of using the offset
of the following line).
tests/general/test_parsing_utils.exp:
tests/general/test_parsing_utils.m:
Test offset_to_line_number_and_position.
Estimated hours taken: 2
Branches: main
library/parsing_utils.m:
Add support for parsers that update their own state (e.g., a symbol
table). Add support for user-defined whitespace specification (e.g.,
to include comments). Add support for converting offsets into line
numbers (e.g., for error reporting).
tests/general/test_parsing_utils.m:
tests/general/test_parsing_utils.exp:
Update the test case.
parsers.
NEWS:
Report the addition of parsing_utils.m to the library.
library/library.m:
Include parsing_utils.m.
library/parsing_utils.m:
Added.
library/string.m:
Make string.to_int fail on overflow. Amend comments to reflect this.
tests/general/Mmakefile:
tests/general/test_parsing_utils.exp:
tests/general/test_parsing_utils.m:
Test case for parsing_utils.m.