diff: fix for bootstrapping problem

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


I've committed this change.

Fix a bug that had stopped the compiler from bootstrapping.

compiler/mercury_to_mercury.m:
	Ensure that graphic tokens (tokens composed of special characters)
	are quoted if they occur after a module qualifier, so that the module
	qualifier is not considered as part of the graphic token.
	Previously it just used term_io__write_constant(term__atom(Name)),
	but term_io__write_constant was changed so that it does not emit
	unnecessary quotes; the problem was that in this context (immediately
	after a module qualifier), the quotes are necessary.

Index: mercury_to_mercury.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.100
diff -u -r1.100 mercury_to_mercury.m
--- mercury_to_mercury.m	1997/04/27 05:29:56	1.100
+++ mercury_to_mercury.m	1997/05/01 02:31:38
@@ -157,7 +157,7 @@
 
 :- import_module prog_out, prog_util, hlds_pred, hlds_out.
 :- import_module globals, options.
-:- import_module bool, int, string, set, term_io, std_util, require.
+:- import_module bool, int, string, set, term_io, lexer, std_util, require.
 
 %-----------------------------------------------------------------------------%
 
@@ -1158,11 +1158,29 @@
 mercury_output_sym_name(Name) -->
 	(	{ Name = qualified(ModuleName, PredName) },
 		mercury_output_bracketed_constant(term__atom(ModuleName)),
-		io__write_char(':')
+		io__write_char(':'),
+		%
+		% If the symname is composed of only graphic token chars,
+		% then term_io__quote_atom will not quote it; but since
+		% ':' is a graphic token char, it needs to be quoted,
+		% otherwise the ':' would be considered part of the
+		% symbol name (e.g. "int:<" tokenizes as ["int", ":<"].)
+		%
+		(
+			{ string__to_char_list(PredName, Chars) },
+			{ \+ (  list__member(Char, Chars),
+				\+ lexer__graphic_token_char(Char)) }
+		->
+			io__write_string("'"),
+			io__write_string(PredName),
+			io__write_string("'")
+		;
+			term_io__quote_atom(PredName)
+		)
 	;
-		{ Name = unqualified(PredName) }
-	),
-	term_io__write_constant(term__atom(PredName)).
+		{ Name = unqualified(PredName) },
+		term_io__quote_atom(PredName)
+	).
 
 %-----------------------------------------------------------------------------%
 

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