Commit Graph

197 Commits

Author SHA1 Message Date
Fergus Henderson
f591233502 Fix bug in mode declaration.
interpreter.nl:
	Fix bug in mode declaration.

hlds.nl, mercury_to_mercury.nl:
	Fix mode error in mercury_to_mercury.nl.

modes.nl:
	Fix bug in handling of `erroneous' preds.
	Fix a bunch of other errors including some mode errors.

prog_io.nl:
	Fix type error introduced by last change.
	Fix mode error in DCG expansion code.

type_util.nl:
	Work around scoping problem with \=.

typecheck.nl:
	Fix mode error.
1994-05-11 18:29:20 +00:00
Fergus Henderson
02e97f01f4 Handle is erroneous' and is failure' proc declarations.
prog_io.nl, hlds.nl, modes.nl, mercury_to_mercury.nl, require.nl:
	Handle `is erroneous' and `is failure' proc declarations.
	Add `is erroneous' to the declaration of error/1.

prog_io.nl:
	Report errors in proc declarations instead of just
	ignoring them.

hlds.nl:
	Fix a mode error (variable numbering error) detected by the
	mode checker.

modes.nl:
	Fix a minor formatting problem in error message.

mercury_builtin.nl:
	Change the work-around for higher-order predicate modes
	so that it doesn't cause mode errors.
1994-05-11 08:39:25 +00:00
Fergus Henderson
1687d301e5 - Add a new inst `not_reached' (intended for internal use by the
prog_io.nl:
	- Add a new inst `not_reached' (intended for internal use by the
	  compiler, but for the moment at least we also allow it in user
	  code).
	- Parse abstract inst definitions, with the syntax
		:- inst foo is private.

type_util.nl, typecheck.nl, codegen.nl, Makefile, doit.nl:
	- Add a new module `type_util'.
	- Move make_type_id from typecheck.nl to type_util.nl.
	- Rename vartype_to_type as classify_type, move it from
	  codegen.nl to type_util.nl, and modify the interface slightly.
	- Move the type_is_enumeration stub from codegen.nl to type_util.nl,
	  and implement it.
	- Implement type_is_atomic.

modes.nl:
	- Distinguish between simple_unify's and complicated unifies by
	  calling type_is_atomic.
	- Check that the final insts of the head vars match that specified
	  by the mode declaration.
	- Handle (some cases of) unreachable code, using the `not_reached'
	  inst.  More work needed on this.
	- Improve the error message in the case where there is a single
	  delayed goal in a conjunction.  (Instead of printing out the
	  generic "mode error in conjunction" message, we now print out
	  the error message for the delayed goal in question.)
	- Fix bug where it didn't realize that bound('.'(ground, ground))
	  was the same as ground (due to missing clauses for inst_is_compat_3).

Most of these changes have not yet been tested.
1994-05-10 14:03:03 +00:00
Fergus Henderson
0ad664520e Rename various things for consistency:
s/term_functor/term__functor/g
	s/term_atom/term__atom/g
	s/term_string/term__string/g
	s/term_int/term__int/g
	s/term_float/term__float/g
	s/term_variable/term__variable/g

	/:- mode.*[^a-zA-Z_]input,/s/input,/in,/g
	/[^a-zA-Z_]input,.*)/s/input,/in,/g
	/:- mode.*[^a-zA-Z_]output,/s/output,/out,/g
	/[^a-zA-Z_]output,.*)/s/output,/out,/g

	/:- mode.*[^a-zA-Z_]input)/s/input)/in)/g
	/:- mode.*[^a-zA-Z_]output)/s/output)/out)/g

	/[a-z]info/s/info/_info/g
	/__info/s/__info/_info/g
1994-05-03 12:28:54 +00:00
Fergus Henderson
1d69a71f41 Implement mode-checking for constants and functors.
modes.nl:
	Implement mode-checking for constants and functors.

hlds.nl, hlds_out.nl, make_hlds.nl, codegen.nl:
	Change the `cons_id' type so that it can handle constants of
	the builtin types int, string, and float.
	Also make codegen.nl handle character constants.

mercury_builtin.nl:
	Trivial fix of comment.

prog_io.nl:
	Fix capitalization in warning message.

followvars.nl:
	A couple of bug fixes.
