problem with DCG (Definite Clause Gramma) rule



Hi,

I have one problem egarding a DCG (Definite Clause Grammar) rule in SWI
Prolog.

Please have a look at the 6 examples below.

A. Jomes, S. Jackson, and F. Tom.
A. Timothy.
O. Jack, P. Johnson, and A. Tracker.
X. Sue, T. Ramsay, S. Machusita, and J. Rao.
Macky and Lower.
Pavel.

I want to create DCG rule for these kind of sentences.

And assume that each character (or symbol) appears
as a separate entry in a list. For example the last example
appears as

[ 'P' , a , v , e , l , '.' ]

Basically what I want in simple english is that.

a list is a sentence if it is terminated by the sequence of
two characters and one period. That is the delimiter for
every sentence is [ X , Y , '.' ] where X and Y are characters.
In other words this sequence acts as a delimiter.

I dont want to simply check last 3 elements of the list. That
is trivial. But I dont wan tto do that. As I will be later putting
it as part of bigger list. So I have to do it in this way only.

I have also created predicate has_no_such_sequence(List) which
is true if the list contains sequence of character,character,period at
any position (as mentioened already).

I tried creating DCG for this.

sentence --> X , { has_no_such_sequence(X) } , "." .

I want to say X is a "list with no such sequence" ; followed by a
period.

And when I run this DCG rule.

? sentence("Hello.",[]).
ERROR: Out of local stack

no matter what i enter as list I get this error.
So how do I get rid of it? Well in above query the double quote is just
another way of writing list. thats not an issue.

I guess some issue with my DCG rule. pls explain how do I get it
working fine ? I want to do it with DCG only.

Declaratively its correct. But I am sure there is some precedural
level problem. Will someone pls correct me?

By the way I use SWI-Prolog.

thanks
-Sam B.

.