[mercury-users] Suggestion: Inverse DCG Notation

Terrence Brannon princepawn at earthlink.net
Thu May 3 12:01:19 AEST 2001


In the code below, you can see that most of the lines are escaped. It
would be nice to have some means of having to escape the threaded IO
lines instead of the non-thread ones, ie:

main ==> { io__read_line_as_string(W0) } ,

main --> io__read_line_as_string(W0), 
     (
	{ W0 = eof },
	print("Nothing could be read"), nl
	;
	{ W0 = error(Err) },
	io__print(io__error_message(Err) `with_type` string)
	;
	{ W0 = ok(W) },
	{  L = string__length(W) },
	{  string__substring(W, 0, L-1, W2) },
	{  I = string__det_to_int(W2) },
	  io__write_string("is"),
	  (
	     if   ({ prime(I) }) 
	       then io__write_string("")
             else 
	       io__write_string(" not") 
	  ),
	  io__write_string(" prime")
     ).


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



More information about the users mailing list