[mercury-users] Prolog DCGs Pattern Matching in Mercury
Goncalo Jorge Coelho e Silva
l10454 at alunos.uevora.pt
Tue Apr 29 09:58:02 AEST 2003
Hi Ralph and all,
>DCGs are the same in Mercury and Prolog. Strings in Mercury, however,
>are primitive whereas in Prolog they are lists of character codes, which
>is one of the reasons why your program won't work.
hmmm, I'm not sure what you meant here.
Do you mean I won't be able to handle DGC
pattern matching arguments, that might be
a mix of strings and variables?
To give a specific example of what I'd
like to do, look at this very simplistic
approach (where the top lines are
pseudo-code and the bottom ones, would be
close Mercury syntax):
% set_value Vn
% ------------
% HEAP[H] <- Vm ;
% H <- H+1;
%code_gen([set_value V | Tail],Heap, H) -->
% {
% array__array_set(Heap,H,V),
% H_New = H + 1,
% }
% code_gen(Tail,H_New,Heap).
So, in a nutshell, I'd like to iterate
a list or an array, and be able to generate
a specific set of instructions for that
pattern... no necessarily IO instructions
(OK, my last post example was not so fortunate
with the line:
"{nl, write(' matched "name(_something_)" '), nl}"
... in fact, no IO at all.
Thanks a lot.
Cheers,
Goncalo
--------------------------------------------------------------------------
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