[m-rev.] [reuse] diff: move remaining parse rpoutines for aliases_domain

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Sun Jun 27 20:46:36 AEST 2004


Hi,


===================================================================


Estimated hours taken: 0.5
Branches: reuse

Move remaining parse routines for aliases_domain. 

pa_alias_as.m:
prog_io_pasr.m:
prog_io_pragma.m:
sr_data.m:


Index: pa_alias_as.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_alias_as.m,v
retrieving revision 1.1.2.40
diff -u -r1.1.2.40 pa_alias_as.m
--- pa_alias_as.m	27 Jun 2004 10:06:28 -0000	1.1.2.40
+++ pa_alias_as.m	27 Jun 2004 10:42:17 -0000
@@ -221,18 +221,6 @@
 % Parsing routines. 
 %-----------------------------------------------------------------------------%
-	% Parse the aliases as stored in the trans_opt interface files.
-	% This is the reverse routine for print_maybe_interface_aliases.
-	% Precondition: the list should contain only one element. 
-:- pred parse_read_aliases(list(term(T))::in, aliases_domain::out) is det.
-
-	% Parse the aliases as stored in the trans_opt interface files. Unlike
-	% in the previous routine, the alias is here dscribed by one single
-	% term (instead of a list of one single term). 
-:- pred parse_read_aliases_from_single_term(term(T)::in, 
-		aliases_domain::out) is det.
-
 	% Parse the used declared aliases (pragma aliasing). 
 	% XXX This routine is definitely on the wrong place and should be moved
 	% to parse_tree somewhere, once the aliasing type is defined without
@@ -904,87 +892,7 @@
 	).
 		
 %-----------------------------------------------------------------------------%
-% parsing routines
-%-----------------------------------------------------------------------------%
-
-parse_read_aliases(LISTTERM ,AS):- 
-	(
-		% LISTTERM ought to have only one element
-		LISTTERM = [ OneITEM ]
-	->
-		parse_read_aliases_from_single_term(OneITEM, AS)
-	;
-		list__length(LISTTERM, L),
-		string__int_to_string(L, LS), 
-		string__append_list(["(pa_alias_as) parse_read_aliases: wrong number of arguments. yes/", LS,
-				" should be yes/1"], Msg),
-		error(Msg)
-	).
-
-parse_read_aliases_from_single_term(OneITEM, AS) :- 
-	(
-		OneITEM = term__functor(term__atom(CONS), _TERMS, Context)
-	->
-		(
-			CONS = "[|]"
-		->
-			parse_list_alias_term(OneITEM, Aliases),
-			% from_pair_alias_list(Aliases, 
-			%		AliasSet), 
-			% wrap(AliasSet, AS)
-			AS = real(Aliases)
-			% AS = bottom
-		;
-			CONS = "bottom"
-		->
-			AS = bottom
-
-		; 
-			CONS = "top"
-		->
-			format_context(Context, ContextString), 
-			string__append_list(["imported top (", 
-				ContextString, ")"], 
-					Msg),
-			AS = top([Msg])
-		;
-			string__append(
-		"(pa_alias_as) parse_read_aliases_from_single_term: could not parse aliases, top cons: ", CONS, Msg),
-			error(Msg)
-		)
-	;
-		error("(pa_alias_as) parse_read_aliases_from_single_term: term not a functor")
-	).
-
-
-:- pred parse_list_alias_term(term(T), list(prog_data__alias)).
-:- mode parse_list_alias_term(in, out) is det.
-
-parse_list_alias_term(TERM, Aliases) :-
-	(
-		TERM = term__functor(term__atom(CONS), Args, _)
-	->
-		(
-		        CONS = "[|]",
-                        Args = [ AliasTerm, Rest]
-                ->
-			prog_io_pasr__parse_alias(AliasTerm, Alias),
-			parse_list_alias_term(Rest, RestAliases), 
-                        Aliases = [ Alias | RestAliases ]
-                ;
-			CONS = "[]"
-		->
-			Aliases = []
-		;
-			string__append("(pa_alias_as) parse_list_alias_term: could not parse aliases, top cons: ", CONS, Msg),
-			error(Msg)
-		)
-        ;
-                error("(pa_alias_as) parse_list_alias_term: term is not a functor")
-	).
-
-%-----------------------------------------------------------------------------%
-% user declared aliases
+% parsing routines for user declared aliases
 %-----------------------------------------------------------------------------%
 
 parse_user_declared_aliases(term__functor(term__atom("no_aliasing"), [], _),
@@ -1017,13 +925,6 @@
 	parse_user_declared_aliases_2(AliasTerm, AliasAs), 
 	Aliasing = aliasing(MaybeTypes, TypeVarSet, AliasAs). 
 
-:- pred format_context(term__context::in, string::out) is det.
-format_context(Context, String):- 
-	term__context_line(Context, ContextLine), 
-	term__context_file(Context, ContextFile), 
-	string__int_to_string(ContextLine, ContextLineS), 
-	string__append_list([ContextFile, ":", ContextLineS], 
-			String).
 
 :- pred parse_user_declared_aliases_2(term::in, alias_as::out) is det.
 parse_user_declared_aliases_2(ListTerm, AliasAS):- 
Index: prog_io_pasr.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/prog_io_pasr.m,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 prog_io_pasr.m
--- prog_io_pasr.m	27 Jun 2004 10:06:29 -0000	1.1.2.3
+++ prog_io_pasr.m	27 Jun 2004 10:42:19 -0000
@@ -14,7 +14,7 @@
 
 :- import_module parse_tree__prog_data.
 
-:- import_module io, term, std_util.
+:- import_module io, term, std_util, list.
 
 %-----------------------------------------------------------------------------%
 % Printing routines. 
@@ -94,8 +94,14 @@
 :- pred parse_datastruct(term(T)::in, datastruct::out) is det.
 % 3. alias.
 :- pred parse_alias(term(T)::in , alias::out) is det.
+% 4. aliases
+:- pred parse_aliases(term(T)::in, aliases::out) is det.
+% 5. aliases_domain
+:- pred parse_aliases_domain(term(T)::in, aliases_domain::out) is det.
+:- pred parse_aliases_domain_from_list(list(term(T))::in,
+		aliases_domain::out) is det.
 
-
+:- pred format_context(term__context::in, string::out) is det.
 %-----------------------------------------------------------------------------%
 
 :- implementation. 
@@ -105,7 +111,7 @@
 :- import_module parse_tree__mercury_to_mercury.
 :- import_module parse_tree__prog_io.
 
-:- import_module string, list, require, bool, varset, std_util, int. 
+:- import_module string, require, bool, varset, std_util, int. 
 
 %-----------------------------------------------------------------------------%
 print_selector(TVarSet, Selector, !IO) :-
@@ -409,3 +415,84 @@
 		error("(prog_io_pasr) parse_alias: term is not a functor")
 	).
 
