[m-dev.] diff: fix more quoting bugs

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jun 10 02:36:31 AEST 1999


Estimated hours taken: 1

Fix some more quoting bug that caused the compiler to generate `.opt' files
containing syntax errors.

compiler/mercury_to_mercury.m:
compiler/hlds_out.m:
	Fix some more quoting problems: it was not properly quoting
	certain subterms when they occurred immediately before the final
	`.' at the end of a term.

tests/valid/intermod_quote2.m:
	Add some regression tests for the above bug fix.

tests/valid/Mmakefile:
	Fix a bug in the Mmakefile that meant that the intermod_quote
	test didn't work properly when --use-subdirs was enabled.

Workspace: /home/mercury0/fjh/mercury-other
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.219
diff -u -r1.219 hlds_out.m
--- hlds_out.m	1999/06/01 09:43:47	1.219
+++ hlds_out.m	1999/06/09 16:34:21
@@ -746,7 +746,7 @@
 			AppendVarnums),
 		io__write_string(" = "),
 		mercury_output_term(term__variable(RetVal), VarSet,
-			AppendVarnums)
+			AppendVarnums, next_to_graphic_token)
 	;
 		{ PredOrFunc = predicate },
 		hlds_out__write_qualified_functor(ModuleName,
@@ -1205,7 +1205,7 @@
 	;
 		{ PredName = unqualified(Name) },
 		hlds_out__write_functor(term__atom(Name), ArgVars, VarSet,
-			AppendVarnums)
+			AppendVarnums, next_to_graphic_token)
 	),
 	io__write_string(Follow),
 	( { string__contains_char(Verbose, 'l') } ->
@@ -1476,7 +1476,7 @@
 		AppendVarnums),
 	( { MaybeType = yes(Type), TypeQual = yes(TVarSet, _) } ->
 		io__write_string(" TYPE_QUAL_OP "),
-		mercury_output_term(Type, TVarSet, no)
+		mercury_output_term(Type, TVarSet, no, next_to_graphic_token)
 	;
 		[]
 	).
@@ -1518,7 +1518,8 @@
 	),
 	( { MaybeType = yes(Type), TypeQual = yes(TVarSet, _) } ->
 		io__write_string(" TYPE_QUAL_OP "),
-		mercury_output_term(Type, TVarSet, AppendVarnums)
+		mercury_output_term(Type, TVarSet, AppendVarnums,
+			next_to_graphic_token)
 	;
 		[]
 	),
@@ -1576,7 +1577,8 @@
 		;
 			{ SymName = unqualified(Name) },
 			hlds_out__write_functor(term__atom(Name),
-				ArgVars, VarSet, AppendVarnums)
+				ArgVars, VarSet, AppendVarnums,
+				next_to_graphic_token)
 		)
 	;
 		{ ConsId = int_const(Int) },
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.156
diff -u -r1.156 mercury_to_mercury.m
--- mercury_to_mercury.m	1999/04/23 01:02:51	1.156
+++ mercury_to_mercury.m	1999/06/09 15:44:43
@@ -1162,7 +1162,7 @@
 mercury_output_type_defn_2(abstract_type(Name, Args), VarSet, Context) -->
 	io__write_string(":- type "),
 	{ construct_qualified_term(Name, Args, Context, TypeTerm) },
-	mercury_output_term(TypeTerm, VarSet, no),
+	mercury_output_term(TypeTerm, VarSet, no, next_to_graphic_token),
 	io__write_string(".\n").
 
 mercury_output_type_defn_2(eqv_type(Name, Args, Body), VarSet, Context) -->
@@ -1170,7 +1170,7 @@
 	{ construct_qualified_term(Name, Args, Context, TypeTerm) },
 	mercury_output_term(TypeTerm, VarSet, no),
 	io__write_string(" == "),
-	mercury_output_term(Body, VarSet, no),
+	mercury_output_term(Body, VarSet, no, next_to_graphic_token),
 	io__write_string(".\n").
 
 mercury_output_type_defn_2(du_type(Name, Args, Ctors, MaybeEqualityPred),
@@ -1443,7 +1443,7 @@
 		mercury_output_bracketed_sym_name(FuncName)
 	),
 	io__write_string(" = "),
