[m-rev.] make moose compile with intermodule-optimization

Julien Fischer juliensf at students.cs.mu.OZ.AU
Wed Jul 9 17:11:04 AEST 2003


Estimated hours taken: 0.5
Branches: main

Fix moose so that it compiles successfully with intermodule-optimization
enabled.

extras/moose/check.m:
extras/moose/grammar.m:
extras/moose/lalr.m:
extras/moose/moose.m:
	Module qualify some predicate names to resolve type ambiguities.
	Add underscores to a couple of variables that are not used.


Index: check.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/moose/check.m,v
retrieving revision 1.1
diff -u -r1.1 check.m
--- check.m	22 May 2000 05:22:03 -0000	1.1
+++ check.m	9 Jul 2003 06:48:38 -0000
@@ -130,7 +130,7 @@
 check_clauses0([Clause|ClauseList], Decls, Clauses0, Clauses, Errors) :-
 	Clause = clause(Head, Prod, _, Context),
 	Id = nonterminal(Head),
-	( search(Clauses0, Id, ClauseList0) ->
+	( map__search(Clauses0, Id, ClauseList0) ->
 		append(ClauseList0, [Clause], ClauseList1)
 	;
 		ClauseList1 = [Clause]
@@ -141,10 +141,10 @@
 	solutions((pred(NonTermId::out) is nondet :-
 			% XXX performance
 		nonterminals(Prod, NonTermIds),
-		member(NonTermId, NonTermIds),
+		list__member(NonTermId, NonTermIds),
 		not contains(Decls, NonTermId)
 	), UnDeclaredIds),
-	map((pred(UnDeclaredId::in, UnDeclaredError::out) is det :-
+	list__map((pred(UnDeclaredId::in, UnDeclaredError::out) is det :-
 		id(Id, CN, CA),
 		id(UnDeclaredId, NN, NA),
 		format("In production for %s/%d,", [s(CN), i(CA)], Msg0),
@@ -188,13 +188,13 @@
 :- mode useful(in, in, in, out) is det.

 useful(New0, Clauses, Useful0, Useful) :-
-	( empty(New0) ->
+	( set__empty(New0) ->
 		Useful = Useful0
 	;
 		solutions_set((pred(UId::out) is nondet :-
-			member(Id, New0),
-			search(Clauses, Id, ClauseList),
-			member(Clause, ClauseList),
+			set__member(Id, New0),
+			map__search(Clauses, Id, ClauseList),
+			list__member(Clause, ClauseList),
 			Clause = clause(_Head, Prod, _VarSet, _Context),
 			nonterminal(UId, Prod)
 		), NewSet),
@@ -244,12 +244,12 @@

 finite(Inf0, Fin0, Clauses, Inf) :-
 	solutions_set((pred(NewFinId::out) is nondet :-
-		member(NewFinId, Inf0),
+		set__member(NewFinId, Inf0),
 			% search rather than lookup in case the nonterminal
 			% doesn't have any clauses. This may lead to
 			% spurious infinite derivations.
-		search(Clauses, NewFinId, ClauseList),
-		member(Clause, ClauseList),
+		map__search(Clauses, NewFinId, ClauseList),
+		list__member(Clause, ClauseList),
 		Clause = clause(_Head, Prod, _VarSet, _Context),
 		nonterminals(Prod, NonTerms),
 		(
@@ -257,12 +257,12 @@
 		;
 			NonTerms = [_|_],
 			all [NId] (
-				member(NId, NonTerms) => member(NId, Fin0)
+				list__member(NId, NonTerms) => set__member(NId, Fin0)
 			)
 		)
 	), NewFinSet),
 	NewFin = NewFinSet - Fin0,
-	( empty(NewFin) ->
+	( set__empty(NewFin) ->
 		Inf = Inf0
 	;
 		Inf1 = Inf0 - NewFin,
Index: grammar.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/moose/grammar.m,v
retrieving revision 1.5
diff -u -r1.5 grammar.m
--- grammar.m	19 Feb 2002 07:49:01 -0000	1.5
+++ grammar.m	9 Jul 2003 06:50:52 -0000
@@ -224,13 +224,12 @@
 	Nont0 = 1,
 	start_rule(Start, StartRule),
 	map__from_assoc_list([0 - StartRule], Rules0),
-	map__init(Xfs0),
 	map__init(ClauseIndex0),
 	map__init(First0),
 	map__init(Follow0),
 	Grammar0 = grammar(Rules0, AllClauses, XForms, Nont0, ClauseIndex0,
 		First0, Follow0),
-	foldl(transform_clause_list, ClauseList, Grammar0, Grammar1),
+	list.foldl(transform_clause_list, ClauseList, Grammar0, Grammar1),
 	compute_first0(Grammar1, Grammar2),
 	compute_follow0(Grammar2, Grammar3),
 	Grammar3 = grammar(Rules3, AllClauses3, XForms3, Nont3, ClauseIndex3,
@@ -452,18 +451,18 @@

 compute_first(I, IMax, Elems, First, Set0, Set) :-
 	( I =< IMax ->
-		lookup(Elems, I, Elem),
+		array__lookup(Elems, I, Elem),
 		(
 				% If we get to a terminal, then we add it
 				% to the first set, and remove epsilon (if
 				% it was there in the first place), since
 				% this rule is certainly not nullable.
 			Elem = terminal(Id),
-			insert(Set0, Id, Set1),
-			difference(Set1, { epsilon }, Set)
+			set__insert(Set0, Id, Set1),
+			set__difference(Set1, { epsilon }, Set)
 		;
 			Elem = nonterminal(Id),
-			( search(First, Id, Set1) ->
+			( map__search(First, Id, Set1) ->
 					% If we know some information about
 					% the nonterminal, then add it to
 					% what we already know. If it is
@@ -471,12 +470,12 @@
 					% not nullable, and we're done. If
 					% it is nullable, then we look at
 					% the next literal in the body.
-				union(Set0, Set1, Set2),
-				( member(epsilon, Set1) ->
+				set__union(Set0, Set1, Set2),
+				( set__member(epsilon, Set1) ->
 					compute_first(I + 1, IMax, Elems, First,
 						Set2, Set)
 				;
-					difference(Set2, { epsilon }, Set)
+					set__difference(Set2, { epsilon }, Set)
 				)
 			;
 					% If we don't know anything about
@@ -634,12 +633,12 @@

 compute_follow3(I, First, MyId, Elems, Stuff0, Stuff) :-
 	( I >= 0 ->
-		lookup(Elems, I, Elem),
+		array__lookup(Elems, I, Elem),
 		( Elem = nonterminal(Id) ->
 			get_follow(MyId, MyFollow, Stuff0, _),
 			add_follow(Id, MyFollow, Stuff0, Stuff1),
-			lookup(First, Id, IdFirst),
-			( member(epsilon, IdFirst) ->
+			map__lookup(First, Id, IdFirst),
+			( set__member(epsilon, IdFirst) ->
 				compute_follow3(I - 1, First, MyId, Elems,
 					Stuff1, Stuff)
 			;
@@ -689,16 +688,16 @@
 first(First, Elems, I) = FirstI :-
 	array__max(Elems, Max),
 	( I =< Max ->
-		lookup(Elems, I, Elem),
+		array__lookup(Elems, I, Elem),
 		(
 			Elem = terminal(Id),
 			FirstI = { Id }
 		;
 			Elem = nonterminal(Id),
-			lookup(First, Id, FirstI0),
-			( member(epsilon, FirstI0) ->
+			map__lookup(First, Id, FirstI0),
+			( set__member(epsilon, FirstI0) ->
 				RestFirst = first(First, Elems, I+1),
-				union(FirstI0, RestFirst, FirstI)
+				set__union(FirstI0, RestFirst, FirstI)
 			;
 				FirstI = FirstI0
 			)
Index: lalr.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/moose/lalr.m,v
retrieving revision 1.2
diff -u -r1.2 lalr.m
--- lalr.m	24 Aug 2000 06:44:00 -0000	1.2
+++ lalr.m	9 Jul 2003 06:53:32 -0000
@@ -86,7 +86,7 @@
 		Ch = Ch0,
 		Reaching = Reaching0
 	;
-		lookup(Symbols, SN, Symbol),
+		array__lookup(Symbols, SN, Symbol),
 		(
 			Symbol = terminal(_),
 			Ch = Ch0,
@@ -94,16 +94,16 @@
 		;
 			Symbol = nonterminal(A),
 			reaches(C, A, Ch0, Ch1, Reaching0, Reaching1),
-			( search(Reaching1, A, AR) ->
+			( map__search(Reaching1, A, AR) ->
 				set__to_sorted_list(AR, ARList),
-				foldl2(reaches(C), ARList, Ch1, Ch2,
+				list__foldl2(reaches(C), ARList, Ch1, Ch2,
 					Reaching1, Reaching2)
 			;
 				Ch2 = Ch1,
 				Reaching2 = Reaching1
 			),
-			lookup(First, A, FirstA),
-			( member(epsilon, FirstA) ->
+			map__lookup(First, A, FirstA),
+			( set__member(epsilon, FirstA) ->
 				reaching(SN + 1, Max, Symbols, First, C,
 					Ch2, Ch, Reaching2, Reaching)
 			;
@@ -117,19 +117,19 @@
 :- mode reaches(in, in, in, out, in, out) is det.

 reaches(C, A, Ch0, Ch, Reaching0, Reaching) :-
-	( search(Reaching0, C, As0) ->
-		( member(A, As0) ->
+	( map__search(Reaching0, C, As0) ->
+		( set__member(A, As0) ->
 			Ch = Ch0,
 			Reaching = Reaching0
 		;
 			Ch = yes,
 			As = As0 \/ { A },
-			set(Reaching0, C, As, Reaching)
+			map__set(Reaching0, C, As, Reaching)
 		)
 	;
 		Ch = yes,
 		As = { A },
-		set(Reaching0, C, As, Reaching)
+		map__set(Reaching0, C, As, Reaching)
 	).

 %------------------------------------------------------------------------------%
@@ -335,15 +335,15 @@
 closure1([], _Rules, _First, _Index, I, I).
 closure1([AItem|AItems], Rules, First, Index, I0, I) :-
 	AItem = item(Ap, Ad, Asym),
-	lookup(Rules, Ap, rule(_, _, Asyms, _, _, _, _)),
+	map__lookup(Rules, Ap, rule(_, _, Asyms, _, _, _, _)),
 	array__max(Asyms, AMax),
 	( Ad =< AMax ->
-		lookup(Asyms, Ad, BSym),
+		array__lookup(Asyms, Ad, BSym),
 		( BSym = nonterminal(Bn) ->
 			Bf0 = first(First, Asyms, Ad + 1),
-			( member(epsilon, Bf0) ->
-				delete(Bf0, epsilon, Bf1),
-				insert(Bf1, Asym, Bf)
+			( set__member(epsilon, Bf0) ->
+				set__delete(Bf0, epsilon, Bf1),
+				set__insert(Bf1, Asym, Bf)
 				%Bf = Bf1 \/ { Asym }
 			;
 				Bf = Bf0
@@ -355,8 +355,8 @@
 			    % sorted order. Thus we don't have to
 			    % sort the list to turn it into a set.
 			    % Reduces running time by > 10%
-			reverse(BfList0, BfList),
-			lookup(Index, Bn, Bps),
+			list__reverse(BfList0, BfList),
+			map__lookup(Index, Bn, Bps),
 			make_items(Bps, BfList, [], NList),
 			set__sorted_list_to_set(NList, N),
 			I1 = [N|I0]
Index: moose.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/moose/moose.m,v
retrieving revision 1.5
diff -u -r1.5 moose.m
--- moose.m	9 Jul 2002 03:33:50 -0000	1.5
+++ moose.m	9 Jul 2003 06:54:30 -0000
@@ -643,7 +643,7 @@
 		io__state, io__state).
 :- mode write_parser(in, in, in, in, in, in, di, uo) is det.

-write_parser(Where, NT, Decl, TT, InAtom, OutAtom) -->
+write_parser(Where, NT, Decl, _TT, InAtom, OutAtom) -->
 	(
 		{ NT = StartName/StartArity }
 	;

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list