Estimated hours taken: 24
Add code to parse terms from strings rather than from streams.
The original intention for this change was twofold:
to increase expressiveness and to improve efficiency.
However, for the moment I have given up on the goal of
improving efficiency.
library/io.m:
Add io__read_file_as_string/{4,5}, for efficiently
reading a whole file into a single string.
Add io__read_from_string/5, for reading terms of
any type from a string.
(Should that instead be named string__read instead?)
library/string.m:
Implement string__substring/4 more efficiently,
using `pragma c_code' rather than by calling
string__right(string__left(...)).
Export string__unsafe_index/3, and add new exported
predicate string__unsafe_substring/4 -- these
are versions of string__index and string__substring
that don't check for range errors. They are
needed to get reasonable efficiency when dealing
with very large strings.
library/string.nu.nl:
Add Prolog implementations of string__substring
and string__unsafe_substring.
library/lexer.m:
Add lexer__string_get_token_list/{5,6}, for parsing
tokens from a string. This required adding
`string_' versions of most of the lexical analysis routines.
XXX lots of code duplication, I'm afraid.
XXX the string versions are not as efficiency as they
could ideally be.
library/parser.m:
Add new predicates parser__read_term_from_string/{4,6}
and parser__parse_token_list.
compiler/bytecode_gen.m:
compiler/error_util.m:
compiler/fact_table.m:
compiler/term_errors.m:
Minor changes to use term__context as an ADT rather than
as a concrete data type.
In addition, I made the following changes, which I am NOT committing.
compiler/prog_io.m:
Change to use io__read_file_as_string and
parser__read_term_from_string.
(Not committed because the existing method is
in currently more efficient.)
library/term.m:
Add new alternative term__detailed_context to the term__context type.
This alternative can record both the start and end of a term rather
than just the end.
(The lexer now has almost all the necessary support for detailed
contexts, but enabling it would have some potentially significant
efficiency costs, and curently the parser uses only single contexts
rather than ranges; so currently this is not used.)
Estimated hours taken: 0.5
library/*.m:
compiler/*.m:
Undo Zoltan's bogus update of all the copyright dates.
The dates in the copyright header should reflect the years
in which the file was modified (and no, changes to the
copyright header itself don't count as modifications).
Estimated hours taken: 0.25 + unknown by zs
[zs was the real author of this change]
library/varset.m:
Define a new predicate to create a new named variable. Previously
this required to separate operations, creating a variable and
giving it a name. Using the new predicate reduces memory consumption.
library/parser.m:
Use the new predicate in varset.m.
Estimated hours taken: 0.25 + unknown by zs
[zs was the real author of this change]
library/lexer.m:
Change the representation of token lists to be a fat list
instead of a list of pairs, since this reduces memory
consumption, the number of calls to the memory allocator,
and the amount of indirection required to access tokens.
library/parser.m:
Use the new token list representation.
Estimated hours taken: 3
Make the syntax for higher-order code a bit nicer.
library/parser.m:
Allow the syntax
Foo(Arg1, ..., ArgN)
and parse it as the term
''(Foo, Arg1, ..., ArgN).
Estimated hours taken: 1
Fix a bug in the parser -- it misparsed `-1 * X' as `-(1 * X)'
rather than as `(-1) * X'. (The ISO Prolog standard says that
the latter is correct.)
library/parser.m:
Rearrange the code in parse_left_term so that it checks for
negative numbers before checking for prefix operators, and
so that it gives `-1' a precedence of 0 rather than the
precedence of unary minus (which is 500).
Estimated hours taken: 2
Implement a new `:- pragma source_file("<source file name>").' declaration,
and a `#<line number>' directive, to make it more convenient to use
preprocessors or to use Mercury as a target language.
io.m:
Add predicates io__set_line_number/3 and /4, for use by lexer.m.
lexer.m:
Implement the new `#<line number>' directive.
Check for tokens of the form `#[0-9]*\n', and when one is
found, call io__set_line_number and then skip that token.
parser.m:
Add a new predicate parser__read_term/4. This is the same
as parser__read_term/3, except that the new first argument
specifies the name of the source file. This is used by
compiler/prog_io.m to handle `pragma source_file' declarations.
Estimated hours taken: 1.5
Undo dylan's changes in the names of some library entities,
by applying the following sed script
s/term_atom/term__atom/g
s/term_string/term__string/g
s/term_integer/term__integer/g
s/term_float/term__float/g
s/term_context/term__context/g
s/term_functor/term__functor/g
s/term_variable/term__variable/g
s/_term__/_term_/g
s/std_util__bool_/bool__/g
to all the `.m' and `.pp' files in the compiler and library directories.
The reason for undoing these changes was to minimize incompatibilities
with 0.4 (and besides, the changes were not a really good idea in the first
place).
I also moved `bool' from std_util.m to a separate module.
The main reason for that change is to ensure that the `__' prefix is
only used when it genuinely represents a module qualifier.
(That's what dylan's changes were trying to acheive, but `term__'
does genuinely represent a module qualifier.)
library/bool.m:
New file, containing stuff previously in std_util.m.
library/*.m:
Apply sed script above;
where appropriate, add `bool' to the list of imported modules.
Estimated hours taken: _2___
Change predicate names with badly placed double underscores. This was
automated with script/remove____from_library.sedscript. Similar changes have
been made to the compiler.
library/mercury_builtin:
term types of the form "term__*" are now "term_*".
The `type' bool is now "std_util__bool_" instead of "bool__"
library/ the rest:
Use the different built-in names.
compiler/*
Allow predicate and mode definitions, and predicate calls to have
module qualifiers. This allows a restricted form of predicate
name overloading.
compiler/llds.m, prog_io.m
In addition to above, these modules now write some labels in `*.c'
output files with module-name qualifiers. Predicate `main/2',
predicates of `mercury_builtin' and special predicates with names
like `__*__' are not qualified.
compiler/mercury_to_goedel.m
This module is probably a little more broken than before, as
module:qualifiers are ignored.
library/char.*, *
Change some predicate names from `char_*' to `char__*' for better
consistency, nicer `c' labels.
library/*, compiler/*
Change calls to predicates `char_*' to `char__*'.
library/*.m:
Improve the documentation.
Add a "Stability: low/medium/high" comment to all modules,
which describes the stability of the interface to that module.
ops.m:
Add `:' as an infix operator.
require.m:
Implement require/1, since higher-order predicates now work.
term.m:
Use the type `comparison_result' from mercury_builtin.m,
rather than defining an identical type `comparison'.
library/mercury_builtin.m:
Add copy/2.
library/io.m:
Change io__get/set_globals to use unique modes.
Add a few calls to copy/2 to make things work.
library/*.m:
Add unique modes to a few predicates.
Remove unique modes in a couple of cases where they didn't work.
parser.m:
Fix "off-by-one" bug in the error messages.
(The parser was using the token_context for the
token *after* the one that caused the error, not for
the token that actually caused the error.)
parser.m:
Provide much more detailed diagnostics.
Also fix a bug: operators should not be parsed
as names unless they are enclosed in parentheses.
lexer.m:
Add lexer__token_to_string, so that parser.m can
use it for error messages.
ops.m:
Add ops__lookup_option, so that parser.m can use it
in the above bug fix.
code_util.nl, float.nl, llds.nl, mercury_builtin.nl, opt_debug.nl,
parser.nl, polymorphism.nl, sp_lib.nl, string.nl, string.nu.nl,
type_util.nl, typecheck.nl, unify_gen.nl:
Implement floating point.
Makefile.common:
Remove `-include test.dep' line. Use Mmake.
int.nl:
Update a few of the comments.
io.nu.nl:
For Sicstus Prolog, if main/2 is not defined then enter the
debugger.
io.nl:
Store the operator table from ops.nl in the io_state.
term_io.nl, term_io.nu.nl:
Use the operator table from ops.nl rather than using
the NU-Prolog builtin operator table.
parser.nl:
When constructing the term_context for the parsed term,
use the name of the _input_ stream, not the output stream!
llds.nl, io.nu.nl:
Change some dodgy syntax since it violated ISO Prolog syntax rules:
parenthesized all occurrences of '|', put '$mainloop' in quotes.
lexer.nl:
Allow NU-Prolog style octal escapes as well as ISO Prolog style ones.
library.nl, parser.nl, ops.nl:
Add parser.nl and ops.nl to the library.
varset.nl:
Add the reverse mode of varset__lookup_name, so you can lookup
the variable with a particular name.