🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3010

Re: Prolog Grammar Rules

#3010
From: Chris Moss
Date: Mon, 22 Feb 1988 18:02
69 lines
2636 bytes
In article <667@cresswell.quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes:
>In article <489@ashton.UUCP>, dwiggins@ashtate (Don Dwiggins) writes:
>> In the translation from DCG rules to clauses, O'Keefe has terminals being
>> translated to goals of the form "connects(Terminal, Pos1, Pos2)", ...
>> ... Actually, this predicate can be
>> "folded into" the translator, so that no calls to connects/3 remain in the
>> translated clauses (this is the translation presented by Clocksin & Mellish).
>
>This is true, but you have to be *extremely* careful, and I'm afraid the
>version in Clocksin & Mellish isn't.  The trouble is cuts.
>

I agree.
Another problem is with disjunctions.

>...  Suppose you want to recognise statements in
>C, and would like to exploit indexing.  You might start with this (where
>I've suppressed irrelevant detail and a lot of rules):
>
>	statement --> ['{'], rest_of_block.
>	statement --> [if], rest_of_if.
>	statement --> [return], rest_of_return.
...
>This isn't going to be indexed in most Prolog implementations.
...
>   What can we do?
>We can read ahead one token.
>
>	statement --> expression, [;], !.
>	statement --> [First], statement(First).
>
>	statement('{')    --> rest_of_block.

I think Richard has disproved his own case here. Clearly it is DIFFICULT to
do the translation right, but it isn't IMPOSSIBLE.

What happens? 

Instead of a perfectly good declarative grammar one is forced(?) to recode
it in a much more obscure fashion. Maybe Colmerauer was right when he
dropped grammar rules in Prolog II (:-). 

It would seem a perfectly good compromise to use connects (or =) after ANY
non-grammatical predicate (in {}), or after a disjunction.

As an unrelated comment, why should ! be allowed in a dcg rule except within
{}? It seems a grubby implementation concession! Everything else is a 
proper grammatical object--terminal or non-terminal. ! is not translated to
!(S1,S2), so why should it be given privileged treatment?

Chris Moss.
Imperial College.


m to stop a silly poster limit
m
m
m
m
m
m
m
m
m
m
m
m
m
Technical Details
Message-ID: <204@gould.doc.ic.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!ukc!eagle!icdoc!ivax!cdsm
References: <646@cresswell.quintus.UUCP> <489@ashton.UUCP> <667@cresswell.quintus.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!ukc!eagle!icdoc!ivax!cdsm
From: cdsm@ivax.doc.ic.ac.uk (Chris Moss)
Newsgroups: comp.lang.prolog
Subject: Re: Prolog Grammar Rules
Message-ID: <204@gould.doc.ic.ac.uk>
Date: 22 Feb 88 18:02:37 GMT
References: <646@cresswell.quintus.UUCP> <489@ashton.UUCP> <667@cresswell.quintus.UUCP>
Sender: news@doc.ic.ac.uk
Reply-To: cdsm@doc.ic.ac.uk (Chris Moss)
Organization: Dept. of Computing, Imperial College, London, UK.
Lines: 69
Keywords: DCGs tutorial