Hi,
I'm doing some 'sentence translation' for a module which parses code related to Prolog. But, some of its syntax is hard to get Ciao to see as being a 'sentence'; I'll be grateful for any suggestions. It's this:
compute 1 { not fail }.
I can get
{ not fail }.
and
compute x.
recognized separately by making 'not' and 'compute' be operators, but, no non-infix prolog operator can have two arguments and that's what it seems 'compute' needs. So, how to get such a construct recognized by the sentence / clause / term translation machinery?
%% Note that this obvious-seeming version doesn't work. braces_sentence_trans(compute(N){X},[],_M) :- message(['full compute ']).
-- If it's too far from prolog syntax for the sentence translation machinery is it possible to wrap it somehow, or to make the sentence translation more flexible? Or is there a more powerful technique? Thanks for any help;
Jeff Donner
(Attached are simple illustrative files; braces_tr is the translation module, braces is the package, braces_test contains the items which all parse except for the last. To build it put braces and braces_tr in your ciao library directory and make them .po files (emacs/C-c o), do 'braces_tr' before 'braces').
:- load_compilation_module(library(braces_tr)). :- op(900, fy, 'compute'). :- op(900, fy, 'not').
:- add_sentence_trans(braces_sentence_trans/3).
:- use_package(library(braces)).
{ foo(X), bar(Y) } :- sausage(X).
{ not foo }.
compute 9.
compute 1 { not fail }.
:- module(braces_tr, [braces_sentence_trans/3]).
braces_sentence_trans(0,[],Module) :- !, message(['sentence sign-on. Module ',Module,':']).
braces_sentence_trans(end_of_file,[],_M) :- !, message(['EOF']), fail.
%% handles singles and lists! braces_sentence_trans(({X} :- Body),[],_M) :- message(['braces ']).
braces_sentence_trans(not(S),[],_M) :- message(['not ']).
braces_sentence_trans(compute(N),[],_M) :- message(['compute ']).
%% Note that this doesn't work. braces_sentence_trans((compute(N){X}),[],_M) :- message(['full compute ']).
Dear Jeff,
I'm afraid that what you want to do is not possible with sentence translations. You need to have legal prolog terms in the source, which then can be possibly managed by a sentence translation to produce prolog code.
Daniel Cabeza ============================================================================== Message: Address: Action: help majordomo(a)clip.dia.fi.upm.es Info. on useful commands subscribe ciao-users-request(a)clip.dia.fi.upm.es Subscribe to this list unsubscribe ciao-users-request(a)clip.dia.fi.upm.es Unsubscribe from this list <whatever> ciao-users(a)clip.dia.fi.upm.es Send message to list ----------------------------------------------------------------------------- Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/ -----------------------------------------------------------------------------