-	mercury_output_term(RetType, VarSet, no),
+	mercury_output_term(RetType, VarSet, no, next_to_graphic_token),
 	mercury_output_class_context(ClassContext, ExistQVars, VarSet),
 	mercury_output_det_annotation(MaybeDet),
 	io__write_string(Separator).
@@ -1726,12 +1726,12 @@
 		[]
 	),
 	io__write_string(" = "),
-	mercury_output_term(Result, VarSet, no),
 	(
 		{ Body = true - _Context0 }
 	->
-		[]
+		mercury_output_term(Result, VarSet, no, next_to_graphic_token)
 	;
+		mercury_output_term(Result, VarSet, no),
 		io__write_string(" :-\n\t"),
 		mercury_output_goal(Body, VarSet, 1)
 	),
@@ -1859,7 +1859,7 @@
 mercury_output_goal_2(unify(A, B), VarSet, _Indent) -->
 	mercury_output_term(A, VarSet, no),
 	io__write_string(" = "),
-	mercury_output_term(B, VarSet, no).
+	mercury_output_term(B, VarSet, no, next_to_graphic_token).
 
 
 :- pred mercury_output_call(sym_name, list(prog_term), prog_varset, int,
@@ -1879,7 +1879,7 @@
 		{ Name = unqualified(PredName) },
 		{ term__context_init(Context0) },
 		mercury_output_term(term__functor(term__atom(PredName),
-			Term, Context0), VarSet, no)
+			Term, Context0), VarSet, no, next_to_graphic_token)
 	).
 
 :- pred mercury_output_disj(goal, prog_varset, int, io__state, io__state).
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.34
diff -u -r1.34 Mmakefile
--- Mmakefile	1999/04/20 11:48:50	1.34
+++ Mmakefile	1999/06/09 16:01:09
@@ -177,19 +177,19 @@
 MCFLAGS-vn_float		= -O5
 
 # intermod_lambda.m needs inter-module optimization
-intermod_lambda.c:
+$(cs_subdir)intermod_lambda.c:
 	$(MCI) $(GRADEFLAGS) $(MCIFLAGS) intermod_lambda2.m
 	$(MCOI) $(GRADEFLAGS) $(MCOIFLAGS) intermod_lambda2.m
 	$(MCG) $(GRADEFLAGS) $(MCGFLAGS) --intermodule-optimization \
 		intermod_lambda.m
 
-intermod_quote.c:
+$(cs_subdir)intermod_quote.c:
 	$(MCI) $(GRADEFLAGS) $(MCIFLAGS) intermod_quote2.m
 	$(MCOI) $(GRADEFLAGS) $(MCOIFLAGS) intermod_quote2.m
 	$(MCG) $(GRADEFLAGS) $(MCGFLAGS) --intermodule-optimization \
 		intermod_quote.m
 
-intermod_test.c:
+$(cs_subdir)intermod_test.c:
 	$(MCI) $(GRADEFLAGS) $(MCIFLAGS) intermod_test2.m
 	$(MCOI) $(GRADEFLAGS) $(MCOIFLAGS) intermod_test2.m
 	$(MCG) $(GRADEFLAGS) $(MCGFLAGS) --intermodule-optimization \
Index: tests/valid/intermod_quote2.m
===================================================================
RCS file: /home/mercury1/repository/tests/valid/intermod_quote2.m,v
retrieving revision 1.1
diff -u -r1.1 intermod_quote2.m
--- intermod_quote2.m	1998/10/28 01:52:03	1.1
+++ intermod_quote2.m	1999/06/09 15:56:50
@@ -2,10 +2,35 @@
 % .opt file.
 :- module intermod_quote2.
 :- interface.
+:- import_module char.
 
 :- func '*'(func(X) = Y, func(Y) = Z, X) = Z.
 :- mode '*'(func(in) = out is det, func(in) = out is det, in) = out is det.
 
+:- func dollar = char.
+:- func hash = char.
+
+:- func '$' = int.
+:- func '#' = int.
+
+:- pred '$' is det.
+:- pred '#' is det.
+
+:- pred '$$' is semidet.
+:- pred '##' is semidet.
+
 :- implementation.
 
 '*'(F, G, X) = G(F(X)).
+
+dollar = '$'.
+hash = '#'.
+
+'$' = 42.
+'#' = 43.
+
+'$'.
+'#'.
+
+'$$' :- '##'.
+'##' :- '$$'.

-- 
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.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list