1994-04-13 16:41:14 +00:00
Fergus Henderson
3b1487eef7 Change mode_is_input and mode_is_output so that abstract
hlds.nl:
	Change mode_is_input and mode_is_output so that abstract
	insts are assumed to be bound.

	Add predicate `inst_is_ground'.
	Add predicate `moduleinfo_set_num_errors'.

	Also change instmap_delta back into a map again (probably a mistake! -
	but I'll fix it later).

map.nl:
	Add predicate `map__from_sorted_assoc_list'.

mercury_to_mercury.nl:
	Export `mercury_output_inst' and `mercury_output_mode_list'.

modes.nl:
	Lots of changes.  It should be almost useable now.

options.nl:
	Add a new --modecheck option to invoke the mode checker.
	This is disabled by default since the modechecker doesn't
	quite work yet.

parser.nl:
	Remove obsolete comment.

prog_io.nl:
	Ensure that the bound insts in a bound(...) list are in sorted
	order.

set.nl:
	Add predicate `set__sorted_list_to_set'.

toplevel.nl:
	Changed to match the new interface to `modecheck'.
	Also don't generate code if there were any errors detected by
	make_hlds.

typecheck.nl:
	Fix a couple of minor typos in the error messages.
1994-04-11 15:40:29 +00:00
Fergus Henderson
b74db7d040 More performance improvements. 1994-03-28 05:49:07 +00:00
Fergus Henderson
9c3d102cd5 (1) Add a singleton variable warning (and an option to turn it off).
(2)  Fix the singleton variable warnings in prog_io.nl (found and fixed
     a bug in the DCG expansion).

(3)  Improve the error reporting in typecheck.nl

(4)  Improve the layout of error messages.
1994-03-25 23:38:49 +00:00
Fergus Henderson
0e9e503507 Fix bug in DCG expansion of terminal lists.
prog_io.nl:
	Fix bug in DCG expansion of terminal lists.
1994-03-22 12:06:01 +00:00
Fergus Henderson
5f75f6cda4 Fix bug.
prog_io.nl:
	Fix bug.
1994-03-22 05:47:50 +00:00
Fergus Henderson
ba1a19a4de Add an XXX comment.
llds.nl:
	Add an XXX comment.

--------------------

options.nl, prog_io.nl:
	Add a -I option.

--------------------

bintree.nl:
	Add predicates to work out the depth and number of items
	in a bintree.
map.nl:
	Make the fact that maps are bintrees externally visible,
	so that toplevel.nl can print out some stats about some maps.
toplevel.nl:
	Print out some stats about the pred, type, and cons maps.
1994-03-21 10:38:31 +00:00
Fergus Henderson
92d1371b4c New file: converts the prog_io data structure back into Mercury source
mercury_to_mercury.nl:
	New file: converts the prog_io data structure back into Mercury source
	code.

term_io.nl:
	Export mercury_quote_string for use by mercury_to_mercury.nl.

Makefile, doit.nl:
	Add mercury_to_mercury.

options.nl, toplevel.nl:
	Add a new option to save the interface of a module to a `.int' file,
	using mercury_to_mercury.

Makefile:
	Modify the rule for the `clean' target so that it removes `.int' files.

mercury_builtin.nl:
	Fix the module name.

std_util.nl:
	Suppress warnings from nit.
1994-03-14 14:53:58 +00:00
Fergus Henderson
5b3da4cdde An error message was omitting the file name & line number.
prog_io.nl:
	An error message was omitting the file name & line number.
	Also ensure that all error messages start with "error:".

codegen.nl, interpreter.nl, bintree.nl, list.nl:
	Fix stuff detected by nit.

make_hlds.nl:
	Transform to `semi-homogeneous' form (still need to expand
	unifications).

prog_util.nl:
	Fix bug.

mercury_builtin.nl:
	Add call/1.

hlds.nl:
	Add a count of the number of errors and warnings to the module_info
	data structure.

toplevel.nl:
	Continue processing after syntax errors.
1994-03-12 06:00:36 +00:00
Fergus Henderson
30f46e92b0 New file. At the moment it just checks for undefined modes and
modes.nl:
	New file.  At the moment it just checks for undefined modes and
	undefined insts.

Makefile, doit.nl:
	Add new files modes.nl and prog_util.nl.

term.nl:
	Add term__var_to_int.

toplevel.nl:
	Call the mode checker.

prog_io.nl, make_hlds.nl, hlds.nl:
	Allow for the possibility of abstract `inst' definitions,
	just like abstract type definitions.  Currently they
	are allowed for in the data structure, but they aren't
	parsed correctly, and the utilities in hlds.nl don't handle
	them that well.

hlds.nl:
	Move `unqualify_name' to prog_util.nl.

make_hlds.nl:
	Move `split_types_and_modes' to prog_util.nl.

mercury_to_goedel.nl, toplevel.nl:
	Move the equivalence type expansion code to prog_util.nl.

builtin.nl, toplevel.nl:
	Add a new module `builtin.nl' which gets automatically imported
	into every module.  In it, define the standard modes input,
	output, etc., and various other stuff.

std_util.nl:
	Move the defintion for \= to builtin.nl.
	Remove the definition of ~=.

prog_io.nl:
	Export parse_goal/2, since it's used by mercury_to_goedel.

mercury_to_goedel.nl:
	Fix various type errors.

list.nl, int.nl, io.nl, codegen.nl, det_analysis.nl, llds.nl, hlds_out.nl:
	Fix various syntax errors, typos and errors in type and mode
	declarations discovered by mercury_compile.
1994-03-04 12:39:43 +00:00
Fergus Henderson
8da0e9cb59 Modified io__read_term in term_io.nl to return the line number with
syntax errors, so that prog_io.nl can get an accurate line number for
them.  (Also had to modify interpreter.nl since it called io__read_term.)
1994-02-23 11:34:17 +00:00
Fergus Henderson
13ef3d2ea6 prog_io.nl: fix bugs in the DCG expansion. 1994-02-23 00:36:03 +00:00
Fergus Henderson
ba8368ce10 Expand DCG clauses in prog_io.nl rather than use NU-Prolog's expandTerm
in term_io.nu.nl.  NOT YET TESTED!
1994-02-22 06:57:17 +00:00
Fergus Henderson
f0870f671e Everywhere: replace variable' with var'.
parser.nl: did some more work on this
1994-02-18 06:03:28 +00:00
Fergus Henderson
02c2a93c4c typecheck.nl: A couple of minor fixes; fix bug with constants of builtin types.
Optimize for the common case of non-polymorphic types & predicates.

term.nl: Rename term__apply_substitution as term__apply_rec_substitution
	and add a new term__apply_substitution for when you want
	non-recursive application.  Fix logic bug in
	term__substitute_corresponding.

varset.nl: Fix logic bug in varset__merge.

io.nu.nl: Fix typo in error message.

term_io.nu.nl: Fix bug in the code used to work-around the NU-Prolog
	getToken bug for empty strings.

prog_io.nl: Fix bug: the string "\+" should have been "\\+".
	Also fixed LOTS of type errors (discovered by the typechecker,
	hurray it now works!).

int.nl, list.nl, std_util.nl: Added pred & mode declarations for some
	NU-Prolog predicates that we are using.
1994-02-10 15:02:25 +00:00
Fergus Henderson
356748aaf5 toplevel.nl: write hlds dump to a file, not to stdout
toplevel.nl, mercury_to_goedel.nl, hlds.nl:
move unqualify_name/2 to hlds.nl.

typecheck.nl: Fix design problem with typevarsets; fix bug where I had
forgotten to rename apart the types for constructors.

prog_io.nl, prog_out.nl: improve error messages.

various: inlined calls to require/2 to improve efficiency.

various: added an extra arg to io__progname to specify the default
	 in case the program name isn't available.
1994-02-10 09:35:55 +00:00
Fergus Henderson
1e4edbe9fc Bug fixes.
Also rearranged the interface declarations in a couple of modules.
1994-02-02 11:24:56 +00:00
Fergus Henderson
55839f463c builtins.nl: added `when' declarations.
bintree.nl: modified tree structure slighyl to improve efficiency.

io.nl, io.nu.nl: added predicate io__stream_name and code to keep track
	of the name of each stream.

term.nl: store filenames as part of term__context.
prog_out.nl: print out the filename part of a term__context
term_io.nl: initialize the filename when reading in a term

list.nl: add member_chk/2.

various places: replace `integer' with `int'.

did a bit more work on the type-checker.  It now runs without crashing,
although the results are still buggy.

toplevel.nl: added code to read in a module and all the modules
	that it depends upon.

added code to handle abstract type definitions.
1994-01-28 18:54:25 +00:00
Fergus Henderson
843462bbb9 io.nl & io.nu.nl: add predicates dealing with streams.
prog_io.nl: fix bug where binop_to_term returned a list in the reverse order.

mercury_to_goedel.nl: write diagnostics to stderr instead of stdout.
1994-01-26 02:57:50 +00:00
Fergus Henderson
532c27523f Split io.nl into io.nl and term_io.nl.
Moved most of the non-logical NU-Prolog code from io.nl and term_io.nl into
io.nu.nl and term_io.nu.nl respectively.  Rewrote the rest in logical Mercury.
Modified io__write_term to escape string constants if necessary.

Added char.nl and moved some of the predicates in string.nl into char.nl.
Rewrote some of the predicates in these files to avoid NU-Prolog dependencies.
Added a few new predicates.

Modified mercury_to_goedel.nl to correctly output variable names without
any danger of name clashes.  Also modified it to correctly escape string
constants.  Also modified it to correctly output functor names even
for nasty functors.

Did a little more work on the typechecker.

Moved the non-logical NU-Prolog code in require.nl into require.nu.nl.

Fix bug in prog_io.nl where combined type-and-mode declarations were
getting reversed.

Modified io.nu.nl and require.nu.nl so that calls to error/1 will
actually cause the program to abort.

In prog_io.nl: allow "\+" as a synonym for "not".
1994-01-25 13:48:40 +00:00
Fergus Henderson
9ba4a542e0 Added code to parse determinacy annotations.
Also misc. bug fixes.
1994-01-24 14:07:19 +00:00
Fergus Henderson
6a30dbd726 - Replaced "import_module integer" with "import_module int".
- Added some new targets to the Makefile.
- In mercury_to_goedel.nl: handle calls to require/2.
- Replaced "require(fail, ...)" with "error(...)".
- Removed uses of floating point division in array.nl.
- Changed io__progname to take two io__state arguments.
- Removed direct references to $string from io.nl so that it is self-applicable.
- Added pair.nl and changed map.nl to use it.
1994-01-24 10:04:04 +00:00
Fergus Henderson
88b37f2c0b - Add code to silently ignore NU-Prolog `when' declarations (rather than
reject them as syntax errors).
- Change predicates in term.nl to use `term__' prefix instead of `term_'.
- Change predicates in string.nl to use `string__' prefix instead of `string_'.
- Change the types in prog_io.nl so that they store determinism
  annotations for mode and predicate declarations (the code still needs
  to be fixed to parse these new annotations.)
- Add some new predicates to term.nl.
- Did some more work on mercury_to_goedel.nl.
- Various bug fixes.
1994-01-24 03:36:42 +00:00
Fergus Henderson
24c7643b8d Fix bug whereby `some [Vars] Goal' was not being parsed correctly.
Allow `A->B;C' as a synonym for `if A then B else C', and `A->B'
as a synonym for `if A then B'.
1994-01-19 16:14:34 +00:00
Fergus Henderson
5c094a8cb4 Fix typos in error messages. 1994-01-18 07:13:30 +00:00
Fergus Henderson
fc6695ac39 Store a term_context (line number) in various important places
in the hlds.  Add line numbers to all the error messages produced
by make_hlds.nl.
1994-01-10 13:07:06 +00:00
Fergus Henderson
3ddf6bfb05 Improved error reporting in the parser: it now reports the line number
where the error occurred.
Note that line numbers are still not stored in the hlds yet, so
we need to do some more work so that the typechecker, etc. can also
report line numbers.
1994-01-10 09:06:54 +00:00
Fergus Henderson
7901760617 Add special hack to allow you define ';'/2 constructors. 1994-01-04 16:01:06 +00:00
Fergus Henderson
90c2b4f368 Added `author' comment to all source files.
Lots of bug fixes for make_hlds.nl.
A couple of bug fixes for hlds.nl.
Did some optimization of memory usage: added io__gc_call to io.nl
and used it in prog_io.nl and module.nl.  Rewrote the main loop
of prog_io to take maximum advantage of manual garbage collection.
Started working on typecheck.nl.
1993-12-28 11:35:16 +00:00
Fergus Henderson
9dc8da41f6 Add a couple of comments. 1993-12-18 14:51:05 +00:00
Fergus Henderson
6f5561e2fe Parse unifications. 1993-12-14 05:52:10 +00:00
Thomas Conway
aa687bc114 A bit of testing in codegen, a tiny bugfix to prog_io, and a couple of
small additions to hlds.
1993-12-10 04:17:11 +00:00
Fergus Henderson
1e020100f4 Parse constructors properly. 1993-12-07 04:20:34 +00:00
Fergus Henderson
fc8b5cc89c Bug fixes. 1993-12-03 08:51:12 +00:00
Fergus Henderson
90c472c950 Minor changes and bug fixes. 1993-12-01 18:47:05 +00:00
Fergus Henderson
91737ed565 Added code to parse mode declarations. 1993-12-01 11:55:55 +00:00
Fergus Henderson
63673c13f3 Modified the comments. 1993-11-30 16:23:13 +00:00
Fergus Henderson
f4d0c32e52 Various changes. It now successfully parses itself! 1993-11-30 13:03:01 +00:00
Fergus Henderson
2dacf05303 Added comments, mode declarations, code to parse inst & mode definitions. 1993-11-30 05:19:48 +00:00
Fergus Henderson
e875cde847 Minor bug fix. 1993-11-28 13:43:37 +00:00
Fergus Henderson
50340cae7c Finished parsing for module declarations (except operator fixity). 1993-11-28 12:44:03 +00:00
Fergus Henderson
0f5180bfb4 Fixed a few loose ends. Still lots of work to be done here. 1993-11-28 06:17:28 +00:00
Fergus Henderson
f06bac3997 Added the compiler sources to the CVS repository. 1993-11-22 07:21:21 +00:00