Subject: RE: unifying terms with a DCG syntax

From: "Douglas Miles (Volt Computer)" <[email-masked]>
Date: Tue, 20 Jun 2000 07:50:08 -0700

Oh thats right.. silly me

that the Clause is a term starting with ','/2 usually

So i have my answer,

Parsing down the DCG right hand side by collecting terms out of ','/2

thanks,
Douglas

-----Original Message-----
From: Douglas Miles (Volt Computer) [mailto:[email-masked]]
Sent: Thursday, June 08, 2000 5:32 PM
To: [email-masked]
Subject: unifying terms with a DCG syntax

I have a question about unifying terms with a DCG syntax

like In this case... of this example

%%%%%%%%%%%%%%%%%%
:-retractall(dcg_macro(_)).
:-see('O:/output/espg.dcg'),repeat,read(Datum),app(Datum),Datum=end_of_file,
seen.

app(end_of_file):-!.
app((Macro-->CLAUSES)):-!,
		retractall(dcg_macro(Macro)),
		assert(dcg_macro(Macro)),
		expand_term((Macro-->CLAUSES),Prolog),
		assert(Prolog),
		split_dcg_clause(CLAUSES,Terms,Conditions),
		assert(dcg_tree(Macro,Terms,Conditions)).

app(Prolog):-!,assert(Prolog).

split_dcg_clause( ( Terms,{Conditions} ) , Terms, Conditions):-!.
split_dcg_clause( Terms, Terms, true ):-is_list(Terms),!.
split_dcg_clause( ( Terms,{} ) , Terms, true ):-is_list(Terms),!.
% ....
% ....
%%%%%%%%%%%%%%%%%%

You can easily see how my   split_dcg_clause/2 is not sufficient.

but I am not sure if there is an easy way to do this already?
Any way better then an everycase senario ;>

/* dcg files contains... */

sayable(avatar(Avatar)) --> [Avatar],
	{if(avatar(Avatar))}.
sayable(location(Name)) --> [at],sayable(Name), {nonvar(Name)}.
sayable(thing_part(Avatar,Part)) --> sayable(Part),[of],sayable(Avatar),
	{
	nonvar(Avatar),nonvar(Part)
	}.

	%	sayable(bodypart(Part)),[of],sayable(avatar(Avatar)),
	%		{if(bodypart(Part)),if(avatar(Avatar))}.

sayable(pthing(Thing))--> [a,Thing],
	{if(pthing(Thing))}.
sayable(athing(Thing))--> [a,Thing],
        {if(athing(Thing))}.

sayable(sense_organ(Sense)) --> [the,Sense],
	{if(sense_organ(Sense))}.
sayable(bodypart(Bpart))-->[Bpart],
	{if(bodypart(Bpart))}.

sayable(Anything) --> [Anything],{ground(Anything)}.

----------------
* To UNSUBSCRIBE, please use the HTML form at

    http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist

or send mail to [email-masked] using the Subject:
"unsubscribe"
(without the quotes) and *no* message body.

** An ARCHIVE of this list is maintained at

    http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/