diff: fix minor quoting bugs in term_io.m

Fergus Henderson fjh at cs.mu.oz.au
Thu May 1 12:46:19 AEST 1997


library/term_io.m:
	Fix a couple of small bugs in quoting:
	(a) don't quote the empty list '[]'
	(b) do quote the empty atom ''
	Also use our new higher-order syntax: output ''(Var, Arg) as Var(Arg).

Index: term_io.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/term_io.m,v
retrieving revision 1.42
diff -u -r1.42 term_io.m
--- term_io.m	1997/04/30 10:37:47	1.42
+++ term_io.m	1997/05/01 02:43:02
@@ -176,6 +176,18 @@
 		term_io__write_term_2(BracedTerm, VarSet0, N0, VarSet, N),
 		io__write_string(" }")
 	;
+		% the empty functor '' is used for higher-order syntax:
+		% Var(Arg, ...) gets parsed as ''(Var, Arg).  When writing
+		% it out, we want to use the nice syntax.
+		{ Functor = term__atom("") },
+		{ Args = [term__variable(Var), FirstArg | OtherArgs] }
+	->
+		term_io__write_variable_2(Var, VarSet0, N0, VarSet, N),
+		io__write_char('('),
+		term_io__write_term_2(FirstArg, VarSet0, N0, VarSet1, N1),
+		term_io__write_term_args(OtherArgs, VarSet1, N1, VarSet, N),
+		io__write_char(')')
+	;
 		{ Args = [PrefixArg] },
 		{ Functor = term__atom(OpName) },
 		{ ops__lookup_prefix_op(OpTable, OpName,
@@ -351,9 +363,12 @@
 		;
 			{ S = "," }
 		;
+			{ S = "[]" }
+		;
 			{ string__to_char_list(S, Chars) },
 			{ \+ (  list__member(Char, Chars),
-				\+ lexer__graphic_token_char(Char)) }
+				\+ lexer__graphic_token_char(Char)) },
+			{ S \= "" }
 		)
 	->
 		io__write_string(S)

-- 
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