Files
mercury/samples
Simon Taylor 0fd128ff7d Allow user-defined operator precedence tables for parser__read_term
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.
2001-11-08 15:30:40 +00:00
..

This directory contains some example Mercury programs.

hello.m			"Hello World" in Mercury.

cat.m                   An implementation of a simple version of the
			standard UNIX filter `cat', which just copies
			its input files or the standard input stream to
			the standard output stream.

sort.m                  An implementation of a simple version of the
			standard UNIX filter `sort', which reads lines
			from its input files or the standard input
			stream, sorts them, and then writes the result
			to the standard output stream.

calculator.m            A simple four-function arithmetic calculator,
			with a parser written using the Definite Clause
			Grammar notation.

calculator2.m		A simple four-function arithmetic calculator,
			which uses the parser module in the standard
			library with a user-defined operator precendence
			table.

committed_choice.m	An example illustrating committed-choice
			nondeterminism in Mercury.

interpreter.m		An simple interpreter for definite logic programs.
			A demonstration of meta-programming in Mercury.

expand_terms.m		Another example meta-program, showing how to
			emulate Prolog's `expand_term' mechanism.

e.m			A small program which calculates the base of
			natural logarithms to however many digits you
			choose.  It illustrates one way to achieve
			lazy evaluation in Mercury.

Mmakefile		The file used by `mmake', the Mercury Make program,
			to build the programs in this directory.

The `solutions' sub-directory contains some examples of the use of
nondeterminism, showing how a Mercury program can compute 
	- one solution,
	- all solutions, or
	- some solutions (determined by a user-specified criteria)
for a query which has more than one logically correct answer.

There are also some sub-directories which contain examples of multi-module
Mercury programs:

diff                    This directory contains an implementation of a
			simple version of the standard UNIX utility
			`diff', which prints the differences between
			two files.

c_interface		This directory contains some examples of mixed
			Mercury/C/C++/Fortran programs using the C interface.

rot13			This directory contains a few implementations of
			rot-13 encoding.

muz			This directory contains a syntax checker / type checker
			for the specification language Z.