+%-----------------------------------------------------------------------------%
+% 4. aliases
+parse_aliases(Term, Aliases) :-
+	(
+		Term = term__functor(term__atom(Cons), Args, _)
+	->
+		(
+		        Cons = "[|]",
+                        Args = [ AliasTerm, Rest]
+                ->
+			parse_alias(AliasTerm, Alias),
+			parse_aliases(Rest, RestAliases), 
+                        Aliases = [ Alias | RestAliases ]
+                ;
+			Cons = "[]"
+		->
+			Aliases = []
+		;
+			string__append("(prog_io_pasr) parse_aliases: could not parse aliases, top cons: ", Cons, Msg),
+			error(Msg)
+		)
+        ;
+                error("(prog_io_pasr) parse_aliases: term is not a functor")
+	).
+
+%-----------------------------------------------------------------------------%
+% 4. aliases_domain
+parse_aliases_domain(Term, AS) :- 
+	(
+		Term = term__functor(term__atom(Cons), _Terms, Context)
+	->
+		(
+			Cons = "[|]"
+		->
+			parse_aliases(Term, Aliases),
+			AS = real(Aliases)
+		;
+			Cons = "bottom"
+		->
+			AS = bottom
+
+		; 
+			Cons = "top"
+		->
+			format_context(Context, ContextString), 
+			string__append_list(["imported top (", 
+				ContextString, ")"], 
+					Msg),
+			AS = top([Msg])
+		;
+			string__append(
+		"(prog_io_pasr) parse_aliases_domain: could not parse aliases, top cons: ", Cons, Msg),
+			error(Msg)
+		)
+	;
+		error("(prog_io_pasr) parse_aliases_domain: term not a functor")
+	).
+
+format_context(Context, String):- 
+	term__context_line(Context, ContextLine), 
+	term__context_file(Context, ContextFile), 
+	string__int_to_string(ContextLine, ContextLineS), 
+	string__append_list([ContextFile, ":", ContextLineS], 
+			String).
+
+parse_aliases_domain_from_list(ListTerm, AliasesDomain):- 
+	(
+		% ListTerm must have only one item
+		ListTerm = [ Term ]
+	->
+		parse_aliases_domain(Term, AliasesDomain)
+	;
+		list__length(ListTerm, L),
+		string__int_to_string(L, LS), 
+		string__append_list([
+			"(prog_io_pasr) ", 
+			"parse_aliases_domain_from_list: ", 
+			"wrong number of arguments. yes/", LS,
+			" should be yes/1"], Msg),
+		error(Msg)
+	).
Index: prog_io_pragma.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_io_pragma.m,v
retrieving revision 1.23.2.16
diff -u -r1.23.2.16 prog_io_pragma.m
--- prog_io_pragma.m	11 Jun 2004 06:01:18 -0000	1.23.2.16
+++ prog_io_pragma.m	27 Jun 2004 10:42:23 -0000
@@ -23,6 +23,7 @@
 :- implementation.
 
 :- import_module libs__globals, parse_tree__prog_io, parse_tree__prog_io_goal.
+:- import_module parse_tree__prog_io_pasr.
 :- import_module parse_tree__prog_util.
 :- import_module transform_hlds__term_util, transform_hlds__term_errors.
 :- import_module int, map, string, std_util, bool, require, set.
@@ -1078,7 +1079,7 @@
 	;
 		AliasInformation = term__functor(
 					term__atom("yes"), ReadAliases, _),
-		pa_alias_as__parse_read_aliases(ReadAliases, Alias_as),
+		parse_aliases_domain_from_list(ReadAliases, Alias_as),
 		MaybeAliasInfo = yes(Alias_as)
 	),
 
Index: sr_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_data.m,v
retrieving revision 1.1.2.28
diff -u -r1.1.2.28 sr_data.m
--- sr_data.m	27 Jun 2004 10:06:29 -0000	1.1.2.28
+++ sr_data.m	27 Jun 2004 10:42:31 -0000
@@ -630,7 +630,7 @@
 				nodes_parse(NodesTerm, NodesList),
 				set__list_to_set(NodesList, Nodes), 
 				vars_parse(LUiHTerm, LUiH),
-				parse_read_aliases_from_single_term(LAiHTerm, 	
+				parse_aliases_domain(LAiHTerm, 	
 						LAiH_Domain),
 				from_aliases_domain_to_alias_as(LAiH_Domain,
 						LAiH),


-- 
nancy.mazur at cs.kuleuven.ac.be ------------ Katholieke Universiteit Leuven -
tel: +32-16-327596 - fax: +32-16-327996 ------- Dept. of Computer Science -
--------------------------------------------------------------------------
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