[m-rev.] State variable syntax transformation

Ralph Becket rafe at cs.mu.OZ.AU
Mon Feb 11 14:43:11 AEDT 2002


Ralph Becket, Thursday,  7 February 2002:
> 
> I have not included the diffs for lexer.m, builtin.m, prog_io.m or
> mercury_compile.m since these haven't changed since my last posting.

Here are the diffs for those files as requested, including an updated
diff for prog_io.m that does not contain formatting changes (an
unfortunate consequence of asking vim to retab the file :)

Index: prog_io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_io.m,v
retrieving revision 1.197
diff -u -r1.197 prog_io.m
--- prog_io.m	16 Jul 2001 08:21:04 -0000	1.197
+++ prog_io.m	11 Feb 2002 03:37:30 -0000
@@ -193,7 +193,7 @@
 :- implementation.
 
 :- import_module prog_io_goal, prog_io_dcg, prog_io_pragma, prog_io_util.
-:- import_module prog_io_typeclass.
+:- import_module prog_io_typeclass, prog_io_state_vars.
 :- import_module hlds_data, hlds_pred, prog_util, prog_out.
 :- import_module globals, options, (inst).
 :- import_module recompilation, recompilation_version.
@@ -782,12 +782,19 @@
 		Term = term__functor(term__atom(":-"), [Decl], _DeclContext)
 	->
 		% It's a declaration
-		parse_decl(ModuleName, VarSet, Decl, Result)
+		parse_decl(ModuleName, VarSet0, Decl, Result)
 	; %%% some [DCG_H, DCG_B, DCG_Context]
 		% It's a DCG clause
-		Term = term__functor(term__atom("-->"), [DCG_H, DCG_B],
+		Term = term__functor(term__atom("-->"), [DCG_H0, DCG_B0],
 			DCG_Context)
 	->
+			% First perform the state variable transformation.
+			% 
+		transform_state_vars(DCG_H0, DCG_H, DCG_B0, DCG_B,
+				VarSet0, VarSet),
+
+			% Then the DCG expansion.
+			%
 		parse_dcg_clause(ModuleName, VarSet, DCG_H, DCG_B,
 				DCG_Context, Result)
 	;
@@ -797,24 +804,30 @@
 						TermContext)
 		->
 			% it's a rule
-			Head = H,
-			Body = B,
+			Head0 = H,
+			Body0 = B,
 			TheContext = TermContext
 		;
 			% it's a fact
-			Head = Term,
+			Head0 = Term,
 			(
-				Head = term__functor(_Functor, _Args,
-							HeadContext)
+				Head0 = term__functor(_Functor, _Args,
+							Head0Context)
 			->
-				TheContext = HeadContext
+				TheContext = Head0Context
 			;
 					% term consists of just a single
 					% variable - the context has been lost
 				term__context_init(TheContext)
 			),
-			Body = term__functor(term__atom("true"), [], TheContext)
+			Body0 = term__functor(term__atom("true"), [],
+						TheContext)
 		),
+
+			% Now we perform the state variable transformation.
+			%
+		transform_state_vars(Head0, Head, Body0, Body, VarSet0, VarSet),
+
 		varset__coerce(VarSet, ProgVarSet),
 		parse_goal(Body, ProgVarSet, Body2, ProgVarSet2),
 		(

Index: mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.229
diff -u -r1.229 mercury_compile.m
--- mercury_compile.m	11 Jan 2002 07:41:20 -0000	1.229
+++ mercury_compile.m	18 Jan 2002 05:20:12 -0000
@@ -1752,8 +1752,8 @@
 	mercury_compile__maybe_unneeded_code(HLDS39, Verbose, Stats, HLDS40),
 	mercury_compile__maybe_dump_hlds(HLDS40, "40", "unneeded_code"),
 
-	mercury_compile__maybe_lco(HLDS40, Verbose, Stats, HLDS42), !,
-	mercury_compile__maybe_dump_hlds(HLDS42, "42", "lco"), !,
+	mercury_compile__maybe_lco(HLDS40, Verbose, Stats, HLDS42),
+	mercury_compile__maybe_dump_hlds(HLDS42, "42", "lco"),
 
 	% DNF transformations should be after inlining.
 	mercury_compile__maybe_transform_dnf(HLDS40, Verbose, Stats, HLDS44),

Index: lexer.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/lexer.m,v
retrieving revision 1.34
diff -u -r1.34 lexer.m
--- lexer.m	28 Mar 2000 03:40:38 -0000	1.34
+++ lexer.m	18 Jan 2002 04:53:38 -0000
@@ -511,8 +511,9 @@
 lexer__special_token('|', ht_sep).
 lexer__special_token(',', comma).
 lexer__special_token(';', name(";")).
-lexer__special_token('!', name("!")).
+% lexer__special_token('!', name("!")).
 
+lexer__graphic_token_char('!').
 lexer__graphic_token_char('#').
 lexer__graphic_token_char('$').
 lexer__graphic_token_char('&').

Index: builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.64
diff -u -r1.64 builtin.m
--- builtin.m	19 Dec 2001 02:54:04 -0000	1.64
+++ builtin.m	18 Jan 2002 04:58:18 -0000
@@ -174,11 +174,11 @@
 % backwards compatibility with Prolog systems.  But of course it only works
 % if all your cuts are green cuts.
 
-:- pred ! is det.
-
-:- pred !(T, T).
-:- mode !(di, uo) is det.
-:- mode !(in, out) is det.
+% :- pred ! is det.
+% 
+% :- pred !(T, T).
+% :- mode !(di, uo) is det.
+% :- mode !(in, out) is det.
 
 %-----------------------------------------------------------------------------%
 
@@ -269,8 +269,8 @@
 
 %-----------------------------------------------------------------------------%
 
-!.
-!(X, X).
+% !.
+% !(X, X).
 
 %-----------------------------------------------------------------------------%
 
--------------------------------------------------------------------------
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