Commit Graph

33 Commits

Author SHA1 Message Date
Peter Ross
cc38915026 Allow the term (x fun y) to be expanded to fun(x,y).
Estimated hours taken: 5

Allow the term (x `fun` y) to be expanded to fun(x,y).

library/lexer.m:
    Handle the backquote token.

library/parser.m:
    Do the term transformation as the program is parsed.
1999-07-12 07:44:37 +00:00
Thomas Conway
5c955626f2 These changes make var' and term' polymorphic.
Estimated hours taken: 20

These changes make `var' and `term' polymorphic. This allows us to make
variables and terms representing types of a different type to those
representing program terms and those representing insts.

These changes do not *fix* any existing problems (for instance
there was a messy conflation of program variables and inst variables,
and where necessary I've just called varset__init(InstVarSet) with
an XXX comment).

NEWS:
	Mention the changes to the standard library.

library/term.m:
	Make term, var and var_supply polymorphic.
	Add new predicates:
		term__generic_term/1
		term__coerce/2
		term__coerce_var/2
		term__coerce_var_supply/2

library/varset.m:
	Make varset polymorphic.
	Add the new predicate:
		varset__coerce/2

compiler/prog_data.m:
	Introduce type equivalences for the different kinds of
	vars, terms, and varsets that we use (tvar and tvarset
	were already there but have been changed to use the
	polymorphic var and term).

	Also change the various kinds of items to use the appropriate
	kinds of var/varset.

compiler/*.m:
	Thousands of boring changes to make the compiler type correct
	with the different types for type, program and inst vars and
	varsets.
1998-11-20 04:10:36 +00:00
Fergus Henderson
3918c620e4 Fix a bug: according to the ISO Prolog standard, it should allow
Estimated hours taken: 0.5

library/parser.m:
	Fix a bug: according to the ISO Prolog standard, it should allow
	terms of the form `{}(foo)' or `[](foo)'.

tests/valid/Mmakefile:
tests/valid/parsing_bug.m:
tests/valid/parsing_bug_main.m:
	Regression test.
1998-11-11 00:13:43 +00:00
Fergus Henderson
986b631dc6 Add code to parse terms from strings rather than from streams.
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.)
1998-05-21 16:52:20 +00:00
Fergus Henderson
7cb525fde3 Undo Zoltan's bogus update of all the copyright dates.
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).
1998-01-23 12:33:43 +00:00
Zoltan Somogyi
9ae7acc593 Update all the copyright dates for 1998.
Estimated hours taken: 0.5

library/*.m:
	Update all the copyright dates for 1998.
1998-01-13 10:01:32 +00:00
Fergus Henderson
65da88ffd7 Define a new predicate to create a new named variable.
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.
1997-10-09 13:45:05 +00:00
Fergus Henderson
522265ccba Change the representation of token lists to be a fat list
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.
1997-10-09 13:43:11 +00:00
Fergus Henderson
1858d68984 Minor efficiency improvement.
Estimated hours taken: 0.25

library/parser.m:
	Minor efficiency improvement.
1997-09-06 17:39:58 +00:00
Fergus Henderson
04b720630b Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne".
1997-07-27 15:09:59 +00:00
Fergus Henderson
6a1a8b9645 Make the syntax for higher-order code a bit nicer.
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).
1996-12-10 08:48:55 +00:00
Fergus Henderson
5306a2c5a9 Fix a bug in the parser -- it misparsed -1 * X' as -(1 * X)'
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).
1996-07-18 21:50:19 +00:00
Fergus Henderson
dfff30fafb Implement a new `:- pragma source_file("<source file name>").' declaration,
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.
1996-07-03 13:22:05 +00:00
Fergus Henderson
23b3e9d352 Undo dylan's changes in the names of some library entities,
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.
1996-02-03 17:37:07 +00:00
Dylan Shuttleworth
4ad88ec6c0 Change predicate names with badly placed double underscores.
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.
1995-12-29 03:29:45 +00:00
Dylan Shuttleworth
eade28c8b1 Allow predicate and mode definitions, and predicate calls to have
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__*'.
1995-10-17 04:55:22 +00:00
Fergus Henderson
fa5226ee67 Improve the documentation.
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'.
1995-10-05 11:31:52 +00:00
Thomas Conway
858e9db47d parser.m varset.m: see above changes. 1995-09-01 07:56:57 +00:00
Fergus Henderson
b0351fbeb4 Add copy/2.
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.
1995-08-02 07:20:49 +00:00
Fergus Henderson
08f2b30266 Remove obsolete comment.
parser.m:
	Remove obsolete comment.
1995-07-18 06:36:00 +00:00
Fergus Henderson
77a0272d8d Fix all the obsolete comments referring to `foo.nl' instead of
library/*.m:
	Fix all the obsolete comments referring to `foo.nl' instead of
	`foo.m'.
1995-07-17 12:51:25 +00:00
Fergus Henderson
0de0e90786 Fix misleading error message pointed out by Philip Dart.
parser.m:
	Fix misleading error message pointed out by Philip Dart.
	I just hope this fix doesn't cause any problems elsewhere.
1995-06-19 09:40:10 +00:00
Zoltan Somogyi
a91d63485b Minor formatting changes.
parser.m:
	Minor formatting changes.
1995-06-17 03:46:53 +00:00
Fergus Henderson
9201a07d59 Fix "off-by-one" bug in the error messages.
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.)
1995-05-04 16:55:43 +00:00
Fergus Henderson
d67ae400ed Fix parsing bug pointed out by Bart - we didn't
parser.m:
	Fix parsing bug pointed out by Bart - we didn't
	handle "A*(B+C)" unless there was a space after the "*".
1995-05-01 11:28:49 +00:00
Fergus Henderson
eefbfd552c Improve error messages a bit more.
parser.m:
	Improve error messages a bit more.
1995-05-01 08:14:26 +00:00
Fergus Henderson
1206c509ea Fix bug with parsing lists introduced in previous change.
parser.m:
	Fix bug with parsing lists introduced in previous change.
	Improve the error messages a bit more.
1995-04-22 11:38:38 +00:00
Fergus Henderson
f13ff782f7 Provide much more detailed diagnostics.
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.
1995-04-21 16:24:15 +00:00
Fergus Henderson
93a755d563 Add copyright notices.
library/*:
	Add copyright notices.
1995-03-28 16:19:34 +00:00
Fergus Henderson
77b16b11d9 Implement floating point.
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.
1995-03-15 14:28:24 +00:00
Fergus Henderson
3825a4c724 Remove unused `:- import_module prog_io.'
parser.nl:
	Remove unused `:- import_module prog_io.'
1995-02-08 06:01:00 +00:00
Fergus Henderson
3e4b209d6b Store the operator table from ops.nl in the io_state.
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!
1995-01-30 13:35:00 +00:00
Fergus Henderson
4b07b5a58f Change some dodgy syntax since it violated ISO Prolog syntax rules:
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.
1995-01-29 17:34:09 +00:00