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 ']).