Commit Graph

6 Commits

Author SHA1 Message Date
Mark Brown
8ae09930f8 Fix a bug reported by Doug Auclair.
Estimated hours taken: 5
Branches: main

Fix a bug reported by Doug Auclair.

library/ops.m:
	Change the Mercury arg priority to 999.  It was previously set to
	1201, which allowed arguments and list elements to be parsed the
	way we intended.  However, this had the unintended side effect that
	valid terms were written out using incorrect syntax.

library/parser.m:
	Place the workaround here, where arguments and list elements are
	read.

	Note that this is still technically buggy, because we effectively
	allow syntax which should be illegal according to the operator
	precedence table.  But the proper fix for this involves moving to
	a BNF style parser, so that is left for later work.

tests/hard_coded/Mmakefile:
	Run the term_io_test case twice, checking it against the expected
	output each time.  The first time it is run with the supplied input
	file.  The second time it is run with the expected output as input --
	this ensures that terms are read in the same way that they are
	written out.

tests/hard_coded/term_io_test.m:
	Read input from stdin rather than a fixed file.

tests/hard_coded/term_io_test.inp:
	Add additional input terms.

tests/hard_coded/term_io_test.exp:
tests/invalid/*.err_exp:
	Update the expected output for this and other test cases.
2006-03-07 01:03:46 +00:00
Julien Fischer
e069d16ab1 Do not display the For more information try recompiling with -E'' prompt
Estimated hours taken: 1.5
Branches: main

Do not display the `For more information try recompiling with `-E'' prompt
unless we really mean it, i.e. there is actually more information available.

XXX This change is incomplete for the mode_errors module because that
module requires more substantial changes to make this work - I'll do
that as a separate diff.

compiler/globals.m
	Add a new global (and access predicates) that keeps track of whether
	we have any verbose error information that could be displayed if we
	recompiled with `-E'.

compiler/mercury_compile.m
	Check the new global flag before prompting the user to recompile with
	`-E'.

compiler/mode_errors.m
	Add an XXX comment about needing to respect the extra error info flag
	properly.

compiler/accumulator.m
compiler/add_clause.m
compiler/add_pred.m
compiler/add_type.m
compiler/assertion.m
compiler/check_typeclass.m
compiler/det_report.m
compiler/magic_util.m
compiler/make_hlds_error.m
compiler/modes.m
compiler/module_qual.m
compiler/modules.m
compiler/post_typecheck.m
compiler/purity.m
compiler/stratify.m
compiler/typecheck_errors.m
	Set the new global flag when we come across an error
	for which we have a verbose error message.

tests/recompilation/*:
tests/invalid/*:
	Update expected error files.
2005-09-14 05:27:11 +00:00
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
Tyson Dowd
f9b942b30e Allow functions to be declared by supplying the determinism but not the
Estimated hours taken: 12

Allow functions to be declared by supplying the determinism but not the
modes (we assume the default modes).

compiler/make_hlds.m:
	Assume default modes if determinism is declared without modes
	in the :- func declaration.

compiler/prog_io.m:
	Don't give an error message for determinism without modes for
	function.

compiler/prog_io_goal.m:
	Update documentation to reflect default mode syntax.
	Assume default modes if determinism is declared without modes
	in lambda expressions.

compiler/prog_util.m:
	Mention that declaring modes for some but not all of the
	arguments of a function will be noticed in prog_io, so shouldn't
	be a concern in this code.

doc/reference_manual.texi:
	Document the new syntax.

tests/valid/Mmakefile:
tests/valid/func_default_modes.m:
	A test case for the new syntax.
2000-02-16 07:28:13 +00:00
Fergus Henderson
a251166d8e Update the test results to reflect the extra parentheses
Estimated hours taken: 0.5

tests/invalid/some.err_exp:
tests/invalid/predmode.err_exp:
tests/invalid/func_errors.err_exp:
	Update the test results to reflect the extra parentheses
	now printed out by term_io__write_term.
1998-11-15 06:56:57 +00:00
Fergus Henderson
74dfe1af37 New test case to check that we correctly report errors
Estimated hours taken: 0.25

tests/invalid/Mmake:
tests/invalid/func_errors.m:
tests/invalid/func_errors.err_exp:
	New test case to check that we correctly report errors
	for certain invalid function declarations.
	(Mercury 0.6 failed this test case.)
1997-08-15 15:46:33 +00:00