[m-rev.] for review: moose fixes

Julien Fischer juliensf at students.cs.mu.OZ.AU
Tue Jul 22 18:59:04 AEST 2003


Estimated hours taken: 1.
Branches: main.

Allow moose to parse conditional goals written using the if - then - else
notation.  This makes the code generated by moose less ugly when the `.moo'
file contains these type of goals.

extras/moose/mercury_syntax.m:
	Handle if-then-elses so that the generated code is less ugly.
	Fix some indentation.
	Fix some type declarations.

extras/moose/check.m:
extras/moose/grammar.m:
	Add some module qualifiers.


Index: check.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/moose/check.m,v
retrieving revision 1.3
diff -u -r1.3 check.m
--- check.m	16 Jul 2003 07:16:02 -0000	1.3
+++ check.m	22 Jul 2003 08:44:29 -0000
@@ -55,7 +55,7 @@
 %------------------------------------------------------------------------------%

 check_rule_decls(DeclList, Decls, Errors) :-
-	init(Decls0),
+	map__init(Decls0),
 	check_rule_decls(DeclList, Decls0, Decls, Errors).

 :- pred check_rule_decls(list(rule_decl), rule_decls, rule_decls,
@@ -85,7 +85,7 @@
 %------------------------------------------------------------------------------%

 check_clauses(ClauseList, Decls, Clauses, Errors) :-
-	init(Clauses0),
+	map__init(Clauses0),
 	check_clauses0(ClauseList, Decls, Clauses0, Clauses, Errors0),

 	map__keys(Decls, DeclIds),
Index: grammar.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/moose/grammar.m,v
retrieving revision 1.7
diff -u -r1.7 grammar.m
--- grammar.m	16 Jul 2003 07:16:03 -0000	1.7
+++ grammar.m	22 Jul 2003 08:43:40 -0000
@@ -233,8 +233,8 @@
 		% Keep the nonterminals in reverse sorted order
 		% for efficient processing in lalr.m
 	map__map_values((pred(_K::in, V0::in, V::out) is det :-
-	    sort(V0, V1),
-	    reverse(V1, V)
+	    list__sort(V0, V1),
+	    list__reverse(V1, V)
 	), ClauseIndex3, ClauseIndex4),
 	Grammar = grammar(Rules3, AllClauses3, XForms3, Nont3, ClauseIndex4,
 		First3, Follow3).
Index: mercury_syntax.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/moose/mercury_syntax.m,v
retrieving revision 1.2
diff -u -r1.2 mercury_syntax.m
--- mercury_syntax.m	16 Jul 2003 07:16:02 -0000	1.2
+++ mercury_syntax.m	22 Jul 2003 08:43:11 -0000
@@ -39,8 +39,7 @@

 :- type lines
 	--->	lines
-	;	nolines
-	.
+	;	nolines.

 :- pred write_element(lines, element, io__state, io__state).
 :- mode write_element(in, in, di, uo) is det.
@@ -51,8 +50,7 @@
 :- type (type)
 	--->	abstr(term)
 	;	equiv(term, term)
-	;	disj(term, list(term))
-	.
+	;	disj(term, list(term)).

 :- pred term_to_type(term, (type)).
 :- mode term_to_type(in, out) is semidet.
@@ -68,8 +66,7 @@
 	;	forall(vars, goal)
 	% 	(goal => goal) % XXX conflicts with type classes
 	;	(goal <= goal)
-	;	(goal <=> goal)
-	.
+	;	(goal <=> goal).

 :- pred term_to_goal(term, goal).
 :- mode term_to_goal(in, out) is semidet.
@@ -546,6 +543,14 @@
 		)
 	).

+term_to_goal0("else", [functor(atom("if"), [IfThenTerm],  _), ElseTerm], _,
+		Goal) :-
+	IfThenTerm = functor(atom("then"), [IfTerm, ThenTerm], _),
+	term_to_goal(IfTerm, If),
+	term_to_goal(ThenTerm, Then),
+	term_to_goal(ElseTerm, Else),
+	Goal = ite(If, Then, Else).
+
 term_to_goal0("=", [A, B], Context, =(A, B, Context)).

 term_to_goal0("not", [A], _, not(Goal)) :-
@@ -608,7 +613,8 @@

 write_goal(Lines, Ind, GoalType, ite(If, Then, Else0), VarSet, !IO) :-
 	collect_ite(Else0, IfThens0, Else),
-	write_ite(Lines, Ind, GoalType, [If - Then | IfThens0], Else, VarSet, !IO).
+	write_ite(Lines, Ind, GoalType, [If - Then | IfThens0], Else, VarSet,
+		!IO).

 write_goal(Lines, Ind, GoalType, not(Goal), VarSet, !IO) :-
 	write_ind(Ind, !IO),
--------------------------------------------------------------------------
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