0

How to translate Prolog DCG to standard Prolog clauses:

nombres(nom(N),Number,Genero,Traduccion)-->
    [N],
    {
        atom_codes(N, NombreEntero),
        append(Nombre, Terminacion, NombreEntero),
        atom_codes(Nom, Nombre),
        es_nombre(Nom, Genero, Traduc),
        atom_codes(Ter, Terminacion),
        end_name(Ter, Number),
        atom_codes(Traduc, TRaux),
        atom_codes(Ter, TEaux),
        append(TRaux, TEaux, Tra),
        atom_codes(Traduccion, Tra)
    }.

What I have at the moment is:

nombres(N,Number,Genero,Input,Traduccion):-
    'C'(Input,N,Traduccion),
    atom_codes(N, NombreEntero),
    append(Nombre, Terminacion, NombreEntero),
    atom_codes(Nom, Nombre),
    es_nombre(Nom, Genero, Traduc),
    atom_codes(Ter, Terminacion),
    end_name(Ter, Number),
    atom_codes(Traduc, TRaux),
    atom_codes(Ter, TEaux),
    append(TRaux, TEaux, Tra),
    atom_codes(Traduccion, Tra).

I know that translation is possible, but with the examples I've seen, I can not understand the concept of how to do it.

false
  • 10,264
  • 13
  • 101
  • 209
Greibus
  • 1
  • 1
  • 3
    In prolog, put in your DCG and just enter `listing(nombres)`. It will give you the standard predicate implementation. – lurker Nov 05 '18 at 01:05
  • See this [asnwer](https://stackoverflow.com/a/31172333/1243762) for example. Note that `listing/1` has to be used for each predicate of DCG. – Guy Coder Nov 05 '18 at 10:13

0 Answers0