Re: Parsing Context-sensitive languages with Prolog



Alessandro <askmeformymail@xxxxxxxxxx> writes:

I seek a *good* exemple in Prolog, perhaps with the langage { a^n b^n
c^n } that is known to be context-sensitive

What about:

anbncn --> n_x(N, a), n_x(N, b), n_x(N, c).

n_x(0, _) --> [].
n_x(s(N), X) --> [X], n_x(N, X).

Yielding:

%?- anbncn(Ls, []).
%@ Ls = [] ;
%@ Ls = [a, b, c] ;
%@ Ls = [a, a, b, b, c, c] ;
%@ Ls = [a, a, a, b, b, b, c, c, c] a
%@ Yes

--
comp.lang.prolog FAQ: http://www.logic.at/prolog/faq/
.