cvs diff: ISO Prolog syntax changes

Fergus Henderson fjh at cs.mu.oz.au
Wed Mar 19 06:43:50 AEDT 1997


Hi Tom,

Can you please review this change?

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

Improve ISO Prolog syntax compatibility.

library/ops.m:
	Change the precedence of unary `-', `**', `^', and `\' and the
	precedence and associativity of `mod' to match that specified by
	ISO Prolog. 

	Add the ISO Prolog operators `==', `\==', `=:=', `=\=', `@<',
	`@>', `@=<', `@>=', `?-', and `=..', which were previously
	commented out.  I plan to implement all of these (except `?-')
	in a new module library/prolog.m for Prolog compatibility.
	Similarly add the NU-Prolog / Quintus Prolog operator `~='.
	(These were all already present in compiler/mercury_to_mercury.m.)

	Delete the commented out NU-Prolog operators that we don't use:
	delete, dynamic, gAll, gSome, in, insert, lib, listing, man,
	nospy, once, listing, pure, sorted, spy, update, useIf, and wait.
	(I left these in compiler/mercury_to_mercury.m, so that the output will
	still be properly parenthesized for use with the NU-Prolog parser.)

library/ops.m:
library/nc_builtin.m:
library/sp_builtin.m:
compiler/mercury_to_mercury.m:
	Add `rem' as an operator, as specified by ISO Prolog.

Index: ops.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/ops.m,v
retrieving revision 1.13
diff -u -r1.13 ops.m
--- ops.m	1997/01/27 22:22:17	1.13
+++ ops.m	1997/03/18 19:25:18
@@ -114,13 +114,13 @@
 :- mode ops__op_table(in, out, out, out) is nondet.
 
 ops__op_table("*", after, yfx, 400).
-ops__op_table("**", after, xfy, 300).
+ops__op_table("**", after, xfy, 200).
 ops__op_table("+", after, yfx, 500).
 ops__op_table("+", before, fx, 500).
 ops__op_table(",", after, xfy, 1000).
 ops__op_table("&", after, xfy, 1025).
 ops__op_table("-", after, yfx, 500).
-ops__op_table("-", before, fx, 500).
+ops__op_table("-", before, fx, 200).
 ops__op_table("--->", after, xfy, 1179).
 ops__op_table("-->", after, xfx, 1200).
 ops__op_table("->", after, xfy, 1050).
@@ -129,7 +129,6 @@
 ops__op_table("//", after, yfx, 400).
 ops__op_table("/\\", after, yfx, 500).
 ops__op_table(":", after, xfy, 600).
-% ops__op_table(":", before, fx, 1175).
 ops__op_table(":-", after, xfx, 1200).
 ops__op_table(":-", before, fx, 1200).
 ops__op_table("::", after, xfx, 1175).
@@ -139,30 +138,28 @@
 ops__op_table("<=", after, xfy, 920).
 ops__op_table("<=>", after, xfy, 920).
 ops__op_table("=", after, xfx, 700).
-% ops__op_table("=..", after, xfx, 700).
-% ops__op_table("=:=", after, xfx, 700).
+ops__op_table("=..", after, xfx, 700).
+ops__op_table("=:=", after, xfx, 700).
 ops__op_table("=<", after, xfx, 700).
 ops__op_table("==", after, xfx, 700).
 ops__op_table("=>", after, xfy, 920).
-% ops__op_table("=\\=", after, xfx, 700).
+ops__op_table("=\\=", after, xfx, 700).
 ops__op_table(">", after, xfx, 700).
 ops__op_table(">=", after, xfx, 700).
 ops__op_table(">>", after, yfx, 400).
-% ops__op_table("?-", before, fx, 1200).
-% ops__op_table("@<", after, xfx, 700).
-% ops__op_table("@=<", after, xfx, 700).
-% ops__op_table("@>", after, xfx, 700).
-% ops__op_table("@>=", after, xfx, 700).
-ops__op_table("\\", before, fx, 500).
+ops__op_table("?-", before, fx, 1200).
+ops__op_table("@<", after, xfx, 700).
+ops__op_table("@=<", after, xfx, 700).
+ops__op_table("@>", after, xfx, 700).
+ops__op_table("@>=", after, xfx, 700).
+ops__op_table("\\", before, fx, 200).
 ops__op_table("\\+", before, fy, 900).
 ops__op_table("\\/", after, yfx, 500).
 ops__op_table("\\=", after, xfx, 700).
-% ops__op_table("\\==", after, xfx, 700).
+ops__op_table("\\==", after, xfx, 700).
 ops__op_table("^", after, xfy, 200).
 ops__op_table("all", before, fxy, 950).
 ops__op_table("and", after, xfy, 720).
-% ops__op_table("delete", before, fy, 1175).
-% ops__op_table("dynamic", before, fy, 1150).
 ops__op_table("else", after, xfy, 1170).
 ops__op_table("end_module", before, fx, 1199).
 ops__op_table("export_adt", before, fx, 1199).
@@ -173,8 +170,6 @@
 ops__op_table("export_sym", before, fx, 1199).
 ops__op_table("export_type", before, fx, 1199).
 ops__op_table("func", before, fx, 1180).
-% ops__op_table("gAll", before, fxy, 950).
-% ops__op_table("gSome", before, fxy, 950).
 ops__op_table("if", before, fx, 1160).
 ops__op_table("import_adt", before, fx, 1199).
 ops__op_table("import_cons", before, fx, 1199).
@@ -183,34 +178,21 @@
 ops__op_table("import_pred", before, fx, 1199).
 ops__op_table("import_sym", before, fx, 1199).
 ops__op_table("import_type", before, fx, 1199).
-% ops__op_table("in", after, xfx, 1172).
-% ops__op_table("insert", before, fy, 1175).
 ops__op_table("inst", before, fx, 1199).
 ops__op_table("is", after, xfx, 701).
 ops__op_table("lambda", before, fxy, 950).
-% ops__op_table("lib", before, fy, 900).
-% ops__op_table("listing", before, fy, 900).
-% ops__op_table("man", before, fy, 900).
-ops__op_table("mod", after, xfx, 300).
+ops__op_table("mod", after, yfx, 400).
 ops__op_table("mode", before, fx, 1199).
 ops__op_table("module", before, fx, 1199).
-% ops__op_table("nospy", before, fy, 900).
 ops__op_table("not", before, fy, 900).
-% ops__op_table("once", before, fy, 900).
 ops__op_table("or", after, xfy, 740).
 ops__op_table("pragma", before, fx, 1199).
 ops__op_table("pred", before, fx, 1180).
-% ops__op_table("pure", before, fy, 1150).
+ops__op_table("rem", after, yfx, 400).
 ops__op_table("rule", before, fx, 1199).
 ops__op_table("some", before, fxy, 950).
-% ops__op_table("sorted", after, xf, 1171).	% can't support this
-% ops__op_table("sorted", after, xfx, 1171).
-% ops__op_table("spy", before, fy, 900).
 ops__op_table("then", after, xfx, 1150).
-% ops__op_table("to", after, xfx, 980).
 ops__op_table("type", before, fx, 1180).
-% ops__op_table("update", before, fy, 1175).
-% ops__op_table("useIf", before, fx, 1180).
 ops__op_table("use_adt", before, fx, 1199).
 ops__op_table("use_cons", before, fx, 1199).
 ops__op_table("use_module", before, fx, 1199).
@@ -218,11 +200,10 @@
 ops__op_table("use_pred", before, fx, 1199).
 ops__op_table("use_sym", before, fx, 1199).
 ops__op_table("use_type", before, fx, 1199).
-% ops__op_table("wait", before, fy, 900).
 ops__op_table("when", after, xfx, 900).
 ops__op_table("where", after, xfx, 1175).
 ops__op_table("~", before, fy, 900).
-% ops__op_table("~=", after, xfx, 700).
+ops__op_table("~=", after, xfx, 700).
 
 ops__init_op_table(ops__table).
 
Index: nc_builtin.nl
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/nc_builtin.nl,v
retrieving revision 1.11
diff -u -r1.11 nc_builtin.nl
--- nc_builtin.nl	1997/02/06 02:36:28	1.11
+++ nc_builtin.nl	1997/03/18 19:17:55
@@ -52,6 +52,8 @@
 
 :- op(950, fxy, (lambda)).
 
+:- op(400, yfx, (rem)).
+
 % In NU-Prolog, ':' has precedence 1175, whereas according to the
 % ISO Prolog modules standard it should have precedence 600.
 % Hence we need to override the original precedence for it.
Index: sp_builtin.nl
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/sp_builtin.nl,v
retrieving revision 1.10
diff -u -r1.10 sp_builtin.nl
--- sp_builtin.nl	1997/02/06 02:36:27	1.10
+++ sp_builtin.nl	1997/03/18 19:18:01
@@ -68,6 +68,8 @@
 
 :- op(701, xfx, (is)).
 
+:- op(400, yfx, (rem)).
+
 % Use term_expansion/2 to prevent warnings about undefined predicates
 % when the interpreter tries to execute the new declarations.
 
Index: ../compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.95
diff -u -r1.95 mercury_to_mercury.m
--- mercury_to_mercury.m	1997/03/06 05:09:30	1.95
+++ mercury_to_mercury.m	1997/03/18 19:38:54
@@ -1586,6 +1586,7 @@
 mercury_infix_op("<<").
 mercury_infix_op("**").
 mercury_infix_op("mod").
+mercury_infix_op("rem").
 mercury_infix_op("^").
 
 :- pred mercury_unary_prefix_op(string).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list